diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index a8bcd1d9650..2ea8fc96846 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -419,6 +419,9 @@ Release 2.4.0 - UNRELEASED HDFS-6028. Print clearer error message when user attempts to delete required mask entry from ACL. (cnauroth) + HDFS-6039. Uploading a File under a Dir with default acls throws "Duplicated + ACLFeature". (cnauroth) + Release 2.3.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java index ea23e6a25c8..d143075f4f3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java @@ -2246,6 +2246,7 @@ public class FSDirectory implements Closeable { final Quota.Counts counts = child.computeQuotaUsage(); updateCount(iip, pos, counts.get(Quota.NAMESPACE), counts.get(Quota.DISKSPACE), checkQuota); + boolean isRename = (child.getParent() != null); final INodeDirectory parent = inodes[pos-1].asDirectory(); boolean added = false; try { @@ -2260,7 +2261,9 @@ public class FSDirectory implements Closeable { -counts.get(Quota.NAMESPACE), -counts.get(Quota.DISKSPACE)); } else { iip.setINode(pos - 1, child.getParent()); - AclStorage.copyINodeDefaultAcl(child); + if (!isRename) { + AclStorage.copyINodeDefaultAcl(child); + } addToInodeMap(child); } return added; 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 d3dc844d015..c9a64844ed9 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 @@ -1063,6 +1063,45 @@ public abstract class FSAclBaseTest { assertAclFeature(dirPath, true); } + @Test + public void testDefaultAclRenamedFile() throws Exception { + Path dirPath = new Path(path, "dir"); + FileSystem.mkdirs(fs, dirPath, FsPermission.createImmutable((short)0750)); + List aclSpec = Lists.newArrayList( + aclEntry(DEFAULT, USER, "foo", ALL)); + fs.setAcl(dirPath, aclSpec); + Path filePath = new Path(path, "file1"); + fs.create(filePath).close(); + fs.setPermission(filePath, FsPermission.createImmutable((short)0640)); + Path renamedFilePath = new Path(dirPath, "file1"); + fs.rename(filePath, renamedFilePath); + AclEntry[] expected = new AclEntry[] { }; + AclStatus s = fs.getAclStatus(renamedFilePath); + AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]); + assertArrayEquals(expected, returned); + assertPermission(renamedFilePath, (short)0640); + assertAclFeature(renamedFilePath, false); + } + + @Test + public void testDefaultAclRenamedDir() throws Exception { + Path dirPath = new Path(path, "dir"); + FileSystem.mkdirs(fs, dirPath, FsPermission.createImmutable((short)0750)); + List aclSpec = Lists.newArrayList( + aclEntry(DEFAULT, USER, "foo", ALL)); + fs.setAcl(dirPath, aclSpec); + Path subdirPath = new Path(path, "subdir"); + FileSystem.mkdirs(fs, subdirPath, FsPermission.createImmutable((short)0750)); + Path renamedSubdirPath = new Path(dirPath, "subdir"); + fs.rename(subdirPath, renamedSubdirPath); + AclEntry[] expected = new AclEntry[] { }; + AclStatus s = fs.getAclStatus(renamedSubdirPath); + AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]); + assertArrayEquals(expected, returned); + assertPermission(renamedSubdirPath, (short)0750); + assertAclFeature(renamedSubdirPath, false); + } + @Test public void testSkipAclEnforcementPermsDisabled() throws Exception { Path bruceDir = new Path(path, "bruce"); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testAclCLI.xml b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testAclCLI.xml index c01c56d46a3..2edc46e5d79 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testAclCLI.xml +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testAclCLI.xml @@ -972,5 +972,55 @@ + + copyFromLocal: copying file into a directory with a default ACL + + -fs NAMENODE -mkdir /dir1 + -fs NAMENODE -setfacl -m default:user:charlie:rwx /dir1 + -fs NAMENODE -copyFromLocal CLITEST_DATA/data15bytes /dir1/data15bytes + -fs NAMENODE -getfacl /dir1/data15bytes + + + -fs NAMENODE -rm -R /dir1 + + + + RegexpComparator + ^# file: /dir1/data15bytes$ + + + RegexpComparator + ^# owner: USERNAME$ + + + RegexpComparator + ^# group: supergroup$ + + + RegexpComparator + ^user::rw-$ + + + RegexpComparator + ^user:charlie:rwx\t#effective:r--$ + + + RegexpComparator + ^group::r-x\t#effective:r--$ + + + RegexpComparator + ^mask::r--$ + + + RegexpComparator + ^other::r--$ + + + RegexpAcrossOutputComparator + .*(?!default).* + + +