hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject hadoop git commit: Revert "HADOOP-13073 RawLocalFileSystem does not react on changing umask. Contributed by Andras Bokor"
Date Thu, 14 Jul 2016 09:30:49 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 45af585e7 -> be26c1b9b


Revert "HADOOP-13073 RawLocalFileSystem does not react on changing umask. Contributed by Andras
Bokor"

This reverts commit 45af585e7ad23e7d5a5bc4dade00723d315ef6b2.


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

Branch: refs/heads/trunk
Commit: be26c1b9b0ae8fc138489498f40301cf3ee303a0
Parents: 45af585
Author: Steve Loughran <stevel@apache.org>
Authored: Thu Jul 14 10:30:36 2016 +0100
Committer: Steve Loughran <stevel@apache.org>
Committed: Thu Jul 14 10:30:36 2016 +0100

----------------------------------------------------------------------
 .../apache/hadoop/fs/RawLocalFileSystem.java    |  7 ++-
 .../fs/TestLocalFileSystemPermission.java       | 56 +-------------------
 2 files changed, 7 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/be26c1b9/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java
index 0fcddcf..cc41f4a 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java
@@ -64,6 +64,8 @@ public class RawLocalFileSystem extends FileSystem {
   // Temporary workaround for HADOOP-9652.
   private static boolean useDeprecatedFileStatus = true;
 
+  private FsPermission umask;
+
   @VisibleForTesting
   public static void useStatIfAvailable() {
     useDeprecatedFileStatus = !Stat.isAvailable();
@@ -97,6 +99,7 @@ public class RawLocalFileSystem extends FileSystem {
   public void initialize(URI uri, Configuration conf) throws IOException {
     super.initialize(uri, conf);
     setConf(conf);
+    umask = FsPermission.getUMask(conf);
   }
   
   /*******************************************************
@@ -230,7 +233,7 @@ public class RawLocalFileSystem extends FileSystem {
       if (permission == null) {
         this.fos = new FileOutputStream(file, append);
       } else {
-        permission = permission.applyUMask(FsPermission.getUMask(getConf()));
+        permission = permission.applyUMask(umask);
         if (Shell.WINDOWS && NativeIO.isAvailable()) {
           this.fos = NativeIO.Windows.createFileOutputStreamWithMode(file,
               append, permission.toShort());
@@ -507,7 +510,7 @@ public class RawLocalFileSystem extends FileSystem {
     if (permission == null) {
       permission = FsPermission.getDirDefault();
     }
-    permission = permission.applyUMask(FsPermission.getUMask(getConf()));
+    permission = permission.applyUMask(umask);
     if (Shell.WINDOWS && NativeIO.isAvailable()) {
       try {
         NativeIO.Windows.createDirectoryWithMode(p2f, permission.toShort());

http://git-wip-us.apache.org/repos/asf/hadoop/blob/be26c1b9/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystemPermission.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystemPermission.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystemPermission.java
index 7252ab9..e37de19 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystemPermission.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystemPermission.java
@@ -29,10 +29,6 @@ import java.util.*;
 
 import junit.framework.*;
 
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.junit.Assert.assertThat;
-
 /**
  * This class tests the local file system via the FileSystem abstraction.
  */
@@ -71,9 +67,9 @@ public class TestLocalFileSystemPermission extends TestCase {
       System.out.println("Cannot run test for Windows");
       return;
     }
-    LocalFileSystem localfs = FileSystem.getLocal(new Configuration());
-    Configuration conf = localfs.getConf();
+    Configuration conf = new Configuration();
     conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "044");
+    LocalFileSystem localfs = FileSystem.getLocal(conf);
     Path dir = new Path(TEST_PATH_PREFIX + "dir");
     localfs.mkdirs(dir);
     try {
@@ -241,54 +237,6 @@ public class TestLocalFileSystemPermission extends TestCase {
     finally {cleanup(localfs, f);}
   }
 
-  /**
-   * Steps:
-   * 1. Create a directory with default permissions: 777 with umask 022
-   * 2. Check the directory has good permissions: 755
-   * 3. Set the umask to 062.
-   * 4. Create a new directory with default permissions.
-   * 5. For this directory we expect 715 as permission not 755
-   * @throws Exception we can throw away all the exception.
-   */
-  public void testSetUmaskInRealTime() throws Exception {
-    if (Path.WINDOWS) {
-      System.out.println("Cannot run test for Windows");
-      return;
-    }
-
-    LocalFileSystem localfs = FileSystem.getLocal(new Configuration());
-    Configuration conf = localfs.getConf();
-    conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "022");
-    System.out.println(
-        conf.get(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY));
-    Path dir = new Path(TEST_PATH_PREFIX + "dir");
-    Path dir2 = new Path(TEST_PATH_PREFIX + "dir2");
-    try {
-      assertTrue(localfs.mkdirs(dir));
-      FsPermission initialPermission = getPermission(localfs, dir);
-      assertEquals(
-          "With umask 022 permission should be 755 since the default " +
-              "permission is 777", new FsPermission("755"), initialPermission);
-
-      // Modify umask and create a new directory
-      // and check if new umask is applied
-      conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "062");
-      assertTrue(localfs.mkdirs(dir2));
-      FsPermission finalPermission = localfs.getFileStatus(dir2)
-          .getPermission();
-      assertThat("With umask 062 permission should not be 755 since the " +
-          "default permission is 777", new FsPermission("755"),
-          is(not(finalPermission)));
-      assertEquals(
-          "With umask 062 we expect 715 since the default permission is 777",
-          new FsPermission("715"), finalPermission);
-    } finally {
-      conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "022");
-      cleanup(localfs, dir);
-      cleanup(localfs, dir2);
-    }
-  }
-
   static List<String> getGroups() throws IOException {
     List<String> a = new ArrayList<String>();
     String s = Shell.execCommand(Shell.getGroupsCommand());


---------------------------------------------------------------------
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