src/solaris/classes/sun/nio/fs/UnixSecureDirectoryStream.java
Print this page
*** 38,48 ****
/**
* Unix implementation of SecureDirectoryStream.
*/
class UnixSecureDirectoryStream
! extends SecureDirectoryStream<Path>
{
private final UnixDirectoryStream ds;
private final int dfd;
UnixSecureDirectoryStream(UnixPath dir,
--- 38,48 ----
/**
* Unix implementation of SecureDirectoryStream.
*/
class UnixSecureDirectoryStream
! implements SecureDirectoryStream<Path>
{
private final UnixDirectoryStream ds;
private final int dfd;
UnixSecureDirectoryStream(UnixPath dir,
*** 79,88 ****
--- 79,102 ----
if (!(obj instanceof UnixPath))
throw new ProviderMismatchException();
return (UnixPath)obj;
}
+ private boolean followLinks(LinkOption... options) {
+ boolean followLinks = true;
+ for (LinkOption option: options) {
+ if (option == LinkOption.NOFOLLOW_LINKS) {
+ followLinks = false;
+ continue;
+ }
+ if (option == null)
+ throw new NullPointerException();
+ throw new AssertionError("Should not get here");
+ }
+ return followLinks;
+ }
+
/**
* Opens sub-directory in this directory
*/
@Override
public SecureDirectoryStream<Path> newDirectoryStream(Path obj,
*** 89,99 ****
LinkOption... options)
throws IOException
{
UnixPath file = getName(obj);
UnixPath child = ds.directory().resolve(file);
! boolean followLinks = file.getFileSystem().followLinks(options);
// permission check using name resolved against original path of directory
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
child.checkRead();
--- 103,113 ----
LinkOption... options)
throws IOException
{
UnixPath file = getName(obj);
UnixPath child = ds.directory().resolve(file);
! boolean followLinks = followLinks(options);
// permission check using name resolved against original path of directory
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
child.checkRead();
*** 300,310 ****
public <V extends FileAttributeView> V getFileAttributeView(Path obj,
Class<V> type,
LinkOption... options)
{
UnixPath file = getName(obj);
! boolean followLinks = file.getFileSystem().followLinks(options);
return getFileAttributeViewImpl(file, type, followLinks);
}
/**
* A BasicFileAttributeView implementation that using a dfd/name pair.
--- 314,324 ----
public <V extends FileAttributeView> V getFileAttributeView(Path obj,
Class<V> type,
LinkOption... options)
{
UnixPath file = getName(obj);
! boolean followLinks = followLinks(options);
return getFileAttributeViewImpl(file, type, followLinks);
}
/**
* A BasicFileAttributeView implementation that using a dfd/name pair.
*** 334,346 ****
--- 348,364 ----
}
private void checkWriteAccess() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
+ if (file == null) {
+ ds.directory().checkWrite();
+ } else {
ds.directory().resolve(file).checkWrite();
}
}
+ }
@Override
public String name() {
return "basic";
}