hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From x...@apache.org
Subject hadoop git commit: HDFS-9019. Adding informative message to sticky bit permission denied exception. Contributed by Xiaoyu Yao.
Date Tue, 08 Sep 2015 17:00:58 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 a0594961d -> b2465690a


HDFS-9019. Adding informative message to sticky bit permission denied exception. Contributed
by Xiaoyu Yao.

(cherry picked from commit 970daaa5e44d3c09afd46d1c8e923a5096708c44)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/b2465690
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b2465690
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b2465690

Branch: refs/heads/branch-2
Commit: b2465690a15ee4257b381a8d186ffa6981ddc537
Parents: a059496
Author: Xiaoyu Yao <xyao@apache.org>
Authored: Tue Sep 8 09:57:36 2015 -0700
Committer: Xiaoyu Yao <xyao@apache.org>
Committed: Tue Sep 8 09:58:29 2015 -0700

----------------------------------------------------------------------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt         |  3 +++
 .../hdfs/server/namenode/FSPermissionChecker.java   | 16 +++++++++++-----
 .../apache/hadoop/fs/permission/TestStickyBit.java  |  3 +++
 3 files changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/b2465690/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index befb5d4..5114e8a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -552,6 +552,9 @@ Release 2.8.0 - UNRELEASED
     HDFS-8984. Move replication queues related methods in FSNamesystem to
     BlockManager. (wheat9)
 
+    HDFS-9019. Adding informative message to sticky bit permission denied
+    exception. (xyao)
+
   OPTIMIZATIONS
 
     HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b2465690/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSPermissionChecker.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSPermissionChecker.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSPermissionChecker.java
index e6570f5..041ce0b 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSPermissionChecker.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSPermissionChecker.java
@@ -207,7 +207,7 @@ class FSPermissionChecker implements AccessControlEnforcer {
     final INodeAttributes last = inodeAttrs[inodeAttrs.length - 1];
     if (parentAccess != null && parentAccess.implies(FsAction.WRITE)
         && inodeAttrs.length > 1 && last != null) {
-      checkStickyBit(inodeAttrs[inodeAttrs.length - 2], last);
+      checkStickyBit(inodeAttrs[inodeAttrs.length - 2], last, path);
     }
     if (ancestorAccess != null && inodeAttrs.length > 1) {
       check(inodeAttrs, path, ancestorIndex, ancestorAccess);
@@ -405,8 +405,8 @@ class FSPermissionChecker implements AccessControlEnforcer {
   }
 
   /** Guarded by {@link FSNamesystem#readLock()} */
-  private void checkStickyBit(INodeAttributes parent, INodeAttributes inode
-      ) throws AccessControlException {
+  private void checkStickyBit(INodeAttributes parent, INodeAttributes inode,
+      String path) throws AccessControlException {
     if (!parent.getFsPermission().getStickyBit()) {
       return;
     }
@@ -421,8 +421,14 @@ class FSPermissionChecker implements AccessControlEnforcer {
       return;
     }
 
-    throw new AccessControlException("Permission denied by sticky bit setting:" +
-      " user=" + getUser() + ", inode=" + inode);
+    throw new AccessControlException(String.format(
+        "Permission denied by sticky bit: user=%s, path=\"%s\":%s:%s:%s%s, " +
+        "parent=\"%s\":%s:%s:%s%s", user,
+        path, inode.getUserName(), inode.getGroupName(),
+        inode.isDirectory() ? "d" : "-", inode.getFsPermission().toString(),
+        path.substring(0, path.length() - inode.toString().length() - 1 ),
+        parent.getUserName(), parent.getGroupName(),
+        parent.isDirectory() ? "d" : "-", parent.getFsPermission().toString()));
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b2465690/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/permission/TestStickyBit.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/permission/TestStickyBit.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/permission/TestStickyBit.java
index 9d0e31b..d5cece4 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/permission/TestStickyBit.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/permission/TestStickyBit.java
@@ -140,6 +140,9 @@ public class TestStickyBit {
     } catch (IOException ioe) {
       assertTrue(ioe instanceof AccessControlException);
       assertTrue(ioe.getMessage().contains("sticky bit"));
+      assertTrue(ioe.getMessage().contains("user="+user2.getUserName()));
+      assertTrue(ioe.getMessage().contains("path=\"" + file + "\""));
+      assertTrue(ioe.getMessage().contains("parent=\"" + file.getParent() + "\""));
     }
   }
 


Mime
View raw message