diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAclOp.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAclOp.java index 7b3471dcf59..917708b6ee5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAclOp.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAclOp.java @@ -153,12 +153,11 @@ class FSDirAclOp { if (iip.isDotSnapshotDir() && fsd.getINode4DotSnapshot(iip) != null) { return new AclStatus.Builder().owner("").group("").build(); } - INode inode = FSDirectory.resolveLastINode(iip); - int snapshotId = iip.getPathSnapshotId(); - List acl = AclStorage.readINodeAcl(fsd.getAttributes(iip)); - FsPermission fsPermission = inode.getFsPermission(snapshotId); + INodeAttributes inodeAttrs = fsd.getAttributes(iip); + List acl = AclStorage.readINodeAcl(inodeAttrs); + FsPermission fsPermission = inodeAttrs.getFsPermission(); return new AclStatus.Builder() - .owner(inode.getUserName()).group(inode.getGroupName()) + .owner(inodeAttrs.getUserName()).group(inodeAttrs.getGroupName()) .stickyBit(fsPermission.getStickyBit()) .setPermission(fsPermission) .addEntries(acl).build(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeAttributeProvider.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeAttributeProvider.java index b3bab06e3f2..788ee301c08 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeAttributeProvider.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeAttributeProvider.java @@ -405,4 +405,37 @@ public class TestINodeAttributeProvider { return null; }); } + + @Test + // HDFS-14389 - Ensure getAclStatus returns the owner, group and permissions + // from the Attribute Provider, and not from HDFS. + public void testGetAclStatusReturnsProviderOwnerPerms() throws Exception { + FileSystem fs = FileSystem.get(miniDFS.getConfiguration(0)); + final Path userPath = new Path("/user"); + final Path authz = new Path("/user/authz"); + final Path authzChild = new Path("/user/authz/child2"); + + fs.mkdirs(userPath); + fs.setPermission(userPath, new FsPermission(HDFS_PERMISSION)); + fs.mkdirs(authz); + fs.setPermission(authz, new FsPermission(HDFS_PERMISSION)); + fs.mkdirs(authzChild); + fs.setPermission(authzChild, new FsPermission(HDFS_PERMISSION)); + UserGroupInformation ugi = UserGroupInformation.createUserForTesting("u1", + new String[]{"g1"}); + ugi.doAs(new PrivilegedExceptionAction() { + @Override + public Void run() throws Exception { + FileSystem fs = FileSystem.get(miniDFS.getConfiguration(0)); + Assert.assertEquals(PROVIDER_PERMISSION, + fs.getFileStatus(authzChild).getPermission().toShort()); + + Assert.assertEquals("foo", fs.getAclStatus(authzChild).getOwner()); + Assert.assertEquals("bar", fs.getAclStatus(authzChild).getGroup()); + Assert.assertEquals(PROVIDER_PERMISSION, + fs.getAclStatus(authzChild).getPermission().toShort()); + return null; + } + }); + } }