]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:utils: Migrate dbwrap_tool to new cmdline option parser
authorAndreas Schneider <asn@samba.org>
Wed, 13 Jan 2021 08:16:31 +0000 (09:16 +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/dbwrap_tool.c
source3/utils/wscript_build

index 5d4791473a0ad2dde4d90aed6ba67477f3dc6bba..3c7f39854c8df7392cdd5399ea125437a9a5bc8c 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "includes.h"
 #include "system/filesys.h"
-#include "popt_common.h"
+#include "lib/cmdline/cmdline.h"
 #include "dbwrap/dbwrap.h"
 #include "dbwrap/dbwrap_open.h"
 #include "messages.h"
@@ -382,6 +382,7 @@ int main(int argc, const char **argv)
        TALLOC_CTX *mem_ctx = talloc_stackframe();
 
        int ret = 1;
+       bool ok;
 
        struct poptOption popt_options[] = {
                POPT_AUTOHELP
@@ -393,6 +394,7 @@ int main(int argc, const char **argv)
                { "persistent", 0, POPT_ARG_NONE, &persistent, 0,
                  "treat the database as persistent",
                  NULL },
+               POPT_COMMON_VERSION
                POPT_TABLEEND
        };
        int opt;
@@ -401,10 +403,29 @@ int main(int argc, const char **argv)
        poptContext pc;
 
        smb_init_locale();
+
+       setup_logging(argv[0], DEBUG_DEFAULT_STDERR);
        lp_set_cmdline("log level", "0");
-       setup_logging(argv[0], DEBUG_STDERR);
 
-       pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST);
+       ok = samba_cmdline_init(mem_ctx,
+                               SAMBA_CMDLINE_CONFIG_CLIENT,
+                               false /* require_smbconf */);
+       if (!ok) {
+               DBG_ERR("Failed to init cmdline parser!\n");
+               TALLOC_FREE(mem_ctx);
+               exit(1);
+       }
+
+       pc = samba_popt_get_context(getprogname(),
+                                   argc,
+                                   argv,
+                                   popt_options,
+                                   POPT_CONTEXT_KEEP_FIRST);
+       if (!ok) {
+               DBG_ERR("Failed to setup popt context!\n");
+               TALLOC_FREE(mem_ctx);
+               exit(1);
+       }
 
        while ((opt = poptGetNextOpt(pc)) != -1) {
                switch (opt) {
@@ -422,8 +443,6 @@ int main(int argc, const char **argv)
                while (extra_argv[extra_argc]) extra_argc++;
        }
 
-       lp_load_global(get_dyn_CONFIGFILE());
-
        if ((extra_argc < 2) || (extra_argc > 5)) {
                d_fprintf(stderr,
                          "USAGE: %s [options] <database> <op> [<key> [<type> "
index c28fd862b3a5bd48e7098d0e7bea2d0b65d5b694..55ad6ee79db6868a9871fcc9d90d9c1160ca9c9b 100644 (file)
@@ -135,7 +135,7 @@ bld.SAMBA3_BINARY('dbwrap_tool',
                  source='dbwrap_tool.c',
                  deps='''
                  talloc
-                 popt_samba3
+                 CMDLINE_S3
                  cmdline_contexts
                  ''')