You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by we...@apache.org on 2019/04/04 11:07:43 UTC
[hadoop] branch branch-3.0 updated: HDFS-14389. getAclStatus
returns incorrect permissions and owner when an iNodeAttributeProvider is
configured. Contributed by Stephen O'Donnell.
This is an automated email from the ASF dual-hosted git repository.
weichiu pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 79714fd HDFS-14389. getAclStatus returns incorrect permissions and owner when an iNodeAttributeProvider is configured. Contributed by Stephen O'Donnell.
79714fd is described below
commit 79714fdfabebb1216c2675bdaf4a386da5683454
Author: Stephen O'Donnell <so...@cloudera.com>
AuthorDate: Thu Apr 4 04:04:08 2019 -0700
HDFS-14389. getAclStatus returns incorrect permissions and owner when an iNodeAttributeProvider is configured. Contributed by Stephen O'Donnell.
Signed-off-by: Wei-Chiu Chuang <we...@apache.org>
(cherry picked from commit c528e427aa6745434672b1c1850738795ad1d6d2)
(cherry picked from commit 388f445dde577999b2d81f809adcfca8f0958499)
(cherry picked from commit d9899015ebf8a27e9ac339d8a8b3c9d88bcbacb9)
---
.../hadoop/hdfs/server/namenode/FSDirAclOp.java | 9 +++---
.../namenode/TestINodeAttributeProvider.java | 33 ++++++++++++++++++++++
2 files changed, 37 insertions(+), 5 deletions(-)
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 7b3471d..917708b 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<AclEntry> acl = AclStorage.readINodeAcl(fsd.getAttributes(iip));
- FsPermission fsPermission = inode.getFsPermission(snapshotId);
+ INodeAttributes inodeAttrs = fsd.getAttributes(iip);
+ List<AclEntry> 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 b3bab06..788ee30 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<Void>() {
+ @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;
+ }
+ });
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org