|
@@ -1869,11 +1869,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "setPermission";
|
|
|
FileStatus auditStat;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot set permission for " + src);
|
|
|
- auditStat = FSDirAttrOp.setPermission(dir, src, permission);
|
|
|
+ auditStat = FSDirAttrOp.setPermission(dir, pc, src, permission);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -1893,11 +1894,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "setOwner";
|
|
|
FileStatus auditStat;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot set owner for " + src);
|
|
|
- auditStat = FSDirAttrOp.setOwner(dir, src, username, group);
|
|
|
+ auditStat = FSDirAttrOp.setOwner(dir, pc, src, username, group);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -1917,7 +1919,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "open";
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
GetBlockLocationsResult res = null;
|
|
|
- FSPermissionChecker pc = getPermissionChecker();
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
@@ -2030,11 +2032,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "concat";
|
|
|
FileStatus stat = null;
|
|
|
boolean success = false;
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot concat " + target);
|
|
|
- stat = FSDirConcatOp.concat(dir, target, srcs, logRetryCache);
|
|
|
+ stat = FSDirConcatOp.concat(dir, pc, target, srcs, logRetryCache);
|
|
|
success = true;
|
|
|
} catch (AccessControlException ace) {
|
|
|
logAuditEvent(success, operationName, Arrays.toString(srcs),
|
|
@@ -2058,11 +2061,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "setTimes";
|
|
|
FileStatus auditStat;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot set times " + src);
|
|
|
- auditStat = FSDirAttrOp.setTimes(dir, src, mtime, atime);
|
|
|
+ auditStat = FSDirAttrOp.setTimes(dir, pc, src, mtime, atime);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -2096,8 +2100,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
throw new HadoopIllegalArgumentException(
|
|
|
"Cannot truncate to a negative file size: " + newLength + ".");
|
|
|
}
|
|
|
- final FSPermissionChecker pc = getPermissionChecker();
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
BlocksMapUpdateInfo toRemoveBlocks = new BlocksMapUpdateInfo();
|
|
|
try {
|
|
@@ -2166,11 +2170,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "setReplication";
|
|
|
boolean success = false;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot set replication for " + src);
|
|
|
- success = FSDirAttrOp.setReplication(dir, blockManager, src, replication);
|
|
|
+ success = FSDirAttrOp.setReplication(dir, pc, blockManager, src,
|
|
|
+ replication);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -2194,11 +2200,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "setStoragePolicy";
|
|
|
FileStatus auditStat;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot set storage policy for " + src);
|
|
|
- auditStat = FSDirAttrOp.setStoragePolicy(dir, blockManager, src,
|
|
|
+ auditStat = FSDirAttrOp.setStoragePolicy(dir, pc, blockManager, src,
|
|
|
policyName);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
@@ -2219,11 +2226,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "unsetStoragePolicy";
|
|
|
FileStatus auditStat;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot unset storage policy for " + src);
|
|
|
- auditStat = FSDirAttrOp.unsetStoragePolicy(dir, blockManager, src);
|
|
|
+ auditStat = FSDirAttrOp.unsetStoragePolicy(dir, pc, blockManager, src);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -2242,10 +2250,11 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
*/
|
|
|
BlockStoragePolicy getStoragePolicy(String src) throws IOException {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
- return FSDirAttrOp.getStoragePolicy(dir, blockManager, src);
|
|
|
+ return FSDirAttrOp.getStoragePolicy(dir, pc, blockManager, src);
|
|
|
} finally {
|
|
|
readUnlock("getStoragePolicy");
|
|
|
}
|
|
@@ -2267,10 +2276,11 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
|
|
|
long getPreferredBlockSize(String src) throws IOException {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
- return FSDirAttrOp.getPreferredBlockSize(dir, src);
|
|
|
+ return FSDirAttrOp.getPreferredBlockSize(dir, pc, src);
|
|
|
} finally {
|
|
|
readUnlock("getPreferredBlockSize");
|
|
|
}
|
|
@@ -2374,13 +2384,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
"ecPolicyName are exclusive parameters. Set both is not allowed!");
|
|
|
}
|
|
|
|
|
|
- FSPermissionChecker pc = getPermissionChecker();
|
|
|
INodesInPath iip = null;
|
|
|
boolean skipSync = true; // until we do something that might create edits
|
|
|
HdfsFileStatus stat = null;
|
|
|
BlocksMapUpdateInfo toRemoveBlocks = null;
|
|
|
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
@@ -2461,8 +2471,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
boolean recoverLease(String src, String holder, String clientMachine)
|
|
|
throws IOException {
|
|
|
boolean skipSync = false;
|
|
|
- FSPermissionChecker pc = getPermissionChecker();
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
@@ -2601,8 +2611,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
try {
|
|
|
boolean skipSync = false;
|
|
|
LastBlockWithStatus lbs = null;
|
|
|
- final FSPermissionChecker pc = getPermissionChecker();
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
@@ -2657,8 +2667,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
|
|
|
LocatedBlock[] onRetryBlock = new LocatedBlock[1];
|
|
|
FSDirWriteFileOp.ValidateAddBlockResult r;
|
|
|
- FSPermissionChecker pc = getPermissionChecker();
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
@@ -2708,7 +2718,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final List<DatanodeStorageInfo> chosen;
|
|
|
final BlockType blockType;
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
- FSPermissionChecker pc = getPermissionChecker();
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
@@ -2756,7 +2766,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
NameNode.stateChangeLog.debug(
|
|
|
"BLOCK* NameSystem.abandonBlock: {} of file {}", b, src);
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
- FSPermissionChecker pc = getPermissionChecker();
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
@@ -2821,7 +2831,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
throws IOException {
|
|
|
boolean success = false;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
- FSPermissionChecker pc = getPermissionChecker();
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
@@ -2899,11 +2909,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
throws IOException {
|
|
|
final String operationName = "rename";
|
|
|
FSDirRenameOp.RenameResult ret = null;
|
|
|
+ checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot rename " + src);
|
|
|
- ret = FSDirRenameOp.renameToInt(dir, src, dst, logRetryCache);
|
|
|
+ ret = FSDirRenameOp.renameToInt(dir, pc, src, dst, logRetryCache);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src, dst, null);
|
|
|
throw e;
|
|
@@ -2923,11 +2935,14 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
throws IOException {
|
|
|
final String operationName = "rename";
|
|
|
FSDirRenameOp.RenameResult res = null;
|
|
|
+ checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot rename " + src);
|
|
|
- res = FSDirRenameOp.renameToInt(dir, src, dst, logRetryCache, options);
|
|
|
+ res = FSDirRenameOp.renameToInt(dir, pc, src, dst, logRetryCache,
|
|
|
+ options);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName + " (options=" +
|
|
|
Arrays.toString(options) + ")", src, dst, null);
|
|
@@ -2958,13 +2973,15 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
throws IOException {
|
|
|
final String operationName = "delete";
|
|
|
BlocksMapUpdateInfo toRemovedBlocks = null;
|
|
|
+ checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
boolean ret = false;
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot delete " + src);
|
|
|
toRemovedBlocks = FSDirDeleteOp.delete(
|
|
|
- this, src, recursive, logRetryCache);
|
|
|
+ this, pc, src, recursive, logRetryCache);
|
|
|
ret = toRemovedBlocks != null;
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
@@ -3063,11 +3080,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = needBlockToken ? "open" : "getfileinfo";
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
HdfsFileStatus stat = null;
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
stat = FSDirStatAndListingOp.getFileInfo(
|
|
|
- dir, src, resolveLink, needLocation, needBlockToken);
|
|
|
+ dir, pc, src, resolveLink, needLocation, needBlockToken);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -3084,10 +3102,11 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
boolean isFileClosed(final String src) throws IOException {
|
|
|
final String operationName = "isFileClosed";
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
- return FSDirStatAndListingOp.isFileClosed(dir, src);
|
|
|
+ return FSDirStatAndListingOp.isFileClosed(dir, pc, src);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -3104,11 +3123,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "mkdirs";
|
|
|
FileStatus auditStat = null;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot create directory " + src);
|
|
|
- auditStat = FSDirMkdirOp.mkdirs(this, src, permissions, createParent);
|
|
|
+ auditStat = FSDirMkdirOp.mkdirs(this, pc, src, permissions,
|
|
|
+ createParent);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -3137,12 +3158,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
ContentSummary getContentSummary(final String src) throws IOException {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
final String operationName = "contentSummary";
|
|
|
- readLock();
|
|
|
boolean success = true;
|
|
|
ContentSummary cs;
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
+ readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
- cs = FSDirStatAndListingOp.getContentSummary(dir, src);
|
|
|
+ cs = FSDirStatAndListingOp.getContentSummary(dir, pc, src);
|
|
|
} catch (AccessControlException ace) {
|
|
|
success = false;
|
|
|
logAuditEvent(success, operationName, src);
|
|
@@ -3172,11 +3194,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
final String operationName = "quotaUsage";
|
|
|
QuotaUsage quotaUsage;
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
readLock();
|
|
|
boolean success = true;
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
- quotaUsage = FSDirStatAndListingOp.getQuotaUsage(dir, src);
|
|
|
+ quotaUsage = FSDirStatAndListingOp.getQuotaUsage(dir, pc, src);
|
|
|
} catch (AccessControlException ace) {
|
|
|
success = false;
|
|
|
logAuditEvent(success, operationName, src);
|
|
@@ -3202,12 +3225,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
}
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
final String operationName = getQuotaCommand(nsQuota, ssQuota);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
boolean success = false;
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot set quota on " + src);
|
|
|
- FSDirAttrOp.setQuota(dir, src, nsQuota, ssQuota, type);
|
|
|
+ FSDirAttrOp.setQuota(dir, pc, src, nsQuota, ssQuota, type);
|
|
|
success = true;
|
|
|
} catch (AccessControlException ace) {
|
|
|
logAuditEvent(success, operationName, src);
|
|
@@ -3234,8 +3258,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
throws IOException {
|
|
|
NameNode.stateChangeLog.info("BLOCK* fsync: " + src + " for " + clientName);
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
-
|
|
|
- FSPermissionChecker pc = getPermissionChecker();
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
@@ -3739,10 +3762,11 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
final String operationName = "listStatus";
|
|
|
DirectoryListing dl = null;
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(NameNode.OperationCategory.READ);
|
|
|
- dl = getListingInt(dir, src, startAfter, needLocation);
|
|
|
+ dl = getListingInt(dir, pc, src, startAfter, needLocation);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -4678,6 +4702,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ void checkSuperuserPrivilege(FSPermissionChecker pc)
|
|
|
+ throws AccessControlException {
|
|
|
+ if (isPermissionEnabled) {
|
|
|
+ pc.checkSuperuserPrivilege();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Check to see if we have exceeded the limit on the number
|
|
|
* of inodes.
|
|
@@ -6365,14 +6396,16 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
*/
|
|
|
String createSnapshot(String snapshotRoot, String snapshotName,
|
|
|
boolean logRetryCache) throws IOException {
|
|
|
+ checkOperation(OperationCategory.WRITE);
|
|
|
final String operationName = "createSnapshot";
|
|
|
String snapshotPath = null;
|
|
|
boolean success = false;
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot create snapshot for " + snapshotRoot);
|
|
|
- snapshotPath = FSDirSnapshotOp.createSnapshot(dir,
|
|
|
+ snapshotPath = FSDirSnapshotOp.createSnapshot(dir, pc,
|
|
|
snapshotManager, snapshotRoot, snapshotName, logRetryCache);
|
|
|
success = true;
|
|
|
} catch (AccessControlException ace) {
|
|
@@ -6399,15 +6432,17 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
void renameSnapshot(
|
|
|
String path, String snapshotOldName, String snapshotNewName,
|
|
|
boolean logRetryCache) throws IOException {
|
|
|
+ checkOperation(OperationCategory.WRITE);
|
|
|
final String operationName = "renameSnapshot";
|
|
|
boolean success = false;
|
|
|
String oldSnapshotRoot = Snapshot.getSnapshotPath(path, snapshotOldName);
|
|
|
String newSnapshotRoot = Snapshot.getSnapshotPath(path, snapshotNewName);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot rename snapshot for " + path);
|
|
|
- FSDirSnapshotOp.renameSnapshot(dir, snapshotManager, path,
|
|
|
+ FSDirSnapshotOp.renameSnapshot(dir, pc, snapshotManager, path,
|
|
|
snapshotOldName, snapshotNewName, logRetryCache);
|
|
|
success = true;
|
|
|
} catch (AccessControlException ace) {
|
|
@@ -6435,10 +6470,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
SnapshottableDirectoryStatus[] status = null;
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
boolean success = false;
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
- status = FSDirSnapshotOp.getSnapshottableDirListing(dir, snapshotManager);
|
|
|
+ status = FSDirSnapshotOp.getSnapshottableDirListing(dir, pc,
|
|
|
+ snapshotManager);
|
|
|
success = true;
|
|
|
} catch (AccessControlException ace) {
|
|
|
logAuditEvent(success, operationName, null, null, null);
|
|
@@ -6475,10 +6512,11 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
path : Snapshot.getSnapshotPath(path, fromSnapshot);
|
|
|
String toSnapshotRoot = (toSnapshot == null || toSnapshot.isEmpty()) ?
|
|
|
path : Snapshot.getSnapshotPath(path, toSnapshot);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
- diffs = FSDirSnapshotOp.getSnapshotDiffReport(dir, snapshotManager,
|
|
|
+ diffs = FSDirSnapshotOp.getSnapshotDiffReport(dir, pc, snapshotManager,
|
|
|
path, fromSnapshot, toSnapshot);
|
|
|
success = true;
|
|
|
} catch (AccessControlException ace) {
|
|
@@ -6530,11 +6568,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
String toSnapshotRoot =
|
|
|
(toSnapshot == null || toSnapshot.isEmpty()) ? path :
|
|
|
Snapshot.getSnapshotPath(path, toSnapshot);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
diffs = FSDirSnapshotOp
|
|
|
- .getSnapshotDiffReportListing(dir, snapshotManager, path,
|
|
|
+ .getSnapshotDiffReportListing(dir, pc, snapshotManager, path,
|
|
|
fromSnapshot, toSnapshot, startPath, index,
|
|
|
snapshotDiffReportLimit);
|
|
|
success = true;
|
|
@@ -6562,14 +6601,15 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "deleteSnapshot";
|
|
|
boolean success = false;
|
|
|
String rootPath = null;
|
|
|
- writeLock();
|
|
|
BlocksMapUpdateInfo blocksToBeDeleted = null;
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
+ writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot delete snapshot for " + snapshotRoot);
|
|
|
rootPath = Snapshot.getSnapshotPath(snapshotRoot, snapshotName);
|
|
|
- blocksToBeDeleted = FSDirSnapshotOp.deleteSnapshot(dir, snapshotManager,
|
|
|
- snapshotRoot, snapshotName, logRetryCache);
|
|
|
+ blocksToBeDeleted = FSDirSnapshotOp.deleteSnapshot(dir, pc,
|
|
|
+ snapshotManager, snapshotRoot, snapshotName, logRetryCache);
|
|
|
success = true;
|
|
|
} catch (AccessControlException ace) {
|
|
|
logAuditEvent(success, operationName, rootPath, null, null);
|
|
@@ -7051,11 +7091,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "modifyAclEntries";
|
|
|
FileStatus auditStat = null;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot modify ACL entries on " + src);
|
|
|
- auditStat = FSDirAclOp.modifyAclEntries(dir, src, aclSpec);
|
|
|
+ auditStat = FSDirAclOp.modifyAclEntries(dir, pc, src, aclSpec);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -7071,11 +7112,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "removeAclEntries";
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
FileStatus auditStat = null;
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot remove ACL entries on " + src);
|
|
|
- auditStat = FSDirAclOp.removeAclEntries(dir, src, aclSpec);
|
|
|
+ auditStat = FSDirAclOp.removeAclEntries(dir, pc, src, aclSpec);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -7090,11 +7132,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "removeDefaultAcl";
|
|
|
FileStatus auditStat = null;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot remove default ACL entries on " + src);
|
|
|
- auditStat = FSDirAclOp.removeDefaultAcl(dir, src);
|
|
|
+ auditStat = FSDirAclOp.removeDefaultAcl(dir, pc, src);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -7109,11 +7152,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "removeAcl";
|
|
|
FileStatus auditStat = null;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot remove ACL on " + src);
|
|
|
- auditStat = FSDirAclOp.removeAcl(dir, src);
|
|
|
+ auditStat = FSDirAclOp.removeAcl(dir, pc, src);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -7128,11 +7172,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "setAcl";
|
|
|
FileStatus auditStat = null;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot set ACL on " + src);
|
|
|
- auditStat = FSDirAclOp.setAcl(dir, src, aclSpec);
|
|
|
+ auditStat = FSDirAclOp.setAcl(dir, pc, src, aclSpec);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -7147,10 +7192,11 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "getAclStatus";
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
final AclStatus ret;
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
- ret = FSDirAclOp.getAclStatus(dir, src);
|
|
|
+ ret = FSDirAclOp.getAclStatus(dir, pc, src);
|
|
|
} catch(AccessControlException ace) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw ace;
|
|
@@ -7179,13 +7225,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
try {
|
|
|
Metadata metadata = FSDirEncryptionZoneOp.ensureKeyIsInitialized(dir,
|
|
|
keyName, src);
|
|
|
- checkSuperuserPrivilege();
|
|
|
- FSPermissionChecker pc = getPermissionChecker();
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
+ checkSuperuserPrivilege(pc);
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
final FileStatus resultingStat;
|
|
|
writeLock();
|
|
|
try {
|
|
|
- checkSuperuserPrivilege();
|
|
|
+ checkSuperuserPrivilege(pc);
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot create encryption zone on " + src);
|
|
|
resultingStat = FSDirEncryptionZoneOp.createEncryptionZone(dir, src,
|
|
@@ -7240,12 +7286,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
throws IOException {
|
|
|
final String operationName = "listEncryptionZones";
|
|
|
boolean success = false;
|
|
|
- checkSuperuserPrivilege();
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
+ checkSuperuserPrivilege(pc);
|
|
|
readLock();
|
|
|
try {
|
|
|
- checkSuperuserPrivilege();
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
+ checkSuperuserPrivilege(pc);
|
|
|
final BatchedListEntries<EncryptionZone> ret =
|
|
|
FSDirEncryptionZoneOp.listEncryptionZones(dir, prevId);
|
|
|
success = true;
|
|
@@ -7261,11 +7308,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
boolean success = false;
|
|
|
try {
|
|
|
Preconditions.checkNotNull(zone, "zone is null.");
|
|
|
- checkSuperuserPrivilege();
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = dir.getPermissionChecker();
|
|
|
+ checkSuperuserPrivilege(pc);
|
|
|
checkNameNodeSafeMode("NameNode in safemode, cannot " + action
|
|
|
+ " re-encryption on zone " + zone);
|
|
|
- reencryptEncryptionZoneInt(zone, action, logRetryCache);
|
|
|
+ reencryptEncryptionZoneInt(pc, zone, action, logRetryCache);
|
|
|
success = true;
|
|
|
} finally {
|
|
|
logAuditEvent(success, action + "reencryption", zone, null, null);
|
|
@@ -7276,12 +7324,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final long prevId) throws IOException {
|
|
|
final String operationName = "listReencryptionStatus";
|
|
|
boolean success = false;
|
|
|
- checkSuperuserPrivilege();
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
+ checkSuperuserPrivilege(pc);
|
|
|
readLock();
|
|
|
try {
|
|
|
- checkSuperuserPrivilege();
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
+ checkSuperuserPrivilege(pc);
|
|
|
final BatchedListEntries<ZoneReencryptionStatus> ret =
|
|
|
FSDirEncryptionZoneOp.listReencryptionStatus(dir, prevId);
|
|
|
success = true;
|
|
@@ -7292,9 +7341,9 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void reencryptEncryptionZoneInt(final String zone,
|
|
|
- final ReencryptAction action, final boolean logRetryCache)
|
|
|
- throws IOException {
|
|
|
+ private void reencryptEncryptionZoneInt(final FSPermissionChecker pc,
|
|
|
+ final String zone, final ReencryptAction action,
|
|
|
+ final boolean logRetryCache) throws IOException {
|
|
|
if (getProvider() == null) {
|
|
|
throw new IOException("No key provider configured, re-encryption "
|
|
|
+ "operation is rejected");
|
|
@@ -7302,7 +7351,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
String keyVersionName = null;
|
|
|
if (action == ReencryptAction.START) {
|
|
|
// get zone's latest key version name out of the lock.
|
|
|
- keyVersionName = FSDirEncryptionZoneOp.getCurrentKeyVersion(dir, zone);
|
|
|
+ keyVersionName =
|
|
|
+ FSDirEncryptionZoneOp.getCurrentKeyVersion(dir, pc, zone);
|
|
|
if (keyVersionName == null) {
|
|
|
throw new IOException("Failed to get key version name for " + zone);
|
|
|
}
|
|
@@ -7311,11 +7361,10 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
}
|
|
|
writeLock();
|
|
|
try {
|
|
|
- checkSuperuserPrivilege();
|
|
|
+ checkSuperuserPrivilege(pc);
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("NameNode in safemode, cannot " + action
|
|
|
+ " re-encryption on zone " + zone);
|
|
|
- final FSPermissionChecker pc = dir.getPermissionChecker();
|
|
|
List<XAttr> xattrs;
|
|
|
dir.writeLock();
|
|
|
try {
|
|
@@ -7550,7 +7599,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "getErasureCodingPolicy";
|
|
|
boolean success = false;
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
- FSPermissionChecker pc = getPermissionChecker();
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
@@ -7609,11 +7658,14 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
throws IOException {
|
|
|
final String operationName = "setXAttr";
|
|
|
FileStatus auditStat = null;
|
|
|
+ checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot set XAttr on " + src);
|
|
|
- auditStat = FSDirXAttrOp.setXAttr(dir, src, xAttr, flag, logRetryCache);
|
|
|
+ auditStat = FSDirXAttrOp.setXAttr(dir, pc, src, xAttr, flag,
|
|
|
+ logRetryCache);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -7629,10 +7681,11 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "getXAttrs";
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
List<XAttr> fsXattrs;
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
- fsXattrs = FSDirXAttrOp.getXAttrs(dir, src, xAttrs);
|
|
|
+ fsXattrs = FSDirXAttrOp.getXAttrs(dir, pc, src, xAttrs);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -7647,10 +7700,11 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "listXAttrs";
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
List<XAttr> fsXattrs;
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
- fsXattrs = FSDirXAttrOp.listXAttrs(dir, src);
|
|
|
+ fsXattrs = FSDirXAttrOp.listXAttrs(dir, pc, src);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -7665,11 +7719,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
throws IOException {
|
|
|
final String operationName = "removeXAttr";
|
|
|
FileStatus auditStat = null;
|
|
|
+ checkOperation(OperationCategory.WRITE);
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot remove XAttr entry on " + src);
|
|
|
- auditStat = FSDirXAttrOp.removeXAttr(dir, src, xAttr, logRetryCache);
|
|
|
+ auditStat = FSDirXAttrOp.removeXAttr(dir, pc, src, xAttr, logRetryCache);
|
|
|
} catch (AccessControlException e) {
|
|
|
logAuditEvent(false, operationName, src);
|
|
|
throw e;
|
|
@@ -7683,7 +7739,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
void checkAccess(String src, FsAction mode) throws IOException {
|
|
|
final String operationName = "checkAccess";
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
- FSPermissionChecker pc = getPermissionChecker();
|
|
|
+ final FSPermissionChecker pc = getPermissionChecker();
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
@@ -7934,6 +7990,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
.size();
|
|
|
}
|
|
|
|
|
|
+ // This method logs operatoinName without super user privilege.
|
|
|
+ // It should be called without holding FSN lock.
|
|
|
void checkSuperuserPrivilege(String operationName)
|
|
|
throws IOException {
|
|
|
try {
|