From 8eab891bff402b10c0ec3a8de191aa05055a9668 Mon Sep 17 00:00:00 2001 From: Chris Nauroth Date: Mon, 17 Jun 2013 20:54:34 +0000 Subject: [PATCH] HDFS-4910. TestPermission failed in branch-2. Contributed by Chuan Liu. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1493932 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 + .../server/namenode/FSPermissionChecker.java | 56 +++++++++---------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index e1a814a0c6e..604e2ec7bf4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -386,6 +386,8 @@ Release 2.1.0-beta - UNRELEASED HDFS-4845. FSNamesystem.deleteInternal should acquire write-lock before changing the inode map. (Arpit Agarwal via szetszwo) + HDFS-4910. TestPermission failed in branch-2. (Chuan Liu via cnauroth) + BREAKDOWN OF HDFS-347 SUBTASKS AND RELATED JIRAS HDFS-4353. Encapsulate connections to peers in Peer and PeerServer classes. 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 33738152add..ffba6568dca 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 @@ -144,35 +144,35 @@ void checkPermission(String path, INodeDirectory root, boolean doCheckOwner, + ", resolveLink=" + resolveLink); } // check if (parentAccess != null) && file exists, then check sb - // Resolve symlinks, the check is performed on the link target. - final INodesInPath inodesInPath = root.getINodesInPath(path, true); - final Snapshot snapshot = inodesInPath.getPathSnapshot(); - final INode[] inodes = inodesInPath.getINodes(); - int ancestorIndex = inodes.length - 2; - for(; ancestorIndex >= 0 && inodes[ancestorIndex] == null; - ancestorIndex--); - checkTraverse(inodes, ancestorIndex, snapshot); + // If resolveLink, the check is performed on the link target. + final INodesInPath inodesInPath = root.getINodesInPath(path, resolveLink); + final Snapshot snapshot = inodesInPath.getPathSnapshot(); + final INode[] inodes = inodesInPath.getINodes(); + int ancestorIndex = inodes.length - 2; + for(; ancestorIndex >= 0 && inodes[ancestorIndex] == null; + ancestorIndex--); + checkTraverse(inodes, ancestorIndex, snapshot); - final INode last = inodes[inodes.length - 1]; - if (parentAccess != null && parentAccess.implies(FsAction.WRITE) - && inodes.length > 1 && last != null) { - checkStickyBit(inodes[inodes.length - 2], last, snapshot); - } - if (ancestorAccess != null && inodes.length > 1) { - check(inodes, ancestorIndex, snapshot, ancestorAccess); - } - if (parentAccess != null && inodes.length > 1) { - check(inodes, inodes.length - 2, snapshot, parentAccess); - } - if (access != null) { - check(last, snapshot, access); - } - if (subAccess != null) { - checkSubAccess(last, snapshot, subAccess); - } - if (doCheckOwner) { - checkOwner(last, snapshot); - } + final INode last = inodes[inodes.length - 1]; + if (parentAccess != null && parentAccess.implies(FsAction.WRITE) + && inodes.length > 1 && last != null) { + checkStickyBit(inodes[inodes.length - 2], last, snapshot); + } + if (ancestorAccess != null && inodes.length > 1) { + check(inodes, ancestorIndex, snapshot, ancestorAccess); + } + if (parentAccess != null && inodes.length > 1) { + check(inodes, inodes.length - 2, snapshot, parentAccess); + } + if (access != null) { + check(last, snapshot, access); + } + if (subAccess != null) { + checkSubAccess(last, snapshot, subAccess); + } + if (doCheckOwner) { + checkOwner(last, snapshot); + } } /** Guarded by {@link FSNamesystem#readLock()} */