HBASE-25441 : add security check for some APIs in RSRpcServices (#2810)

Signed-off-by: stack <stack@apache.org>
Signed-off-by: Viraj Jasani <vjasani@apache.org>
This commit is contained in:
lujiefsi 2020-12-31 02:52:26 +08:00 committed by GitHub
parent 55a4eca9e6
commit 29a9a16de4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -2784,6 +2784,19 @@ public class HMaster extends HRegionServer implements MasterServices {
return initialized.isReady();
}
/**
* Report whether this master is started
*
* This method is used for testing.
*
* @return true if master is ready to go, false if not.
*/
@Override
public boolean isOnline() {
return serviceStarted;
}
/**
* Report whether this master is in maintenance mode.
*

View File

@ -2345,6 +2345,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
@QosPriority(priority=HConstants.ADMIN_QOS)
public StopServerResponse stopServer(final RpcController controller,
final StopServerRequest request) throws ServiceException {
rpcPreCheck("stopServer");
requestCount.increment();
String reason = request.getReason();
regionServer.stop(reason);
@ -2354,6 +2355,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
@Override
public UpdateFavoredNodesResponse updateFavoredNodes(RpcController controller,
UpdateFavoredNodesRequest request) throws ServiceException {
rpcPreCheck("updateFavoredNodes");
List<UpdateFavoredNodesRequest.RegionUpdateInfo> openInfoList = request.getUpdateInfoList();
UpdateFavoredNodesResponse.Builder respBuilder = UpdateFavoredNodesResponse.newBuilder();
for (UpdateFavoredNodesRequest.RegionUpdateInfo regionUpdateInfo : openInfoList) {
@ -3774,6 +3776,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
RpcController controller, UpdateConfigurationRequest request)
throws ServiceException {
try {
requirePermission("updateConfiguration", Permission.Action.ADMIN);
this.regionServer.updateConfiguration();
} catch (Exception e) {
throw new ServiceException(e);
@ -3806,7 +3809,8 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
@Override
public ClearRegionBlockCacheResponse clearRegionBlockCache(RpcController controller,
ClearRegionBlockCacheRequest request) {
ClearRegionBlockCacheRequest request) throws ServiceException {
rpcPreCheck("clearRegionBlockCache");
ClearRegionBlockCacheResponse.Builder builder =
ClearRegionBlockCacheResponse.newBuilder();
CacheEvictionStatsBuilder stats = CacheEvictionStats.builder();
@ -3933,7 +3937,8 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
@Override
@QosPriority(priority = HConstants.ADMIN_QOS)
public ClearSlowLogResponses clearSlowLogsResponses(final RpcController controller,
final ClearSlowLogResponseRequest request) {
final ClearSlowLogResponseRequest request) throws ServiceException {
rpcPreCheck("clearSlowLogsResponses");
final NamedQueueRecorder namedQueueRecorder =
this.regionServer.getNamedQueueRecorder();
boolean slowLogsCleaned = Optional.ofNullable(namedQueueRecorder)