examples: Migrate smb2mount to new cmdline option parser
authorAndreas Schneider <asn@samba.org>
Wed, 13 Jan 2021 13:49:07 +0000 (14:49 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 28 May 2021 02:55:31 +0000 (02:55 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
examples/fuse/smb2mount.c
examples/fuse/wscript_build

index c27f442ad76bf6aee4f21bcd9ab6aae75a3e1350..7133927ad16e9606e0a68d3de1f19ac07cfd48a6 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "source3/include/includes.h"
 #include "popt.h"
-#include "popt_common_cmdline.h"
+#include "lib/cmdline/cmdline.h"
 #include "client.h"
 #include "libsmb/proto.h"
 #include "clifuse.h"
@@ -57,6 +57,7 @@ int main(int argc, char *argv[])
        char *unc, *mountpoint, *server, *share;
        struct cli_state *cli;
        struct cli_credentials *creds = NULL;
+       bool ok;
 
        struct poptOption long_options[] = {
                POPT_AUTOHELP
@@ -68,14 +69,29 @@ int main(int argc, char *argv[])
        };
 
        smb_init_locale();
-       setup_logging(argv[0], DEBUG_STDERR);
+
+       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("client min protocol", "SMB2");
        lp_set_cmdline("client max protocol", "SMB3_11");
 
-       lp_load_global(get_dyn_CONFIGFILE());
-       load_interfaces();
+       pc = samba_popt_get_context(getprogname(),
+                                   argc,
+                                   argv_const,
+                                   long_options,
+                                   0);
+       if (pc == NULL) {
+               DBG_ERR("Failed to setup popt context!\n");
+               TALLOC_FREE(frame);
+               exit(1);
+       }
 
-       pc = poptGetContext("smb2mount", argc, argv_const, long_options, 0);
        poptSetOtherOptionHelp(pc, "//server1/share1 mountpoint");
 
        while ((opt = poptGetNextOpt(pc)) != -1) {
@@ -108,7 +124,7 @@ int main(int argc, char *argv[])
        }
 
        poptFreeContext(pc);
-       popt_burn_cmdline_password(argc, argv);
+       samba_cmdline_burn(argc, argv);
 
        server = talloc_strdup(frame, unc+2);
        if (!server) {
@@ -136,7 +152,6 @@ int main(int argc, char *argv[])
                return -1;
        }
 
-       popt_free_cmdline_auth_info();
        TALLOC_FREE(frame);
        return 0;
 }
index 31341e4357d1513b4b45214649ce8f87cced5788..ceef925f65c601cfdf4b0c9a721fbc73cd88c41a 100644 (file)
@@ -3,5 +3,5 @@
 if bld.env.HAVE_FUSE:
     bld.SAMBA_BINARY('smb2mount',
                      source='smb2mount.c clifuse.c',
-                     deps='smbconf popt_samba3_cmdline libsmb fuse',
+                     deps='smbconf CMDLINE_S3 libsmb fuse',
                      install=False)