]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbcontrol: Use cmdline_messaging_context
authorChristof Schmitt <cs@samba.org>
Tue, 21 Aug 2018 19:35:11 +0000 (12:35 -0700)
committerKarolin Seeger <kseeger@samba.org>
Tue, 9 Oct 2018 09:29:24 +0000 (11:29 +0200)
Initialize the messaging context through cmdline_messaging_context to
allow access to config in clustered Samba.

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>
(cherry picked from commit de040eafbd7d729316d757c14c44df163a4b36ad)

source3/utils/smbcontrol.c
source3/utils/wscript_build

index b024f3afbd9fb6d10bd705e01568e805ad89399e..5f7c2e8de0d1b10c46f03e2efcb7c00fec9ee58f 100644 (file)
@@ -35,6 +35,7 @@
 #include "util_tdb.h"
 #include "../lib/util/pidfile.h"
 #include "serverid.h"
+#include "cmdline_contexts.h"
 
 #if HAVE_LIBUNWIND_H
 #include <libunwind.h>
@@ -1643,21 +1644,23 @@ int main(int argc, const char **argv)
        if (argc <= 1)
                usage(pc);
 
+       msg_ctx = cmdline_messaging_context(get_dyn_CONFIGFILE());
+       if (msg_ctx == NULL) {
+               fprintf(stderr,
+                       "Could not init messaging context, not root?\n");
+               TALLOC_FREE(frame);
+               exit(1);
+       }
+
+       evt_ctx = server_event_context();
+
        lp_load_global(get_dyn_CONFIGFILE());
 
        /* Need to invert sense of return code -- samba
          * routines mostly return True==1 for success, but
          * shell needs 0. */ 
 
-       if (!(evt_ctx = samba_tevent_context_init(NULL)) ||
-           !(msg_ctx = messaging_init(NULL, evt_ctx))) {
-               fprintf(stderr, "could not init messaging context\n");
-               TALLOC_FREE(frame);
-               exit(1);
-       }
-
        ret = !do_command(evt_ctx, msg_ctx, argc, argv);
-       TALLOC_FREE(msg_ctx);
        TALLOC_FREE(frame);
        return ret;
 }
index 42aaf6836958f1efded979fcb1f90f1b4114bf46..4b1893f79b7e721ba14b15bfcdbc956b2ea0f84b 100644 (file)
@@ -18,6 +18,7 @@ bld.SAMBA3_BINARY('smbcontrol',
                  talloc
                  smbconf
                  popt_samba3
+                 cmdline_contexts
                  PRINTBASE''')
 
 bld.SAMBA3_BINARY('smbtree',