mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 01:25:07 -05:00
cmdmon: add shutdown command
The command is functionally equivalent to sending the process the SIGTERM signal.
This commit is contained in:
14
cmdmon.c
14
cmdmon.c
@@ -138,6 +138,7 @@ static const char permissions[] = {
|
||||
PERMIT_AUTH, /* ADD_PEER2 */
|
||||
PERMIT_AUTH, /* ADD_SERVER3 */
|
||||
PERMIT_AUTH, /* ADD_PEER3 */
|
||||
PERMIT_AUTH, /* SHUTDOWN */
|
||||
};
|
||||
|
||||
/* ================================================== */
|
||||
@@ -1239,6 +1240,15 @@ handle_ntp_data(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||
memset(tx_message->data.ntp_data.reserved, 0xff, sizeof (tx_message->data.ntp_data.reserved));
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
static void
|
||||
handle_shutdown(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||
{
|
||||
LOG(LOGS_INFO, "Received shutdown command");
|
||||
SCH_QuitProgram();
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
/* Read a packet and process it */
|
||||
|
||||
@@ -1630,6 +1640,10 @@ read_from_cmd_socket(int sock_fd, int event, void *anything)
|
||||
handle_ntp_data(&rx_message, &tx_message);
|
||||
break;
|
||||
|
||||
case REQ_SHUTDOWN:
|
||||
handle_shutdown(&rx_message, &tx_message);
|
||||
break;
|
||||
|
||||
default:
|
||||
DEBUG_LOG("Unhandled command %d", rx_command);
|
||||
tx_message.status = htons(STT_FAILED);
|
||||
|
||||
Reference in New Issue
Block a user