diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirMkdirOp.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirMkdirOp.java index 2f0a0fc298..95e889888b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirMkdirOp.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirMkdirOp.java @@ -17,6 +17,7 @@ */ package org.apache.hadoop.hdfs.server.namenode; +import org.apache.hadoop.fs.permission.FsCreateModes; import com.google.common.base.Preconditions; import org.apache.hadoop.fs.FileAlreadyExistsException; import org.apache.hadoop.fs.FileStatus; @@ -187,10 +188,19 @@ private static INodesInPath createSingleDirectory(FSDirectory fsd, private static PermissionStatus addImplicitUwx(PermissionStatus parentPerm, PermissionStatus perm) { FsPermission p = parentPerm.getPermission(); - FsPermission ancestorPerm = new FsPermission( - p.getUserAction().or(FsAction.WRITE_EXECUTE), - p.getGroupAction(), - p.getOtherAction()); + FsPermission ancestorPerm; + if (p.getUnmasked() == null) { + ancestorPerm = new FsPermission( + p.getUserAction().or(FsAction.WRITE_EXECUTE), + p.getGroupAction(), + p.getOtherAction()); + } else { + ancestorPerm = FsCreateModes.create( + new FsPermission( + p.getUserAction().or(FsAction.WRITE_EXECUTE), + p.getGroupAction(), + p.getOtherAction()), p.getUnmasked()); + } return new PermissionStatus(perm.getUserName(), perm.getGroupName(), ancestorPerm); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/FSAclBaseTest.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/FSAclBaseTest.java index ee92217626..fd50648637 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/FSAclBaseTest.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/FSAclBaseTest.java @@ -1150,7 +1150,7 @@ public void testDefaultAclNewDirIntermediate() throws Exception { AclStatus s = fs.getAclStatus(dirPath); AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]); assertArrayEquals(expected, returned); - assertPermission(dirPath, (short)010750); + assertPermission(dirPath, (short)010770); assertAclFeature(dirPath, true); s = fs.getAclStatus(subdirPath); returned = s.getEntries().toArray(new AclEntry[0]); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testAclCLIWithPosixAclInheritance.xml b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testAclCLIWithPosixAclInheritance.xml index 7e9ace1444..9ff71b86fa 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testAclCLIWithPosixAclInheritance.xml +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testAclCLIWithPosixAclInheritance.xml @@ -740,6 +740,83 @@ + + + setfacl : check inherit default ACL to ancestor dir with mkdir -p + + -fs NAMENODE -mkdir /dir1 + -fs NAMENODE -setfacl -m default:user:charlie:r-x,default:group:admin:rwx /dir1 + -fs NAMENODE -mkdir -p /dir1/dir2/dir3 + -fs NAMENODE -getfacl /dir1/dir2 + + + -fs NAMENODE -rm -R /dir1 + + + + SubstringComparator + # file: /dir1/dir2 + + + SubstringComparator + # owner: USERNAME + + + SubstringComparator + # group: supergroup + + + SubstringComparator + user::rwx + + + + RegexpComparator + ^user:charlie:r-x$ + + + SubstringComparator + group::r-x + + + + RegexpComparator + ^group:admin:rwx$ + + + RegexpComparator + ^mask::rwx$ + + + SubstringComparator + default:user::rwx + + + SubstringComparator + default:user:charlie:r-x + + + SubstringComparator + default:group::r-x + + + SubstringComparator + default:group:admin:rwx + + + SubstringComparator + default:mask::rwx + + + SubstringComparator + default:other::r-x + + + SubstringComparator + other::r-x + + + getfacl -R : recursive