1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

s3 smbcontrol: Add sleep command

Add a sleep command that pauses the target process for the specified
number of seconds

This command is only enabled on developer and self test builds.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Gary Lockyer 2018-12-04 09:31:22 +13:00 committed by Andrew Bartlett
parent b578fad88e
commit ff9052c923
2 changed files with 39 additions and 0 deletions

View File

@ -109,6 +109,7 @@ interface messaging
MSG_SMB_NOTIFY_DB = 0x031D,
MSG_SMB_NOTIFY_REC_CHANGES = 0x031E,
MSG_SMB_NOTIFY_STARTED = 0x031F,
MSG_SMB_SLEEP = 0x0320,
/* winbind messages */
MSG_WINBIND_FINISHED = 0x0401,

View File

@ -410,6 +410,43 @@ static bool do_inject_fault(struct tevent_context *ev_ctx,
#endif /* DEVELOPER || ENABLE_SELFTEST */
}
static bool do_sleep(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
const struct server_id pid,
const int argc, const char **argv)
{
unsigned int seconds;
long input;
const long MAX_SLEEP = 60 * 60; /* One hour maximum sleep */
if (argc != 2) {
fprintf(stderr, "Usage: smbcontrol <dest> sleep seconds\n");
return False;
}
#if !defined(DEVELOPER) && !defined(ENABLE_SELFTEST)
fprintf(stderr, "Sleep is only available in "
"developer and self test builds\n");
return False;
#else /* DEVELOPER || ENABLE_SELFTEST */
input = atol(argv[1]);
if (input < 1 || input > MAX_SLEEP) {
fprintf(stderr,
"Invalid duration for sleep '%s'\n"
"It should be at least 1 second and no more than %ld\n",
argv[1],
MAX_SLEEP);
return False;
}
seconds = input;
return send_message(msg_ctx, pid,
MSG_SMB_SLEEP,
&seconds,
sizeof(unsigned int));
#endif /* DEVELOPER || ENABLE_SELFTEST */
}
/* Force a browser election */
static bool do_election(struct tevent_context *ev_ctx,
@ -1421,6 +1458,7 @@ static const struct {
"Print number of smbd child processes" },
{ "msg-cleanup", do_msg_cleanup },
{ "noop", do_noop, "Do nothing" },
{ "sleep", do_sleep, "Cause the target process to sleep" },
{ NULL }
};