HDFS-15091. Cache Admin and Quota Commands Should Check SuperUser Before Taking Lock. Contributed by Ayush Saxena.

This commit is contained in:
Ayush Saxena 2020-01-04 19:02:59 +05:30
parent 037ec8cfb1
commit f8644fbe9f
3 changed files with 4 additions and 16 deletions

View File

@ -233,9 +233,6 @@ static long getPreferredBlockSize(FSDirectory fsd, FSPermissionChecker pc,
*/ */
static void setQuota(FSDirectory fsd, FSPermissionChecker pc, String src, static void setQuota(FSDirectory fsd, FSPermissionChecker pc, String src,
long nsQuota, long ssQuota, StorageType type) throws IOException { long nsQuota, long ssQuota, StorageType type) throws IOException {
if (fsd.isPermissionEnabled()) {
pc.checkSuperuserPrivilege();
}
fsd.writeLock(); fsd.writeLock();
try { try {

View File

@ -78,11 +78,6 @@ static CachePoolInfo addCachePool(
FSNamesystem fsn, CacheManager cacheManager, CachePoolInfo req, FSNamesystem fsn, CacheManager cacheManager, CachePoolInfo req,
boolean logRetryCache) boolean logRetryCache)
throws IOException { throws IOException {
final FSPermissionChecker pc = getFsPermissionChecker(fsn);
if (pc != null) {
pc.checkSuperuserPrivilege();
}
CachePoolInfo info = cacheManager.addCachePool(req); CachePoolInfo info = cacheManager.addCachePool(req);
fsn.getEditLog().logAddCachePool(info, logRetryCache); fsn.getEditLog().logAddCachePool(info, logRetryCache);
return info; return info;
@ -91,10 +86,6 @@ static CachePoolInfo addCachePool(
static void modifyCachePool( static void modifyCachePool(
FSNamesystem fsn, CacheManager cacheManager, CachePoolInfo req, FSNamesystem fsn, CacheManager cacheManager, CachePoolInfo req,
boolean logRetryCache) throws IOException { boolean logRetryCache) throws IOException {
final FSPermissionChecker pc = getFsPermissionChecker(fsn);
if (pc != null) {
pc.checkSuperuserPrivilege();
}
cacheManager.modifyCachePool(req); cacheManager.modifyCachePool(req);
fsn.getEditLog().logModifyCachePool(req, logRetryCache); fsn.getEditLog().logModifyCachePool(req, logRetryCache);
} }
@ -102,10 +93,6 @@ static void modifyCachePool(
static void removeCachePool( static void removeCachePool(
FSNamesystem fsn, CacheManager cacheManager, String cachePoolName, FSNamesystem fsn, CacheManager cacheManager, String cachePoolName,
boolean logRetryCache) throws IOException { boolean logRetryCache) throws IOException {
final FSPermissionChecker pc = getFsPermissionChecker(fsn);
if (pc != null) {
pc.checkSuperuserPrivilege();
}
cacheManager.removeCachePool(cachePoolName); cacheManager.removeCachePool(cachePoolName);
fsn.getEditLog().logRemoveCachePool(cachePoolName, logRetryCache); fsn.getEditLog().logRemoveCachePool(cachePoolName, logRetryCache);
} }

View File

@ -3378,6 +3378,7 @@ void setQuota(String src, long nsQuota, long ssQuota, StorageType type)
final String operationName = getQuotaCommand(nsQuota, ssQuota); final String operationName = getQuotaCommand(nsQuota, ssQuota);
final FSPermissionChecker pc = getPermissionChecker(); final FSPermissionChecker pc = getPermissionChecker();
try { try {
checkSuperuserPrivilege(pc);
writeLock(); writeLock();
try { try {
checkOperation(OperationCategory.WRITE); checkOperation(OperationCategory.WRITE);
@ -7197,6 +7198,7 @@ void addCachePool(CachePoolInfo req, boolean logRetryCache)
checkOperation(OperationCategory.WRITE); checkOperation(OperationCategory.WRITE);
String poolInfoStr = null; String poolInfoStr = null;
try { try {
checkSuperuserPrivilege();
writeLock(); writeLock();
try { try {
checkOperation(OperationCategory.WRITE); checkOperation(OperationCategory.WRITE);
@ -7223,6 +7225,7 @@ void modifyCachePool(CachePoolInfo req, boolean logRetryCache)
String poolNameStr = "{poolName: " + String poolNameStr = "{poolName: " +
(req == null ? null : req.getPoolName()) + "}"; (req == null ? null : req.getPoolName()) + "}";
try { try {
checkSuperuserPrivilege();
writeLock(); writeLock();
try { try {
checkOperation(OperationCategory.WRITE); checkOperation(OperationCategory.WRITE);
@ -7248,6 +7251,7 @@ void removeCachePool(String cachePoolName, boolean logRetryCache)
checkOperation(OperationCategory.WRITE); checkOperation(OperationCategory.WRITE);
String poolNameStr = "{poolName: " + cachePoolName + "}"; String poolNameStr = "{poolName: " + cachePoolName + "}";
try { try {
checkSuperuserPrivilege();
writeLock(); writeLock();
try { try {
checkOperation(OperationCategory.WRITE); checkOperation(OperationCategory.WRITE);