From 1c3ff0b7c892b9d70737c375fb6f4a6fc6dd6d81 Mon Sep 17 00:00:00 2001 From: Vinayakumar B Date: Fri, 17 Oct 2014 17:48:20 +0530 Subject: [PATCH] HDFS-7242. Code improvement for FSN#checkUnreadableBySuperuser. (Contributed by Yi Liu) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../apache/hadoop/hdfs/server/namenode/FSNamesystem.java | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 3573df538aa..4d2400dc10e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -399,6 +399,9 @@ Release 2.7.0 - UNRELEASED HDFS-7190. Bad use of Preconditions in startFileInternal(). (Dawson Choong via wheat9) + HDFS-7242. Code improvement for FSN#checkUnreadableBySuperuser. + (Yi Liu via vinayakumarb) + Release 2.6.0 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index ea99bfbc5ae..82d5c0e1527 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -6412,10 +6412,10 @@ public class FSNamesystem implements Namesystem, FSClusterStats, private void checkUnreadableBySuperuser(FSPermissionChecker pc, INode inode, int snapshotId) throws IOException { - for (XAttr xattr : dir.getXAttrs(inode, snapshotId)) { - if (XAttrHelper.getPrefixName(xattr). - equals(SECURITY_XATTR_UNREADABLE_BY_SUPERUSER)) { - if (pc.isSuperUser()) { + if (pc.isSuperUser()) { + for (XAttr xattr : dir.getXAttrs(inode, snapshotId)) { + if (XAttrHelper.getPrefixName(xattr). + equals(SECURITY_XATTR_UNREADABLE_BY_SUPERUSER)) { throw new AccessControlException("Access is denied for " + pc.getUser() + " since the superuser is not allowed to " + "perform this operation.");