Move everything to use the common pidfile functions.
[samba.git] / source3 / utils / smbcontrol.c
index 7d7eb1275a344d487e462b2307410df5c3df1c71..54c5d62c9774038f6e72c341efde0dab8c213d0e 100644 (file)
@@ -32,6 +32,7 @@
 #include "libsmb/nmblib.h"
 #include "messages.h"
 #include "util_tdb.h"
+#include "../lib/util/pidfile.h"
 
 #if HAVE_LIBUNWIND_H
 #include <libunwind.h>
@@ -181,8 +182,8 @@ static bool do_idmap(struct tevent_context *ev,
 {
        static const char* usage = "Usage: "
                "smbcontrol <dest> idmap <cmd> [arg]\n"
-               "\tcmd:\tflush [gid|uid]\n"
-               "\t\tdelete \"UID <uid>\"|\"GID <gid>\"|<sid>\n"
+               "\tcmd:"
+               "\tdelete \"UID <uid>\"|\"GID <gid>\"|<sid>\n"
                "\t\tkill \"UID <uid>\"|\"GID <gid>\"|<sid>\n";
        const char* arg = NULL;
        int arglen = 0;
@@ -200,10 +201,7 @@ static bool do_idmap(struct tevent_context *ev,
                return false;
        }
 
-       if (strcmp(argv[1], "flush") == 0) {
-               msg_type = ID_CACHE_FLUSH;
-       }
-       else if (strcmp(argv[1], "delete") == 0) {
+       if (strcmp(argv[1], "delete") == 0) {
                msg_type = ID_CACHE_DELETE;
        }
        else if (strcmp(argv[1], "kill") == 0) {
@@ -1064,10 +1062,6 @@ static bool do_dump_event_list(struct tevent_context *ev_ctx,
                               const struct server_id pid,
                               const int argc, const char **argv)
 {
-       struct server_id myid;
-
-       myid = messaging_server_id(msg_ctx);
-
        if (argc != 1) {
                fprintf(stderr, "Usage: smbcontrol <dest> dump-event-list\n");
                return False;
@@ -1254,6 +1248,18 @@ static bool do_nodestatus(struct tevent_context *ev_ctx,
        return send_message(msg_ctx, pid, MSG_SEND_PACKET, &p, sizeof(p));
 }
 
+static bool do_notify_cleanup(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 smbd notify-cleanup\n");
+               return false;
+       }
+       return send_message(msg_ctx, pid, MSG_SMB_NOTIFY_CLEANUP, NULL, 0);
+}
+
 /* A list of message type supported */
 
 static const struct {
@@ -1296,6 +1302,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"},
+       { "notify-cleanup", do_notify_cleanup },
        { "noop", do_noop, "Do nothing" },
        { NULL }
 };
@@ -1359,7 +1366,7 @@ static struct server_id parse_dest(struct messaging_context *msg,
 
        /* Look up other destinations in pidfile directory */
 
-       if ((pid = pidfile_pid(dest)) != 0) {
+       if ((pid = pidfile_pid(lp_piddir(), dest)) != 0) {
                return pid_to_procid(pid);
        }