Skip to content

Commit 5d6c0a9

Browse files
authored
HBASE-26994 MasterFileSystem create directory without permission check (#4391)
Signed-off-by: Viraj Jasani <[email protected]>
1 parent 0a12926 commit 5d6c0a9

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -331,16 +331,15 @@ private void checkSubDir(final Path p, final String dirPermsConfName) throws IOE
331331
throw new IOException("HBase directory '" + p + "' creation failure.");
332332
}
333333
}
334-
} else {
335-
if (isSecurityEnabled && !dirPerms.equals(fs.getFileStatus(p).getPermission())) {
336-
// check whether the permission match
337-
LOG.warn("Found HBase directory permissions NOT matching expected permissions for "
338-
+ p.toString() + " permissions=" + fs.getFileStatus(p).getPermission() + ", expecting "
339-
+ dirPerms + ". Automatically setting the permissions. "
340-
+ "You can change the permissions by setting \"" + dirPermsConfName
341-
+ "\" in hbase-site.xml " + "and restarting the master");
342-
fs.setPermission(p, dirPerms);
343-
}
334+
}
335+
if (isSecurityEnabled && !dirPerms.equals(fs.getFileStatus(p).getPermission())) {
336+
// check whether the permission match
337+
LOG.warn("Found HBase directory permissions NOT matching expected permissions for "
338+
+ p.toString() + " permissions=" + fs.getFileStatus(p).getPermission() + ", expecting "
339+
+ dirPerms + ". Automatically setting the permissions. "
340+
+ "You can change the permissions by setting \"" + dirPermsConfName
341+
+ "\" in hbase-site.xml " + "and restarting the master");
342+
fs.setPermission(p, dirPerms);
344343
}
345344
}
346345

@@ -355,9 +354,9 @@ private void checkStagingDir() throws IOException {
355354
if (!this.fs.mkdirs(p, HiddenDirPerms)) {
356355
throw new IOException("Failed to create staging directory " + p.toString());
357356
}
358-
} else {
359-
this.fs.setPermission(p, HiddenDirPerms);
360357
}
358+
this.fs.setPermission(p, HiddenDirPerms);
359+
361360
} catch (IOException e) {
362361
LOG.error("Failed to create or set permission on staging directory " + p.toString());
363362
throw new IOException(

0 commit comments

Comments
 (0)