winbind: Add smbcontrol disconnect-dc
authorVolker Lendecke <vl@samba.org>
Wed, 28 Feb 2018 15:08:44 +0000 (15:08 +0000)
committerRalph Boehme <slow@samba.org>
Thu, 15 Mar 2018 14:46:09 +0000 (15:46 +0100)
Make a winbind child drop all DC connections

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13332

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
librpc/idl/messaging.idl
source3/utils/smbcontrol.c
source3/winbindd/winbindd.c
source3/winbindd/winbindd_cm.c
source3/winbindd/winbindd_dual.c
source3/winbindd/winbindd_proto.h

index 5468334b77bc79e2a7e18342f6398dbc2a384afc..14a6f92d583e0e5a6fdc60f3bfccddb049f27811 100644 (file)
@@ -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 */
index 4ecfb3e6dff5983c78337c357384047922d3d9e4..bd89b9ebf0a4ce8272e12634d355a71615dd76cb 100644 (file)
@@ -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 <dest> 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" },
index 81b86df2ffa466c926aeb14ae04006dabb89423c..8821f39a0dac51c2f529ac6977356bf56540a902 100644 (file)
@@ -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 */
index 1e44e9bd3ce8641533d39713b9b19c20df472eb3..0f6a0a9ba1fb4212498dc2a31d4641ad1d2b67a8 100644 (file)
@@ -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);
+       }
+}
index 2a4950b56bfe81cfa054040ff194ff9de91b2362..5ae5bbd9468ba987f9a55d65410602d2fb445265 100644 (file)
@@ -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();
 
index b70227c9b9198d2d9b00c92186b7923237627d0b..f8ffeea74cf00ad6e562e90ed1e71cae2434da96 100644 (file)
@@ -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,