HBASE-26994 MasterFileSystem create directory without permission check (#4391)

Signed-off-by: Viraj Jasani <vjasani@apache.org>
This commit is contained in:
skysiders 2022-05-09 04:26:53 +08:00 committed by Viraj Jasani
parent 6cd31edf5c
commit ad2180b75d
No known key found for this signature in database
GPG Key ID: 08E70F70AB71C5A1
1 changed files with 11 additions and 12 deletions

View File

@ -330,16 +330,15 @@ public class MasterFileSystem {
throw new IOException("HBase directory '" + p + "' creation failure."); throw new IOException("HBase directory '" + p + "' creation failure.");
} }
} }
} else { }
if (isSecurityEnabled && !dirPerms.equals(fs.getFileStatus(p).getPermission())) { if (isSecurityEnabled && !dirPerms.equals(fs.getFileStatus(p).getPermission())) {
// check whether the permission match // check whether the permission match
LOG.warn("Found HBase directory permissions NOT matching expected permissions for " LOG.warn("Found HBase directory permissions NOT matching expected permissions for "
+ p.toString() + " permissions=" + fs.getFileStatus(p).getPermission() + ", expecting " + p.toString() + " permissions=" + fs.getFileStatus(p).getPermission() + ", expecting "
+ dirPerms + ". Automatically setting the permissions. " + dirPerms + ". Automatically setting the permissions. "
+ "You can change the permissions by setting \"" + dirPermsConfName + "You can change the permissions by setting \"" + dirPermsConfName
+ "\" in hbase-site.xml " + "and restarting the master"); + "\" in hbase-site.xml " + "and restarting the master");
fs.setPermission(p, dirPerms); fs.setPermission(p, dirPerms);
}
} }
} }
@ -354,9 +353,9 @@ public class MasterFileSystem {
if (!this.fs.mkdirs(p, HiddenDirPerms)) { if (!this.fs.mkdirs(p, HiddenDirPerms)) {
throw new IOException("Failed to create staging directory " + p.toString()); throw new IOException("Failed to create staging directory " + p.toString());
} }
} else {
this.fs.setPermission(p, HiddenDirPerms);
} }
this.fs.setPermission(p, HiddenDirPerms);
} catch (IOException e) { } catch (IOException e) {
LOG.error("Failed to create or set permission on staging directory " + p.toString()); LOG.error("Failed to create or set permission on staging directory " + p.toString());
throw new IOException( throw new IOException(