s3:utils/smbcontrol implement kill-client-ip in smbcontrol
authorChristian Ambach <ambi@samba.org>
Fri, 15 Mar 2013 14:09:18 +0000 (15:09 +0100)
committerChristof Schmitt <cs@samba.org>
Thu, 12 Dec 2013 17:50:59 +0000 (10:50 -0700)
allows the admin to forcefully shutdown the connection of a specified client by IP address

Signed-off-by: Christian Ambach <ambi@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/utils/smbcontrol.c

index 00b23f7ce93b3fc21e6e83ec5c41357491c65136..ea1f60951f8ca549e2612e0cbe0ce3c60c523cd4 100644 (file)
@@ -790,6 +790,27 @@ static bool do_closeshare(struct tevent_context *ev_ctx,
                            strlen(argv[1]) + 1);
 }
 
+/* Kill a client by IP address */
+static bool do_kill_client_by_ip(struct tevent_context *ev_ctx,
+                                struct messaging_context *msg_ctx,
+                                const struct server_id pid,
+                                const int argc, const char **argv)
+{
+       if (argc != 2) {
+               fprintf(stderr, "Usage: smbcontrol <dest> kill-client-ip "
+                       "<IP address>\n");
+               return false;
+       }
+
+       if (!is_ipaddress_v4(argv[1]) && !is_ipaddress_v6(argv[1])) {
+               fprintf(stderr, "%s is not a valid IP address!\n", argv[1]);
+               return false;
+       }
+
+       return send_message(msg_ctx, pid, MSG_SMB_KILL_CLIENT_IP,
+                           argv[1], strlen(argv[1]) + 1);
+}
+
 /* Tell winbindd an IP got dropped */
 
 static bool do_ip_dropped(struct tevent_context *ev_ctx,
@@ -1287,6 +1308,8 @@ static const struct {
        { "debuglevel", do_debuglevel, "Display current debuglevels" },
        { "printnotify", do_printnotify, "Send a print notify message" },
        { "close-share", do_closeshare, "Forcibly disconnect a share" },
+       { "kill-client-ip", do_kill_client_by_ip,
+         "Forcibly disconnect a client with a specific IP address" },
        { "ip-dropped", do_ip_dropped, "Tell winbind that an IP got dropped" },
        { "lockretry", do_lockretry, "Force a blocking lock retry" },
        { "brl-revalidate", do_brl_revalidate, "Revalidate all brl entries" },