Explorar el Código

HDFS-595. umask settings in configuration may now use octal or symbolic instead of decimal. Contributed by Jakob Homan.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/trunk@812605 13f79535-47bb-0310-9956-ffa450edef68
Suresh Srinivas hace 16 años
padre
commit
ff8df01a57

+ 3 - 0
CHANGES.txt

@@ -25,6 +25,9 @@ Trunk (unreleased changes)
     HDFS-578. Add support for new FileSystem method for clients to get server
     defaults. (Kan Zhang via suresh)
 
+    HDFS-595. umask settings in configuration may now use octal or symbolic 
+    instead of decimal. (Jakob Homan via suresh)
+
   IMPROVEMENTS
 
     HDFS-381. Remove blocks from DataNode maps when corresponding file

+ 2 - 2
src/test/hdfs/org/apache/hadoop/hdfs/TestDFSPermission.java

@@ -154,8 +154,8 @@ public class TestDFSPermission extends TestCase {
   /* create a file/directory with the given umask and permission */
   private void create(OpType op, Path name, short umask, 
       FsPermission permission) throws IOException {
-    // set umask in configuration
-    conf.setInt(FsPermission.UMASK_LABEL, umask);
+    // set umask in configuration, converting to padded octal
+    conf.set(FsPermission.UMASK_LABEL, String.format("%1$03o", umask));
 
     // create the file/directory
     switch (op) {

+ 2 - 2
src/test/hdfs/org/apache/hadoop/security/TestPermission.java

@@ -67,7 +67,7 @@ public class TestPermission extends TestCase {
   public void testCreate() throws Exception {
     Configuration conf = new Configuration();
     conf.setBoolean("dfs.permissions", true);
-    conf.setInt(FsPermission.UMASK_LABEL, 0);
+    conf.set(FsPermission.UMASK_LABEL, "000");
     MiniDFSCluster cluster = null;
     FileSystem fs = null;
 
@@ -95,7 +95,7 @@ public class TestPermission extends TestCase {
       checkPermission(fs, "/b1/b2", inheritPerm);
       checkPermission(fs, "/b1/b2/b3.txt", filePerm);
       
-      conf.setInt(FsPermission.UMASK_LABEL, 0022);
+      conf.set(FsPermission.UMASK_LABEL, "022");
       FsPermission permission = 
         FsPermission.createImmutable((short)0666);
       FileSystem.mkdirs(fs, new Path("/c1"), new FsPermission(permission));