diff --git a/src/slurmctld/controller.c b/src/slurmctld/controller.c index d5363b7639dc2acf40052b2038765432fa9644d7..8c362c5777e840f323fec401e5eb5455dac402bc 100644 --- a/src/slurmctld/controller.c +++ b/src/slurmctld/controller.c @@ -2327,27 +2327,28 @@ static int _background_process_msg(slurm_msg_t * msg) { int error_code = SLURM_SUCCESS; uid_t uid; + bool super_user = false; uid = g_slurm_auth_get_uid(msg->cred); - if ((uid != 0) && (uid != getuid())) { - error("Security violation, SHUTDOWN RPC from uid %u", - (unsigned int) uid); - error_code = ESLURM_USER_ID_MISSING; - } + if ((uid == 0) || (uid == getuid())) + super_user = true; if (error_code == SLURM_SUCCESS) { if (msg->msg_type == REQUEST_PING) { ; - } else if (msg->msg_type == REQUEST_SHUTDOWN_IMMEDIATE) { - debug3 - ("Performing RPC: REQUEST_SHUTDOWN_IMMEDIATE"); - } else if (msg->msg_type == REQUEST_SHUTDOWN) { + } else if (super_user && + (msg->msg_type == REQUEST_SHUTDOWN_IMMEDIATE)) { + debug3("Performing RPC: REQUEST_SHUTDOWN_IMMEDIATE"); + } else if (super_user && + (msg->msg_type == REQUEST_SHUTDOWN)) { debug("Performing RPC: REQUEST_SHUTDOWN"); pthread_kill(thread_id_sig, SIGTERM); - } else if (msg->msg_type == REQUEST_CONTROL) { + } else if (super_user && + (msg->msg_type == REQUEST_CONTROL)) { debug3("Ignoring RPC: REQUEST_CONTROL"); } else { - error("Invalid RPC received %d", msg->msg_type); + error("Invalid RPC received %d from uid %u", + msg->msg_type, uid); error_code = SLURM_COMMUNICATIONS_RECEIVE_ERROR; } }