diff --git a/ql/src/java/org/apache/hadoop/hive/ql/Context.java b/ql/src/java/org/apache/hadoop/hive/ql/Context.java index f7c7c67a6141..c954aa96ae46 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/Context.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/Context.java @@ -558,6 +558,11 @@ private Path getScratchDir(String scheme, String authority, throw new RuntimeException("Cannot make directory: " + dirPath.toString()); } + if (!fs.getFileStatus(dirPath).getPermission().equals(fsPermission)) { + LOG.warn("Directory {} created with unexpected permissions : {}.Change permission to : ", + dirPath, fs.getFileStatus(dirPath).getPermission(), fsPermission); + fs.setPermission(dirPath, fsPermission); + } if (isHDFSCleanup) { fs.deleteOnExit(dirPath); } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/cache/results/QueryResultsCache.java b/ql/src/java/org/apache/hadoop/hive/ql/cache/results/QueryResultsCache.java index 4b833b730cf9..949bcc880d92 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/cache/results/QueryResultsCache.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/cache/results/QueryResultsCache.java @@ -371,6 +371,11 @@ private QueryResultsCache(HiveConf configuration) throws IOException { FsPermission fsPermission = new FsPermission("700"); fs.mkdirs(cacheDirPath, fsPermission); + if (!fs.getFileStatus(cacheDirPath).getPermission().equals(fsPermission)) { + LOG.warn("Directory {} created with unexpected permissions : {}.Change permission to : ", + cacheDirPath, fs.getFileStatus(cacheDirPath).getPermission(), fsPermission); + fs.setPermission(cacheDirPath, fsPermission); + } // Create non-existent path for 0-row results zeroRowsPath = new Path(cacheDirPath, "dummy_zero_rows"); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionState.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionState.java index ba8d53fbfb25..60e8e9b36a09 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionState.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionState.java @@ -796,6 +796,11 @@ private Path createTezDir(String sessionId, String suffix) throws IOException { FileSystem fs = tezDir.getFileSystem(conf); FsPermission fsPermission = new FsPermission(HiveConf.getVar(conf, HiveConf.ConfVars.SCRATCHDIRPERMISSION)); fs.mkdirs(tezDir, fsPermission); + if(!fs.getFileStatus(tezDir).getPermission().equals(fsPermission)){ + LOG.warn("Directory {} created with unexpected permissions : {}.Change permission to : ", + tezDir, fs.getFileStatus(tezDir).getPermission(), fsPermission); + fs.setPermission(tezDir, fsPermission); + } // Make sure the path is normalized (we expect validation to pass since we just created it). tezDir = DagUtils.validateTargetDir(tezDir, conf).getPath();