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 @@ public class FSDirAttrOp {
|
||||||
*/
|
*/
|
||||||
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 {
|
||||||
|
|
|
@ -78,11 +78,6 @@ class FSNDNCacheOp {
|
||||||
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 @@ class FSNDNCacheOp {
|
||||||
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 @@ class FSNDNCacheOp {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3378,6 +3378,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
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 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
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 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
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 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
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);
|
||||||
|
|
Loading…
Reference in New Issue