HDFS-13194. CachePool permissions incorrectly checked. Contributed by Jianfei Jiang.

(cherry picked from commit a9c14b1119)
This commit is contained in:
Yiqun Lin 2018-02-28 10:17:43 +08:00
parent 2f18785f39
commit 08cd911b69
2 changed files with 18 additions and 1 deletions

View File

@ -500,7 +500,9 @@ public class FSPermissionChecker implements AccessControlEnforcer {
&& mode.getGroupAction().implies(access)) {
return;
}
if (mode.getOtherAction().implies(access)) {
if (!getUser().equals(pool.getOwnerName())
&& !isMemberOfGroup(pool.getGroupName())
&& mode.getOtherAction().implies(access)) {
return;
}
throw new AccessControlException("Permission denied while accessing pool "

View File

@ -391,6 +391,9 @@ public class TestCacheDirectives {
setMode(new FsPermission((short)0777)));
proto.addCachePool(new CachePoolInfo("pool4").
setMode(new FsPermission((short)0)));
proto.addCachePool(new CachePoolInfo("pool5").
setMode(new FsPermission((short)0007))
.setOwnerName(unprivilegedUser.getShortUserName()));
CacheDirectiveInfo alpha = new CacheDirectiveInfo.Builder().
setPath(new Path("/alpha")).
@ -459,6 +462,18 @@ public class TestCacheDirectives {
long deltaId = addAsUnprivileged(delta);
try {
addAsUnprivileged(new CacheDirectiveInfo.Builder().
setPath(new Path("/epsilon")).
setPool("pool5").
build());
fail("expected an error when adding to a pool with " +
"mode 007 (no permissions for pool owner).");
} catch (AccessControlException e) {
GenericTestUtils.
assertExceptionContains("Permission denied while accessing pool", e);
}
// We expect the following to succeed, because DistributedFileSystem
// qualifies the path.
long relativeId = addAsUnprivileged(