s3:smbstatus: Use cmdline_messaging_context
authorChristof Schmitt <cs@samba.org>
Mon, 20 Aug 2018 22:46:27 +0000 (15:46 -0700)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 7 Sep 2018 15:26:15 +0000 (17:26 +0200)
Use cmdline_messaging_context to initialize a messaging context instead
of open coding the same steps.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/utils/status.c
source3/wscript_build

index f0d1a851be4d645b7c72d11972a767d2596b2925..0fe2c820eb2742dfd436eab73d4baf16cc5e552d 100644 (file)
@@ -48,6 +48,7 @@
 #include "serverid.h"
 #include "status_profile.h"
 #include "smbd/notifyd/notifyd.h"
+#include "cmdline_contexts.h"
 
 #define SMB_MAXPIDS            2048
 static uid_t           Ucrit_uid = 0;               /* added by OH */
@@ -527,7 +528,6 @@ int main(int argc, const char *argv[])
        };
        TALLOC_CTX *frame = talloc_stackframe();
        int ret = 0;
-       struct tevent_context *ev;
        struct messaging_context *msg_ctx = NULL;
        char *db_path;
        bool ok;
@@ -606,28 +606,9 @@ int main(int argc, const char *argv[])
                d_printf("using configfile = %s\n", get_dyn_CONFIGFILE());
        }
 
-       if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
-               fprintf(stderr, "Can't load %s - run testparm to debug it\n",
-                       get_dyn_CONFIGFILE());
-               ret = -1;
-               goto done;
-       }
-
-
-       /*
-        * This implicitly initializes the global ctdbd connection,
-        * usable by the db_open() calls further down.
-        */
-       ev = samba_tevent_context_init(NULL);
-       if (ev == NULL) {
-               fprintf(stderr, "samba_tevent_context_init failed\n");
-               ret = -1;
-               goto done;
-       }
-
-       msg_ctx = messaging_init(NULL, ev);
+       msg_ctx = cmdline_messaging_context(get_dyn_CONFIGFILE());
        if (msg_ctx == NULL) {
-               fprintf(stderr, "messaging_init failed\n");
+               fprintf(stderr, "Could not initialize messaging, not root?\n");
                ret = -1;
                goto done;
        }
index 9c6200a2b74f8781ba507fc5b0b668d23b91773f..c6598f976e84331070c80edf4726b9d9e3fad3d9 100644 (file)
@@ -1153,6 +1153,7 @@ bld.SAMBA3_BINARY('smbstatus',
                       talloc
                       smbconf
                       popt_samba3
+                      cmdline_contexts
                       smbd_base
                       LOCKING
                       PROFILE