summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2019-01-15 01:39:06 +0100
committerKarolin Seeger <kseeger@samba.org>2019-02-05 15:33:28 +0100
commit562ceb1f43da0e7fd640bb7a8d5eb65a92ea2e89 (patch)
tree9741902a1d359fd3c5df23093d6ba232c34ce376 /source4
parentf6ebd9d2a9eb135c51cbea5909f54b61196ecef4 (diff)
downloadsamba-562ceb1f43da0e7fd640bb7a8d5eb65a92ea2e89.tar.gz
s4:messaging: add support 'smbcontrol <pid> debug/debuglevel'
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13752 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Björn Baumbach <bbaumbach@samba.org> (cherry picked from commit 3a0c1da432c53de234b54bac90a3fb84534994eb)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/messaging/messaging.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index 935951f3fba..4a71b2b76bb 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -121,6 +121,68 @@ static void ringbuf_log_msg(struct imessaging_context *msg,
imessaging_send(msg, src, MSG_RINGBUF_LOG, &blob);
}
+/****************************************************************************
+ Receive a "set debug level" message.
+****************************************************************************/
+
+static void debug_imessage(struct imessaging_context *msg_ctx,
+ void *private_data,
+ uint32_t msg_type,
+ struct server_id src,
+ DATA_BLOB *data)
+{
+ const char *params_str = (const char *)data->data;
+ struct server_id_buf src_buf;
+ struct server_id dst = imessaging_get_server_id(msg_ctx);
+ struct server_id_buf dst_buf;
+
+ /* Check, it's a proper string! */
+ if (params_str[(data->length)-1] != '\0') {
+ DBG_ERR("Invalid debug message from pid %s to pid %s\n",
+ server_id_str_buf(src, &src_buf),
+ server_id_str_buf(dst, &dst_buf));
+ return;
+ }
+
+ DBG_ERR("INFO: Remote set of debug to `%s' (pid %s from pid %s)\n",
+ params_str,
+ server_id_str_buf(dst, &dst_buf),
+ server_id_str_buf(src, &src_buf));
+
+ debug_parse_levels(params_str);
+}
+
+/****************************************************************************
+ Return current debug level.
+****************************************************************************/
+
+static void debuglevel_imessage(struct imessaging_context *msg_ctx,
+ void *private_data,
+ uint32_t msg_type,
+ struct server_id src,
+ DATA_BLOB *data)
+{
+ char *message = debug_list_class_names_and_levels();
+ DATA_BLOB blob = data_blob_null;
+ struct server_id_buf src_buf;
+ struct server_id dst = imessaging_get_server_id(msg_ctx);
+ struct server_id_buf dst_buf;
+
+ DBG_DEBUG("Received REQ_DEBUGLEVEL message (pid %s from pid %s)\n",
+ server_id_str_buf(dst, &dst_buf),
+ server_id_str_buf(src, &src_buf));
+
+ if (message == NULL) {
+ DBG_ERR("debug_list_class_names_and_levels returned NULL\n");
+ return;
+ }
+
+ blob = data_blob_string_const_null(message);
+ imessaging_send(msg_ctx, src, MSG_DEBUGLEVEL, &blob);
+
+ TALLOC_FREE(message);
+}
+
/*
return uptime of messaging server via irpc
*/
@@ -418,6 +480,16 @@ static struct imessaging_context *imessaging_init_internal(TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
goto fail;
}
+ status = imessaging_register(msg, NULL, MSG_DEBUG,
+ debug_imessage);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
+ status = imessaging_register(msg, NULL, MSG_REQ_DEBUGLEVEL,
+ debuglevel_imessage);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
status = IRPC_REGISTER(msg, irpc, IRPC_UPTIME, irpc_uptime, msg);
if (!NT_STATUS_IS_OK(status)) {
goto fail;