use of org.apache.hadoop.fs.permission.AclEntry in project hadoop by apache.
the class FSAclBaseTest method testSetAclMinimalDefault.
@Test
public void testSetAclMinimalDefault() throws IOException {
FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short) 0750));
List<AclEntry> aclSpec = Lists.newArrayList(aclEntry(DEFAULT, USER, ALL), aclEntry(DEFAULT, GROUP, READ_EXECUTE), aclEntry(DEFAULT, OTHER, NONE));
fs.setAcl(path, aclSpec);
AclStatus s = fs.getAclStatus(path);
AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
assertArrayEquals(new AclEntry[] { aclEntry(DEFAULT, USER, ALL), aclEntry(DEFAULT, GROUP, READ_EXECUTE), aclEntry(DEFAULT, OTHER, NONE) }, returned);
assertPermission((short) 010750);
assertAclFeature(true);
}
use of org.apache.hadoop.fs.permission.AclEntry in project hadoop by apache.
the class FSAclBaseTest method testDefaultMinimalAclNewDir.
@Test
public void testDefaultMinimalAclNewDir() throws Exception {
FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short) 0750));
List<AclEntry> aclSpec = Lists.newArrayList(aclEntry(DEFAULT, USER, ALL), aclEntry(DEFAULT, GROUP, READ_EXECUTE), aclEntry(DEFAULT, OTHER, NONE));
fs.setAcl(path, aclSpec);
Path dirPath = new Path(path, "dir1");
fs.mkdirs(dirPath);
AclStatus s = fs.getAclStatus(dirPath);
AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
assertArrayEquals(new AclEntry[] { aclEntry(DEFAULT, USER, ALL), aclEntry(DEFAULT, GROUP, READ_EXECUTE), aclEntry(DEFAULT, OTHER, NONE) }, returned);
assertPermission(dirPath, (short) 010750);
assertAclFeature(dirPath, true);
}
use of org.apache.hadoop.fs.permission.AclEntry in project hadoop by apache.
the class FSAclBaseTest method testUMaskDefaultAclNewDir.
@Test
public void testUMaskDefaultAclNewDir() throws Exception {
FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short) 0750));
List<AclEntry> aclSpec = Lists.newArrayList(aclEntry(DEFAULT, GROUP, ALL), aclEntry(DEFAULT, USER, "foo", ALL));
fs.setAcl(path, aclSpec);
String oldUMask = fs.getConf().get(FS_PERMISSIONS_UMASK_KEY);
fs.getConf().set(FS_PERMISSIONS_UMASK_KEY, "027");
FSDirectory fsDirectory = cluster.getNamesystem().getFSDirectory();
boolean oldEnabled = fsDirectory.isPosixAclInheritanceEnabled();
try {
fsDirectory.setPosixAclInheritanceEnabled(false);
Path dirPath = new Path(path, "dir1");
fs.mkdirs(dirPath);
AclStatus s = fs.getAclStatus(dirPath);
AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
assertArrayEquals(new AclEntry[] { aclEntry(ACCESS, USER, "foo", ALL), aclEntry(ACCESS, GROUP, ALL), aclEntry(DEFAULT, USER, ALL), aclEntry(DEFAULT, USER, "foo", ALL), aclEntry(DEFAULT, GROUP, ALL), aclEntry(DEFAULT, MASK, ALL), aclEntry(DEFAULT, OTHER, NONE) }, returned);
assertPermission(dirPath, (short) 010750);
fsDirectory.setPosixAclInheritanceEnabled(true);
Path dir2Path = new Path(path, "dir2");
fs.mkdirs(dir2Path);
AclStatus s2 = fs.getAclStatus(dir2Path);
AclEntry[] returned2 = s2.getEntries().toArray(new AclEntry[0]);
assertArrayEquals(new AclEntry[] { aclEntry(ACCESS, USER, "foo", ALL), aclEntry(ACCESS, GROUP, ALL), aclEntry(DEFAULT, USER, ALL), aclEntry(DEFAULT, USER, "foo", ALL), aclEntry(DEFAULT, GROUP, ALL), aclEntry(DEFAULT, MASK, ALL), aclEntry(DEFAULT, OTHER, NONE) }, returned2);
assertPermission(dir2Path, (short) 010770);
} finally {
fsDirectory.setPosixAclInheritanceEnabled(oldEnabled);
fs.getConf().set(FS_PERMISSIONS_UMASK_KEY, oldUMask);
}
}
use of org.apache.hadoop.fs.permission.AclEntry in project hadoop by apache.
the class FSAclBaseTest method testModifyAclEntries.
@Test
public void testModifyAclEntries() throws IOException {
FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short) 0750));
List<AclEntry> aclSpec = Lists.newArrayList(aclEntry(ACCESS, USER, ALL), aclEntry(ACCESS, USER, "foo", ALL), aclEntry(ACCESS, GROUP, READ_EXECUTE), aclEntry(ACCESS, OTHER, NONE), aclEntry(DEFAULT, USER, "foo", ALL));
fs.setAcl(path, aclSpec);
aclSpec = Lists.newArrayList(aclEntry(ACCESS, USER, "foo", READ_EXECUTE), aclEntry(DEFAULT, USER, "foo", READ_EXECUTE));
fs.modifyAclEntries(path, aclSpec);
AclStatus s = fs.getAclStatus(path);
AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
assertArrayEquals(new AclEntry[] { aclEntry(ACCESS, USER, "foo", READ_EXECUTE), aclEntry(ACCESS, GROUP, READ_EXECUTE), aclEntry(DEFAULT, USER, ALL), aclEntry(DEFAULT, USER, "foo", READ_EXECUTE), aclEntry(DEFAULT, GROUP, READ_EXECUTE), aclEntry(DEFAULT, MASK, READ_EXECUTE), aclEntry(DEFAULT, OTHER, NONE) }, returned);
assertPermission((short) 010750);
assertAclFeature(true);
}
use of org.apache.hadoop.fs.permission.AclEntry in project hadoop by apache.
the class FSAclBaseTest method testOnlyAccessAclNewDir.
@Test
public void testOnlyAccessAclNewDir() throws Exception {
FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short) 0750));
List<AclEntry> aclSpec = Lists.newArrayList(aclEntry(ACCESS, USER, "foo", ALL));
fs.modifyAclEntries(path, aclSpec);
Path dirPath = new Path(path, "dir1");
fs.mkdirs(dirPath);
AclStatus s = fs.getAclStatus(dirPath);
AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
assertArrayEquals(new AclEntry[] {}, returned);
assertPermission(dirPath, (short) 0755);
assertAclFeature(dirPath, false);
}
Aggregations