]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:utils: Migrate smbcontrol to new cmdline option parser
authorAndreas Schneider <asn@samba.org>
Wed, 13 Jan 2021 12:28:11 +0000 (13:28 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 25 May 2021 00:23:37 +0000 (00:23 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/utils/smbcontrol.c
source3/utils/wscript_build

index 57c029b7e536bc79ae8fa39a59494f001ce9dd64..070e16b97f67f5a6cef2877f96010f3e5cde925a 100644 (file)
@@ -26,7 +26,7 @@
 #include "includes.h"
 #include "system/filesys.h"
 #include "lib/util/server_id.h"
-#include "popt_common.h"
+#include "lib/cmdline/cmdline.h"
 #include "librpc/gen_ndr/spoolss.h"
 #include "nt_printing.h"
 #include "printing/notify.h"
@@ -1703,7 +1703,7 @@ int main(int argc, const char **argv)
        struct tevent_context *evt_ctx;
        struct messaging_context *msg_ctx;
 
-       static struct poptOption long_options[] = {
+       struct poptOption long_options[] = {
                /* POPT_AUTOHELP */
                { NULL, '\0', POPT_ARG_INCLUDE_TABLE, help_options,
                                        0, "Help options:", NULL },
@@ -1711,20 +1711,37 @@ int main(int argc, const char **argv)
                  "Set timeout value in seconds", "TIMEOUT" },
 
                POPT_COMMON_SAMBA
+               POPT_COMMON_VERSION
                POPT_TABLEEND
        };
        TALLOC_CTX *frame = talloc_stackframe();
        int ret = 0;
+       bool ok;
 
        smb_init_locale();
 
-       setup_logging(argv[0], DEBUG_STDOUT);
+       ok = samba_cmdline_init(frame,
+                               SAMBA_CMDLINE_CONFIG_CLIENT,
+                               false /* require_smbconf */);
+       if (!ok) {
+               DBG_ERR("Failed to init cmdline parser!\n");
+               TALLOC_FREE(frame);
+               exit(1);
+       }
        lp_set_cmdline("log level", "0");
 
        /* Parse command line arguments using popt */
 
-       pc = poptGetContext(
-               "smbcontrol", argc, (const char **)argv, long_options, 0);
+       pc = samba_popt_get_context(getprogname(),
+                                   argc,
+                                   argv,
+                                   long_options,
+                                   0);
+       if (pc == NULL) {
+               DBG_ERR("Failed to setup popt context!\n");
+               TALLOC_FREE(frame);
+               exit(1);
+       }
 
        poptSetOtherOptionHelp(pc, "[OPTION...] <destination> <message-type> "
                               "<parameters>");
@@ -1768,8 +1785,6 @@ int main(int argc, const char **argv)
 
        evt_ctx = global_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. */ 
index 23c03cfdf5c1806b27787ad2eea2fc558eb90bf7..85bec26536e6dccb9eb5953a4de9885f9185c2cc 100644 (file)
@@ -20,7 +20,7 @@ bld.SAMBA3_BINARY('smbcontrol',
                  deps='''
                  talloc
                  smbconf
-                 popt_samba3
+                 CMDLINE_S3
                  cmdline_contexts
                  PRINTBASE''')