hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aajis...@apache.org
Subject hadoop git commit: HDFS-9851. NameNode throws NPE when setPermission is called on a path that does not exist. Contributed by Brahma Reddy Battula.
Date Wed, 02 Mar 2016 05:46:33 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2.7 2f3ceb8c6 -> 8f2d0d4ce


HDFS-9851. NameNode throws NPE when setPermission is called on a path that does not exist.
Contributed by Brahma Reddy Battula.


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

Branch: refs/heads/branch-2.7
Commit: 8f2d0d4cea90d2b562633107783722b83cd2702c
Parents: 2f3ceb8
Author: Akira Ajisaka <aajisaka@apache.org>
Authored: Wed Mar 2 14:45:33 2016 +0900
Committer: Akira Ajisaka <aajisaka@apache.org>
Committed: Wed Mar 2 14:45:33 2016 +0900

----------------------------------------------------------------------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt           |  3 +++
 .../hadoop/hdfs/server/namenode/FSDirXAttrOp.java     |  3 ++-
 .../hadoop/hdfs/server/namenode/FSDirectory.java      |  6 +++++-
 .../org/apache/hadoop/security/TestPermission.java    | 14 ++++++++++++++
 4 files changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/8f2d0d4c/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 af9ad82..a878134 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -129,6 +129,9 @@ Release 2.7.3 - UNRELEASED
     HDFS-9766. TestDataNodeMetrics#testDataNodeTimeSpend fails intermittently.
     (Xiao Chen via aajisaka)
 
+    HDFS-9851. NameNode throws NPE when setPermission is called on a path that
+    does not exist. (Brahma Reddy Battula via aajisaka)
+
 Release 2.7.2 - 2016-01-25
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/8f2d0d4c/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java
index 1181118..4d97872 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java
@@ -32,6 +32,7 @@ import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos;
 import org.apache.hadoop.hdfs.protocolPB.PBHelper;
 import org.apache.hadoop.security.AccessControlException;
 
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.EnumSet;
 import java.util.List;
@@ -396,7 +397,7 @@ class FSDirXAttrOp {
   private static void checkXAttrChangeAccess(
       FSDirectory fsd, INodesInPath iip, XAttr xAttr,
       FSPermissionChecker pc)
-      throws AccessControlException {
+      throws AccessControlException, FileNotFoundException {
     if (fsd.isPermissionEnabled() && xAttr.getNameSpace() == XAttr.NameSpace
         .USER) {
       final INode inode = iip.getLastINode();

http://git-wip-us.apache.org/repos/asf/hadoop/blob/8f2d0d4c/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
index 58dc967..3b3f4eb 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
@@ -1673,7 +1673,11 @@ public class FSDirectory implements Closeable {
   }
 
   void checkOwner(FSPermissionChecker pc, INodesInPath iip)
-      throws AccessControlException {
+      throws AccessControlException, FileNotFoundException {
+    if (iip.getLastINode() == null) {
+      throw new FileNotFoundException(
+          "Directory/File does not exist " + iip.getPath());
+    }
     checkPermission(pc, iip, true, null, null, null, null);
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/8f2d0d4c/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestPermission.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestPermission.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestPermission.java
index 06150d7..d21ca22 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestPermission.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestPermission.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.security;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.util.Random;
@@ -50,6 +51,7 @@ public class TestPermission {
   final private static Path CHILD_DIR2 = new Path(ROOT_PATH, "child2");
   final private static Path CHILD_FILE1 = new Path(ROOT_PATH, "file1");
   final private static Path CHILD_FILE2 = new Path(ROOT_PATH, "file2");
+  final private static Path CHILD_FILE3 = new Path(ROOT_PATH, "file3");
 
   final private static int FILE_LEN = 100;
   final private static Random RAN = new Random();
@@ -257,6 +259,18 @@ public class TestPermission {
       final Path RENAME_PATH = new Path("/foo/bar");
       userfs.mkdirs(RENAME_PATH);
       assertTrue(canRename(userfs, RENAME_PATH, CHILD_DIR1));
+      // test permissions on files that do not exist
+      assertFalse(userfs.exists(CHILD_FILE3));
+      try {
+        userfs.setOwner(CHILD_FILE3, "foo", "bar");
+        fail("setOwner should fail for non-exist file");
+      } catch (java.io.FileNotFoundException ignored) {
+      }
+      try {
+        userfs.setPermission(CHILD_FILE3, new FsPermission((short) 0777));
+        fail("setPermission should fail for non-exist file");
+      } catch (java.io.FileNotFoundException ignored) {
+      }
     } finally {
       cluster.shutdown();
     }


Mime
View raw message