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

index f1cdc78d29eb7fed4b0b1280fcea6523d9b93faa..7a6d939cae77d6176a7dbf2b14ee3a6ee851647a 100644 (file)
@@ -21,7 +21,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"
@@ -243,6 +243,7 @@ int main(int argc, const char *argv[])
                { "db-name", 'N', POPT_ARG_STRING, &db_name, 0, "name of the test db", "NAME" },
                { "no-trans", 'n', POPT_ARG_NONE, &no_trans, 0, "use fetch_lock/record store instead of transactions", NULL },
                { "unsafe-writes", 'u', POPT_ARG_NONE, &unsafe_writes, 0, "do not use tdb transactions when writing", NULL },
+               POPT_COMMON_VERSION
                POPT_TABLEEND
        };
        int opt;
@@ -250,7 +251,7 @@ int main(int argc, const char *argv[])
        int extra_argc = 0;
        poptContext pc;
        int tdb_flags;
-
+       bool ok;
        int ret = 1;
 
        mem_ctx = talloc_stackframe();
@@ -263,10 +264,26 @@ int main(int argc, const char *argv[])
 
        smb_init_locale();
 
-       setup_logging(argv[0], DEBUG_STDERR);
+       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);
+       }
        lp_set_cmdline("log level", "0");
 
-       pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST);
+       pc = samba_popt_get_context(getprogname(),
+                                   argc,
+                                   argv,
+                                   popt_options,
+                                   POPT_CONTEXT_KEEP_FIRST);
+       if (pc == NULL) {
+               DBG_ERR("Failed to setup popt context!\n");
+               TALLOC_FREE(mem_ctx);
+               exit(1);
+       }
 
        while ((opt = poptGetNextOpt(pc)) != -1) {
                switch (opt) {
@@ -284,8 +301,6 @@ int main(int argc, const char *argv[])
                while (extra_argv[extra_argc]) extra_argc++;
        }
 
-       lp_load_global(get_dyn_CONFIGFILE());
-
        ev_ctx = samba_tevent_context_init(mem_ctx);
        if (ev_ctx == NULL) {
                d_fprintf(stderr, "ERROR: could not init event context\n");
index 736807ceda6366d21d3ad182933a79b1d86f2784..23c03cfdf5c1806b27787ad2eea2fc558eb90bf7 100644 (file)
@@ -143,7 +143,9 @@ bld.SAMBA3_BINARY('dbwrap_torture',
                  source='dbwrap_torture.c',
                  deps='''
                  talloc
-                 popt_samba3''',
+                 CMDLINE_S3
+                 smbconf
+                 ''',
                  install=False)
 
 bld.SAMBA3_BINARY('split_tokens',