hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjs...@apache.org
Subject [17/38] hadoop git commit: HADOOP-10945. 4-digit octal umask permissions throws a parse error. Contributed by Chang Li
Date Tue, 04 Aug 2015 00:12:58 GMT
HADOOP-10945. 4-digit octal umask permissions throws a parse error. Contributed by Chang Li


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

Branch: refs/heads/YARN-2928
Commit: 2c34b66d652c09c06b005f22a1f8b3be0ca9a296
Parents: c7a0f58
Author: Jason Lowe <jlowe@apache.org>
Authored: Wed Jul 29 15:25:10 2015 +0000
Committer: Zhijie Shen <zjshen@apache.org>
Committed: Mon Aug 3 17:02:09 2015 -0700

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt |  3 +++
 .../hadoop/fs/permission/UmaskParser.java       |  2 +-
 .../apache/hadoop/security/TestPermission.java  | 26 ++++++++++++++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c34b66d/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 84e7076..098194c 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -1023,6 +1023,9 @@ Release 2.8.0 - UNRELEASED
     HADOOP-12175. FsShell must load SpanReceierHost to support tracing
     (Masatake Iwasaki via Colin P. McCabe)
 
+    HADOOP-10945. 4-digit octal umask permissions throws a parse error (Chang
+    Li via jlowe)
+
 Release 2.7.2 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c34b66d/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/UmaskParser.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/UmaskParser.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/UmaskParser.java
index 79956c5..0cf26c5 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/UmaskParser.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/UmaskParser.java
@@ -33,7 +33,7 @@ import org.apache.hadoop.classification.InterfaceStability;
 @InterfaceStability.Unstable
 class UmaskParser extends PermissionParser {
   private static Pattern chmodOctalPattern =
-    Pattern.compile("^\\s*[+]?()([0-7]{3})\\s*$"); // no leading 1 for sticky bit
+    Pattern.compile("^\\s*[+]?(0*)([0-7]{3})\\s*$"); // no leading 1 for sticky bit
   private static Pattern umaskSymbolicPattern =    /* not allow X or t */
     Pattern.compile("\\G\\s*([ugoa]*)([+=-]+)([rwx]*)([,\\s]*)\\s*");
   final short umaskMode;

http://git-wip-us.apache.org/repos/asf/hadoop/blob/2c34b66d/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 036aaae..425c82e 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;
@@ -100,6 +101,31 @@ public class TestPermission {
     conf = new Configuration();
     conf.set(FsPermission.UMASK_LABEL, "022");
     assertEquals(18, FsPermission.getUMask(conf).toShort());
+
+    // Test 5 - equivalent valid umask
+    conf = new Configuration();
+    conf.set(FsPermission.UMASK_LABEL, "0022");
+    assertEquals(18, FsPermission.getUMask(conf).toShort());
+
+    // Test 6 - invalid umask
+    conf = new Configuration();
+    conf.set(FsPermission.UMASK_LABEL, "1222");
+    try {
+      FsPermission.getUMask(conf);
+      fail("expect IllegalArgumentException happen");
+    } catch (IllegalArgumentException e) {
+     //pass, exception successfully trigger
+    }
+
+    // Test 7 - invalid umask
+    conf = new Configuration();
+    conf.set(FsPermission.UMASK_LABEL, "01222");
+    try {
+      FsPermission.getUMask(conf);
+      fail("expect IllegalArgumentException happen");
+    } catch (IllegalArgumentException e) {
+     //pass, exception successfully trigger
+    }
   }
 
   @Test


Mime
View raw message