HDFS-15091. Cache Admin and Quota Commands Should Check SuperUser Before Taking Lock. Contributed by Ayush Saxena.
This commit is contained in:
parent
037ec8cfb1
commit
f8644fbe9f
@ -233,9 +233,6 @@ static long getPreferredBlockSize(FSDirectory fsd, FSPermissionChecker pc,
|
||||
*/
|
||||
static void setQuota(FSDirectory fsd, FSPermissionChecker pc, String src,
|
||||
long nsQuota, long ssQuota, StorageType type) throws IOException {
|
||||
if (fsd.isPermissionEnabled()) {
|
||||
pc.checkSuperuserPrivilege();
|
||||
}
|
||||
|
||||
fsd.writeLock();
|
||||
try {
|
||||
|
@ -78,11 +78,6 @@ static CachePoolInfo addCachePool(
|
||||
FSNamesystem fsn, CacheManager cacheManager, CachePoolInfo req,
|
||||
boolean logRetryCache)
|
||||
throws IOException {
|
||||
final FSPermissionChecker pc = getFsPermissionChecker(fsn);
|
||||
|
||||
if (pc != null) {
|
||||
pc.checkSuperuserPrivilege();
|
||||
}
|
||||
CachePoolInfo info = cacheManager.addCachePool(req);
|
||||
fsn.getEditLog().logAddCachePool(info, logRetryCache);
|
||||
return info;
|
||||
@ -91,10 +86,6 @@ static CachePoolInfo addCachePool(
|
||||
static void modifyCachePool(
|
||||
FSNamesystem fsn, CacheManager cacheManager, CachePoolInfo req,
|
||||
boolean logRetryCache) throws IOException {
|
||||
final FSPermissionChecker pc = getFsPermissionChecker(fsn);
|
||||
if (pc != null) {
|
||||
pc.checkSuperuserPrivilege();
|
||||
}
|
||||
cacheManager.modifyCachePool(req);
|
||||
fsn.getEditLog().logModifyCachePool(req, logRetryCache);
|
||||
}
|
||||
@ -102,10 +93,6 @@ static void modifyCachePool(
|
||||
static void removeCachePool(
|
||||
FSNamesystem fsn, CacheManager cacheManager, String cachePoolName,
|
||||
boolean logRetryCache) throws IOException {
|
||||
final FSPermissionChecker pc = getFsPermissionChecker(fsn);
|
||||
if (pc != null) {
|
||||
pc.checkSuperuserPrivilege();
|
||||
}
|
||||
cacheManager.removeCachePool(cachePoolName);
|
||||
fsn.getEditLog().logRemoveCachePool(cachePoolName, logRetryCache);
|
||||
}
|
||||
|
@ -3378,6 +3378,7 @@ void setQuota(String src, long nsQuota, long ssQuota, StorageType type)
|
||||
final String operationName = getQuotaCommand(nsQuota, ssQuota);
|
||||
final FSPermissionChecker pc = getPermissionChecker();
|
||||
try {
|
||||
checkSuperuserPrivilege(pc);
|
||||
writeLock();
|
||||
try {
|
||||
checkOperation(OperationCategory.WRITE);
|
||||
@ -7197,6 +7198,7 @@ void addCachePool(CachePoolInfo req, boolean logRetryCache)
|
||||
checkOperation(OperationCategory.WRITE);
|
||||
String poolInfoStr = null;
|
||||
try {
|
||||
checkSuperuserPrivilege();
|
||||
writeLock();
|
||||
try {
|
||||
checkOperation(OperationCategory.WRITE);
|
||||
@ -7223,6 +7225,7 @@ void modifyCachePool(CachePoolInfo req, boolean logRetryCache)
|
||||
String poolNameStr = "{poolName: " +
|
||||
(req == null ? null : req.getPoolName()) + "}";
|
||||
try {
|
||||
checkSuperuserPrivilege();
|
||||
writeLock();
|
||||
try {
|
||||
checkOperation(OperationCategory.WRITE);
|
||||
@ -7248,6 +7251,7 @@ void removeCachePool(String cachePoolName, boolean logRetryCache)
|
||||
checkOperation(OperationCategory.WRITE);
|
||||
String poolNameStr = "{poolName: " + cachePoolName + "}";
|
||||
try {
|
||||
checkSuperuserPrivilege();
|
||||
writeLock();
|
||||
try {
|
||||
checkOperation(OperationCategory.WRITE);
|
||||
|
Loading…
Reference in New Issue
Block a user