2 Unix SMB/CIFS implementation.
4 Handers for non core Samba internal messages
6 Handlers for messages that are only included in developer and self test
9 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2018
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include "lib/util/server_id.h"
27 #include "messaging/messaging.h"
28 #include "messaging/messaging_internal.h"
30 #if defined(DEVELOPER) || defined(ENABLE_SELFTEST)
33 * Inject a fault into the currently running process
35 static void do_inject_fault(struct imessaging_context
*msg
,
44 struct server_id_buf tmp
;
47 DBG_WARNING("Received %zu fds, ignoring message\n", num_fds
);
51 if (data
->length
!= sizeof(sig
)) {
52 DBG_ERR("Process %s sent bogus signal injection request\n",
53 server_id_str_buf(src
, &tmp
));
57 sig
= *(int *)data
->data
;
59 DBG_ERR("Process %s requested an iternal failure, "
61 server_id_str_buf(src
, &tmp
));
66 DBG_ERR("Process %s requested injection of signal %d (%s)\n",
67 server_id_str_buf(src
, &tmp
),
71 DBG_ERR("Process %s requested injection of signal %d\n",
72 server_id_str_buf(src
, &tmp
),
80 * Cause the current process to sleep for a specified number of seconds
82 static void do_sleep(struct imessaging_context
*msg
,
91 struct server_id_buf tmp
;
94 DBG_WARNING("Received %zu fds, ignoring message\n", num_fds
);
98 if (data
->length
!= sizeof(seconds
)) {
99 DBG_ERR("Process %s sent bogus sleep request\n",
100 server_id_str_buf(src
, &tmp
));
104 seconds
= *(unsigned int *)data
->data
;
105 DBG_ERR("Process %s requested a sleep of %u seconds\n",
106 server_id_str_buf(src
, &tmp
),
109 DBG_ERR("Restarting after %u second sleep requested by process %s\n",
111 server_id_str_buf(src
, &tmp
));
115 * Register the extra messaging handlers
117 NTSTATUS
imessaging_register_extra_handlers(struct imessaging_context
*msg
)
121 status
= imessaging_register(
122 msg
, NULL
, MSG_SMB_INJECT_FAULT
, do_inject_fault
);
123 if (!NT_STATUS_IS_OK(status
)) {
127 status
= imessaging_register(msg
, NULL
, MSG_SMB_SLEEP
, do_sleep
);
128 if (!NT_STATUS_IS_OK(status
)) {
135 #endif /* defined(DEVELOPER) || defined(ENABLE_SELFTEST) */