HBASE-18512, Region Server will abort with IllegalStateException if HDFS umask has limited scope
Signed-off-by: tedyu <[email protected]> (cherry picked from commit 12201249383bb7dab56ff857fba074c6ed311990) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/22d2c72c Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/22d2c72c Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/22d2c72c Branch: refs/heads/branch-1.2 Commit: 22d2c72c0bc2c8566550627924aa6a68e890de1d Parents: 0466474 Author: Pankaj Kumar <[email protected]> Authored: Mon Aug 14 21:27:45 2017 +0800 Committer: Sean Busbey <[email protected]> Committed: Fri Aug 17 23:21:22 2018 -0500 ---------------------------------------------------------------------- .../security/access/SecureBulkLoadEndpoint.java | 21 +++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/22d2c72c/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java index fae1e2d..48b4f7c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java @@ -148,15 +148,26 @@ public class SecureBulkLoadEndpoint extends SecureBulkLoadService fs = baseStagingDir.getFileSystem(conf); if (!fs.exists(baseStagingDir)) { fs.mkdirs(baseStagingDir, PERM_HIDDEN); - } else { - fs.setPermission(baseStagingDir, PERM_HIDDEN); } - //no sticky bit in hadoop-1.0, making directory nonempty so it never gets erased - fs.mkdirs(new Path(baseStagingDir,"DONOTERASE"), PERM_HIDDEN); FileStatus status = fs.getFileStatus(baseStagingDir); - if(status == null) { + if (status == null) { throw new IllegalStateException("Failed to create staging directory"); } + + // If HDFS UMASK value has limited scope then staging directory permission may not be 711 + // after creation, so we should set staging directory permission explicitly. + if (!status.getPermission().equals(PERM_HIDDEN)) { + fs.setPermission(baseStagingDir, PERM_HIDDEN); + status = fs.getFileStatus(baseStagingDir); + } + + // no sticky bit in hadoop-1.0, making directory nonempty so it never gets erased + Path doNotEraseDir = new Path(baseStagingDir, "DONOTERASE"); + if (!fs.exists(doNotEraseDir)) { + fs.mkdirs(doNotEraseDir, PERM_HIDDEN); + fs.setPermission(doNotEraseDir, PERM_HIDDEN); + } + String scheme = fs.getScheme().toLowerCase(); if (!fsSet.contains(scheme) && !status.getPermission().equals(PERM_HIDDEN)) { throw new IllegalStateException(
