hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khorg...@apache.org
Subject svn commit: r1593462 - in /hive/branches/branch-0.13/ql/src: java/org/apache/hadoop/hive/ql/exec/Utilities.java test/org/apache/hadoop/hive/ql/exec/TestUtilities.java
Date Thu, 08 May 2014 23:39:06 GMT
Author: khorgath
Date: Thu May  8 23:39:06 2014
New Revision: 1593462

URL: http://svn.apache.org/r1593462
Log:
HIVE-7001 : fs.permissions.umask-mode is getting unset when Session is started (Thejas Nair,
reviewed by Ashutosh Chauhan, Vikram Dixit)

Modified:
    hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java
    hive/branches/branch-0.13/ql/src/test/org/apache/hadoop/hive/ql/exec/TestUtilities.java

Modified: hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java?rev=1593462&r1=1593461&r2=1593462&view=diff
==============================================================================
--- hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java (original)
+++ hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java Thu
May  8 23:39:06 2014
@@ -82,8 +82,6 @@ import java.util.zip.Deflater;
 import java.util.zip.DeflaterOutputStream;
 import java.util.zip.InflaterInputStream;
 
-import javax.security.auth.login.LoginException;
-
 import org.antlr.runtime.CommonToken;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang.StringUtils;
@@ -178,7 +176,6 @@ import org.apache.hadoop.mapred.RecordRe
 import org.apache.hadoop.mapred.Reporter;
 import org.apache.hadoop.mapred.SequenceFileInputFormat;
 import org.apache.hadoop.mapred.SequenceFileOutputFormat;
-import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.util.ReflectionUtils;
 import org.apache.hadoop.util.Shell;
 
@@ -3381,8 +3378,7 @@ public final class Utilities {
    */
   public static boolean createDirsWithPermission(Configuration conf, Path mkdir,
       FsPermission fsPermission) throws IOException {
-    // this umask is required because by default the hdfs mask is 022 resulting in
-    // all parents getting the fsPermission & !(022) permission instead of fsPermission
+
     boolean recursive = false;
     if (SessionState.get() != null) {
       recursive = SessionState.get().isHiveServerQuery() &&
@@ -3403,16 +3399,23 @@ public final class Utilities {
   public static boolean createDirsWithPermission(Configuration conf, Path mkdir,
       FsPermission fsPermission, boolean recursive) throws IOException {
     String origUmask = null;
+
     if (recursive) {
       origUmask = conf.get("fs.permissions.umask-mode");
+      // this umask is required because by default the hdfs mask is 022 resulting in
+      // all parents getting the fsPermission & !(022) permission instead of fsPermission
       conf.set("fs.permissions.umask-mode", "000");
     }
+
     FileSystem fs = mkdir.getFileSystem(conf);
     boolean retval = fs.mkdirs(mkdir, fsPermission);
-    if (origUmask != null) {
-      conf.set("fs.permissions.umask-mode", origUmask);
-    } else {
-      conf.unset("fs.permissions.umask-mode");
+
+    if (recursive) {
+      if (origUmask != null) {
+        conf.set("fs.permissions.umask-mode", origUmask);
+      } else {
+        conf.unset("fs.permissions.umask-mode");
+      }
     }
     return retval;
   }

Modified: hive/branches/branch-0.13/ql/src/test/org/apache/hadoop/hive/ql/exec/TestUtilities.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/ql/src/test/org/apache/hadoop/hive/ql/exec/TestUtilities.java?rev=1593462&r1=1593461&r2=1593462&view=diff
==============================================================================
--- hive/branches/branch-0.13/ql/src/test/org/apache/hadoop/hive/ql/exec/TestUtilities.java
(original)
+++ hive/branches/branch-0.13/ql/src/test/org/apache/hadoop/hive/ql/exec/TestUtilities.java
Thu May  8 23:39:06 2014
@@ -20,12 +20,15 @@ package org.apache.hadoop.hive.ql.exec;
 
 import static org.apache.hadoop.hive.ql.exec.Utilities.getFileExtension;
 
+import java.io.IOException;
 import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.List;
 
 import junit.framework.TestCase;
 
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
@@ -36,6 +39,7 @@ import org.apache.hadoop.hive.ql.session
 import org.apache.hadoop.hive.ql.udf.generic.GenericUDFFromUtcTimestamp;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.apache.hadoop.mapred.JobConf;
+import org.junit.Test;
 
 public class TestUtilities extends TestCase {
 
@@ -106,4 +110,23 @@ public class TestUtilities extends TestC
     }
   }
 
+  @Test
+  public void testFSUmaskReset() throws Exception {
+    // ensure that FS Umask is not reset (HIVE-7001)
+    checkFSUMaskReset(true);
+    checkFSUMaskReset(false);
+  }
+
+  private void checkFSUMaskReset(boolean recursiveArg) throws IllegalArgumentException, IOException
{
+    final String FS_MASK_PARAM = "fs.permissions.umask-mode";
+    final String FS_MASK_VAL = "055";
+    HiveConf conf = new HiveConf();
+    String dir = System.getProperty("test.tmp.dir") + "/testUtilitiesUMaskReset";
+    conf.set(FS_MASK_PARAM, FS_MASK_VAL);
+    Utilities.createDirsWithPermission(conf, new Path(dir), new FsPermission((short) 00777),
+        recursiveArg);
+    assertEquals(conf.get(FS_MASK_PARAM), FS_MASK_VAL);
+  }
+
+
 }



Mime
View raw message