]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:torture: Migrate masktest to new cmdline option parser
authorAndreas Schneider <asn@samba.org>
Thu, 17 Dec 2020 16:12:10 +0000 (17:12 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 16 Jun 2021 00:34:38 +0000 (00:34 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/torture/masktest.c
source4/torture/wscript_build

index 35ec2e9d040eee934e2e73a1c906a7e92276fd7f..d29d18485f7eafff0a9995fba57c00851ecfcca9 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/cmdline/popt_common.h"
+#include "lib/cmdline/cmdline.h"
 #include "system/filesys.h"
 #include "system/dir.h"
 #include "libcli/libcli.h"
@@ -83,6 +83,7 @@ static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx,
        struct smbcli_state *c;
        char *server;
        NTSTATUS status;
+       struct cli_credentials *creds = samba_cmdline_get_creds();
 
        server = talloc_strdup(mem_ctx, share+2);
        share = strchr_m(server,'\\');
@@ -90,7 +91,7 @@ static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx,
        *share = 0;
        share++;
 
-       cli_credentials_set_workstation(popt_get_cmdline_credentials(),
+       cli_credentials_set_workstation(creds,
                        "masktest", CRED_SPECIFIED);
 
        status = smbcli_full_connection(NULL, &c,
@@ -98,7 +99,7 @@ static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx,
                                        ports,
                                        share, NULL,
                                        socket_options,
-                                       popt_get_cmdline_credentials(),
+                                       creds,
                                        resolve_ctx, ev,
                                        options, session_options,
                                        gensec_settings);
@@ -317,8 +318,10 @@ int main(int argc, const char *argv[])
                POPT_COMMON_CONNECTION
                POPT_COMMON_CREDENTIALS
                POPT_COMMON_VERSION
-               {0}
+               POPT_LEGACY_S4
+               POPT_TABLEEND
        };
+       bool ok;
 
        setlinebuf(stdout);
        seed = time(NULL);
@@ -328,15 +331,34 @@ int main(int argc, const char *argv[])
                exit(1);
        }
 
-       pc = poptGetContext("locktest", argc, argv, long_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");
+               exit(1);
+       }
+
+       pc = samba_popt_get_context(getprogname(),
+                                   argc,
+                                   argv,
+                                   long_options,
+                                   POPT_CONTEXT_KEEP_FIRST);
+       if (pc == NULL) {
+               DBG_ERR("Failed to setup popt context!\n");
+               exit(1);
+       }
 
        poptSetOtherOptionHelp(pc, "<unc>");
 
+       lp_ctx = samba_cmdline_get_lp_ctx();
+
        while((opt = poptGetNextOpt(pc)) != -1) {
                switch (opt) {
                case OPT_UNCLIST:
-                       lpcfg_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc));
+                       lpcfg_set_cmdline(lp_ctx,
+                                         "torture:unclist",
+                                         poptGetOptArg(pc));
                        break;
                }
        }
@@ -362,8 +384,6 @@ int main(int argc, const char *argv[])
 
        all_string_sub(share,"/","\\",0);
 
-       lp_ctx = cmdline_lp_ctx;
-
        ev = s4_event_context_init(mem_ctx);
 
        gensec_init();
index 2f1a1cfa7b5914d62a03fe079f4b0283585018cf..5c1e12867f39a198f48b8982f045974f0ba303e0 100644 (file)
@@ -338,7 +338,7 @@ bld.SAMBA_BINARY('gentest',
 bld.SAMBA_BINARY('masktest',
        source='masktest.c',
        manpages='man/masktest.1',
-       deps='samba-hostconfig samba-util popt POPT_SAMBA POPT_CREDENTIALS LIBCLI_SMB param_options'
+       deps='samba-hostconfig samba-util popt CMDLINE_S4 LIBCLI_SMB param_options'
        )