diff options
author | Stefan Metzmacher <metze@samba.org> | 2019-01-17 16:27:10 +0100 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2019-02-05 20:41:25 +0100 |
commit | 902de86daa685b864594df5026f60d7cd7171b2e (patch) | |
tree | c4c889a590a4e2520c088854d205a7d8f8f324a9 | |
parent | 45c19f4c25393bcc9db56e93a79ac25cef7e6280 (diff) | |
download | samba-902de86daa685b864594df5026f60d7cd7171b2e.tar.gz |
s4:server: add support for 'smbcontrol samba shutdown'
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 832776c0fcf7cc658c128765514755c2d15b06a6)
-rw-r--r-- | source4/smbd/server.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/source4/smbd/server.c b/source4/smbd/server.c index 0345c6ac7d3..eeb46ffee6a 100644 --- a/source4/smbd/server.c +++ b/source4/smbd/server.c @@ -45,6 +45,7 @@ #include "libds/common/roles.h" #include "lib/util/tfork.h" #include "dsdb/samdb/ldb_modules/util.h" +#include "lib/util/server_id.h" #ifdef HAVE_PTHREAD #include <pthread.h> @@ -292,6 +293,31 @@ static int prime_ldb_databases(struct tevent_context *event_ctx, bool *am_backup } /* + called from 'smbcontrol samba shutdown' + */ +static void samba_parent_shutdown(struct imessaging_context *msg, + void *private_data, + uint32_t msg_type, + struct server_id src, + DATA_BLOB *data) +{ + struct server_state *state = + talloc_get_type_abort(private_data, + struct server_state); + struct server_id_buf src_buf; + struct server_id dst = imessaging_get_server_id(msg); + struct server_id_buf dst_buf; + + DBG_ERR("samba_shutdown of %s %s: from %s\n", + state->binary_name, + server_id_str_buf(dst, &dst_buf), + server_id_str_buf(src, &src_buf)); + + TALLOC_FREE(state); + exit(0); +} + +/* called when a fatal condition occurs in a child task */ static NTSTATUS samba_terminate(struct irpc_message *msg, @@ -325,10 +351,19 @@ static NTSTATUS setup_parent_messaging(struct server_state *state, return status; } + status = imessaging_register(msg, state, MSG_SHUTDOWN, + samba_parent_shutdown); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + status = IRPC_REGISTER(msg, irpc, SAMBA_TERMINATE, samba_terminate, state); + if (!NT_STATUS_IS_OK(status)) { + return status; + } - return status; + return NT_STATUS_OK; } |