You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by th...@apache.org on 2013/09/19 04:26:32 UTC

svn commit: r1524615 - in /hive/branches/branch-0.12: common/src/java/org/apache/hadoop/hive/conf/HiveConf.java ql/src/java/org/apache/hadoop/hive/ql/Context.java

Author: thejas
Date: Thu Sep 19 02:26:31 2013
New Revision: 1524615

URL: http://svn.apache.org/r1524615
Log:
HIVE-4487 - Hive does not set explicit permissions on hive.exec.scratchdir (Chaoyu Tang via Brock Noland)

Modified:
    hive/branches/branch-0.12/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
    hive/branches/branch-0.12/ql/src/java/org/apache/hadoop/hive/ql/Context.java

Modified: hive/branches/branch-0.12/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.12/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java?rev=1524615&r1=1524614&r2=1524615&view=diff
==============================================================================
--- hive/branches/branch-0.12/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (original)
+++ hive/branches/branch-0.12/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java Thu Sep 19 02:26:31 2013
@@ -179,6 +179,7 @@ public class HiveConf extends Configurat
     PLAN("hive.exec.plan", ""),
     SCRATCHDIR("hive.exec.scratchdir", "/tmp/hive-" + System.getProperty("user.name")),
     LOCALSCRATCHDIR("hive.exec.local.scratchdir", System.getProperty("java.io.tmpdir") + File.separator + System.getProperty("user.name")),
+    SCRATCHDIRPERMISSION("hive.scratch.dir.permission", "700"),
     SUBMITVIACHILD("hive.exec.submitviachild", false),
     SCRIPTERRORLIMIT("hive.exec.script.maxerrsize", 100000),
     ALLOWPARTIALCONSUMP("hive.exec.script.allow.partial.consumption", false),

Modified: hive/branches/branch-0.12/ql/src/java/org/apache/hadoop/hive/ql/Context.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.12/ql/src/java/org/apache/hadoop/hive/ql/Context.java?rev=1524615&r1=1524614&r2=1524615&view=diff
==============================================================================
--- hive/branches/branch-0.12/ql/src/java/org/apache/hadoop/hive/ql/Context.java (original)
+++ hive/branches/branch-0.12/ql/src/java/org/apache/hadoop/hive/ql/Context.java Thu Sep 19 02:26:31 2013
@@ -40,6 +40,7 @@ import org.apache.hadoop.fs.ContentSumma
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.hive.common.FileUtils;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.ql.exec.TaskRunner;
@@ -73,6 +74,9 @@ public class Context {
   // scratch directory to use for local file system tmp folders
   private final String localScratchDir;
 
+  // the permission to scratch directory (local and hdfs)
+  private final String scratchDirPermission;
+
   // Keeps track of scratch directories created for different scheme/authority
   private final Map<String, String> fsScratchDirs = new HashMap<String, String>();
 
@@ -118,6 +122,7 @@ public class Context {
                executionId);
     localScratchDir = new Path(HiveConf.getVar(conf, HiveConf.ConfVars.LOCALSCRATCHDIR),
             executionId).toUri().getPath();
+    scratchDirPermission= HiveConf.getVar(conf, HiveConf.ConfVars.SCRATCHDIRPERMISSION);
   }
 
 
@@ -200,6 +205,9 @@ public class Context {
           if (!fs.mkdirs(dirPath)) {
             throw new RuntimeException("Cannot make directory: "
                                        + dirPath.toString());
+          } else {
+            FsPermission fsPermission = new FsPermission(scratchDirPermission);
+            fs.setPermission(dirPath, fsPermission);
           }
           if (isHDFSCleanup) {
             fs.deleteOnExit(dirPath);