From: Volker Lendecke Date: Wed, 28 Feb 2018 15:08:44 +0000 (+0000) Subject: winbind: Add smbcontrol disconnect-dc X-Git-Tag: talloc-2.1.12~182 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0af88b98e7e1bba14827305257e77b63dc82d902;p=thirdparty%2Fsamba.git winbind: Add smbcontrol disconnect-dc Make a winbind child drop all DC connections Bug: https://bugzilla.samba.org/show_bug.cgi?id=13332 Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/librpc/idl/messaging.idl b/librpc/idl/messaging.idl index 5468334b77b..14a6f92d583 100644 --- a/librpc/idl/messaging.idl +++ b/librpc/idl/messaging.idl @@ -124,6 +124,7 @@ interface messaging MSG_WINBIND_DOMAIN_ONLINE = 0x040B, MSG_WINBIND_DOMAIN_OFFLINE = 0x040C, MSG_WINBIND_RELOAD_TRUSTED_DOMAINS = 0x040D, + MSG_WINBIND_DISCONNECT_DC = 0x040E, /* event messages */ /* MSG_DUMP_EVENT_LIST = 0x0500, Obsoleted */ diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c index 4ecfb3e6dff..bd89b9ebf0a 100644 --- a/source3/utils/smbcontrol.c +++ b/source3/utils/smbcontrol.c @@ -1225,6 +1225,19 @@ static bool do_winbind_dump_domain_list(struct tevent_context *ev_ctx, return num_replies; } +static bool do_msg_disconnect_dc(struct tevent_context *ev_ctx, + struct messaging_context *msg_ctx, + const struct server_id pid, + const int argc, const char **argv) +{ + if (argc != 1) { + fprintf(stderr, "Usage: smbcontrol disconnect-dc\n"); + return False; + } + + return send_message(msg_ctx, pid, MSG_WINBIND_DISCONNECT_DC, NULL, 0); +} + static void winbind_validate_cache_cb(struct messaging_context *msg, void *private_data, uint32_t msg_type, @@ -1402,6 +1415,7 @@ static const struct { { "validate-cache" , do_winbind_validate_cache, "Validate winbind's credential cache" }, { "dump-domain-list", do_winbind_dump_domain_list, "Dump winbind domain list"}, + { "disconnect-dc", do_msg_disconnect_dc }, { "notify-cleanup", do_notify_cleanup }, { "num-children", do_num_children, "Print number of smbd child processes" }, diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 81b86df2ffa..8821f39a0da 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -1346,6 +1346,10 @@ static void winbindd_register_handlers(struct messaging_context *msg_ctx, MSG_DEBUG, winbind_msg_debug); + messaging_register(msg_ctx, NULL, + MSG_WINBIND_DISCONNECT_DC, + winbind_disconnect_dc_parent); + netsamlogon_cache_init(); /* Non-critical */ /* clear the cached list of trusted domains */ diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index 1e44e9bd3ce..0f6a0a9ba1f 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -3509,3 +3509,19 @@ void winbind_msg_ip_dropped(struct messaging_context *msg_ctx, } TALLOC_FREE(freeit); } + +void winbind_msg_disconnect_dc(struct messaging_context *msg_ctx, + void *private_data, + uint32_t msg_type, + struct server_id server_id, + DATA_BLOB *data) +{ + struct winbindd_domain *domain; + + for (domain = domain_list(); domain; domain = domain->next) { + if (domain->internal) { + continue; + } + invalidate_cm_connection(domain); + } +} diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index 2a4950b56bf..5ae5bbd9468 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -882,6 +882,21 @@ void winbind_msg_debug(struct messaging_context *msg_ctx, forall_children(winbind_msg_relay_fn, &state); } +void winbind_disconnect_dc_parent(struct messaging_context *msg_ctx, + void *private_data, + uint32_t msg_type, + struct server_id server_id, + DATA_BLOB *data) +{ + struct winbind_msg_relay_state state = { + .msg_ctx = msg_ctx, .msg_type = msg_type, .data = data + }; + + DBG_DEBUG("Got disconnect_dc message\n"); + + forall_children(winbind_msg_relay_fn, &state); +} + /* Set our domains as offline and forward the offline message to our children. */ struct winbind_msg_on_offline_state { @@ -1710,7 +1725,9 @@ static bool fork_domain_child(struct winbindd_child *child) messaging_register(server_messaging_context(), NULL, MSG_WINBIND_IP_DROPPED, winbind_msg_ip_dropped); - + messaging_register(server_messaging_context(), NULL, + MSG_WINBIND_DISCONNECT_DC, + winbind_msg_disconnect_dc); primary_domain = find_our_domain(); diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h index b70227c9b91..f8ffeea74cf 100644 --- a/source3/winbindd/winbindd_proto.h +++ b/source3/winbindd/winbindd_proto.h @@ -297,6 +297,11 @@ void winbind_msg_debug(struct messaging_context *msg_ctx, uint32_t msg_type, struct server_id server_id, DATA_BLOB *data); +void winbind_disconnect_dc_parent(struct messaging_context *msg_ctx, + void *private_data, + uint32_t msg_type, + struct server_id server_id, + DATA_BLOB *data); void winbind_msg_offline(struct messaging_context *msg_ctx, void *private_data, uint32_t msg_type, @@ -327,6 +332,11 @@ void winbind_msg_ip_dropped(struct messaging_context *msg_ctx, uint32_t msg_type, struct server_id server_id, DATA_BLOB *data); +void winbind_msg_disconnect_dc(struct messaging_context *msg_ctx, + void *private_data, + uint32_t msg_type, + struct server_id server_id, + DATA_BLOB *data); void winbind_msg_ip_dropped_parent(struct messaging_context *msg_ctx, void *private_data, uint32_t msg_type,