hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cnaur...@apache.org
Subject hadoop git commit: HDFS-9852. hdfs dfs -setfacl error message is misleading (Wei-Chiu Chuang via aw)
Date Wed, 20 Jul 2016 18:34:35 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2.8 8c5101ea6 -> 35885e954


HDFS-9852. hdfs dfs -setfacl error message is misleading (Wei-Chiu Chuang via aw)

(cherry picked from commit b3649adf6a1b2dc47566b4b0d652bd4e0a6a8056)
(cherry picked from commit 84c785036f5014d4e6066b344c2c235d1ea5028f)


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

Branch: refs/heads/branch-2.8
Commit: 35885e95406436850413f4f7d81145827e6922d4
Parents: 8c5101e
Author: Allen Wittenauer <aw@apache.org>
Authored: Tue Jun 28 20:47:05 2016 -0700
Committer: Chris Nauroth <cnauroth@apache.org>
Committed: Wed Jul 20 11:30:52 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/hadoop/fs/shell/AclCommands.java  | 14 +++++++++++++-
 .../org/apache/hadoop/fs/shell/TestAclCommands.java   |  4 ++++
 2 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/35885e95/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/AclCommands.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/AclCommands.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/AclCommands.java
index 42829bf..51a2255 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/AclCommands.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/AclCommands.java
@@ -192,6 +192,9 @@ class AclCommands extends FsCommand {
       boolean oneRemoveOption = cf.getOpt("b") || cf.getOpt("k");
       boolean oneModifyOption = cf.getOpt("m") || cf.getOpt("x");
       boolean setOption = cf.getOpt("-set");
+      boolean hasExpectedOptions = cf.getOpt("b") || cf.getOpt("k") ||
+          cf.getOpt("m") || cf.getOpt("x") || cf.getOpt("-set");
+
       if ((bothRemoveOptions || bothModifyOptions)
           || (oneRemoveOption && oneModifyOption)
           || (setOption && (oneRemoveOption || oneModifyOption))) {
@@ -201,8 +204,13 @@ class AclCommands extends FsCommand {
 
       // Only -m, -x and --set expects <acl_spec>
       if (oneModifyOption || setOption) {
+        if (args.isEmpty()) {
+          throw new HadoopIllegalArgumentException(
+              "Missing arguments: <acl_spec> <path>");
+        }
         if (args.size() < 2) {
-          throw new HadoopIllegalArgumentException("<acl_spec> is missing");
+          throw new HadoopIllegalArgumentException(
+              "Missing either <acl_spec> or <path>");
         }
         aclEntries = AclEntry.parseAclSpec(args.removeFirst(), !cf.getOpt("x"));
       }
@@ -214,6 +222,10 @@ class AclCommands extends FsCommand {
         throw new HadoopIllegalArgumentException("Too many arguments");
       }
 
+      if (!hasExpectedOptions) {
+        throw new HadoopIllegalArgumentException(
+            "Expected one of -b, -k, -m, -x or --set options");
+      }
       // In recursive mode, save a separate list of just the access ACL entries.
       // Only directories may have a default ACL.  When a recursive operation
       // encounters a file under the specified path, it must pass only the

http://git-wip-us.apache.org/repos/asf/hadoop/blob/35885e95/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestAclCommands.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestAclCommands.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestAclCommands.java
index cb6f560..3b9d397 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestAclCommands.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestAclCommands.java
@@ -64,6 +64,10 @@ public class TestAclCommands {
 
   @Test
   public void testSetfaclValidations() throws Exception {
+    assertFalse("setfacl should fail without options",
+        0 == runCommand(new String[] { "-setfacl", "/" }));
+    assertFalse("setfacl should fail without options -b, -k, -m, -x or --set",
+        0 == runCommand(new String[] { "-setfacl", "-R", "/" }));
     assertFalse("setfacl should fail without path",
         0 == runCommand(new String[] { "-setfacl" }));
     assertFalse("setfacl should fail without aclSpec",


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message