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

index 8fda19f800b87ad2151067fd2f033b75cceff269..87ced2425658b545b71db205c269ed1c14d944b2 100644 (file)
@@ -20,7 +20,7 @@
 */
 
 #include "includes.h"
-#include "popt_common_cmdline.h"
+#include "lib/cmdline/cmdline.h"
 #include "rpc_client/cli_pipe.h"
 #include "../librpc/gen_ndr/ndr_srvsvc_c.h"
 #include "libsmb/libsmb.h"
@@ -46,24 +46,20 @@ static void get_auth_data_with_context_fn(
        char *password,
        int password_len)
 {
-       struct user_auth_info *auth = popt_get_cmdline_auth_info();
+       struct cli_credentials *creds = samba_cmdline_get_creds();
        size_t len;
 
-       if (auth == NULL) {
-               return;
-       }
-
-       len = strlcpy(domain, get_cmdline_auth_info_domain(auth), domain_len);
+       len = strlcpy(domain, cli_credentials_get_domain(creds), domain_len);
        if ((int)len >= domain_len) {
                return;
        }
        len = strlcpy(
-               user, get_cmdline_auth_info_username(auth), user_len);
+               user, cli_credentials_get_username(creds), user_len);
        if ((int)len >= user_len) {
                return;
        }
        len = strlcpy(
-               password, get_cmdline_auth_info_password(auth), password_len);
+               password, cli_credentials_get_password(creds), password_len);
        if ((int)len >= password_len) {
                /* pointless, but what can you do... */
                return;
@@ -97,6 +93,7 @@ int main(int argc, char *argv[])
                },
                POPT_COMMON_SAMBA
                POPT_COMMON_CREDENTIALS
+               POPT_COMMON_VERSION
                POPT_TABLEEND
        };
        poptContext pc;
@@ -112,14 +109,28 @@ int main(int argc, char *argv[])
 
        setlinebuf(stdout);
 
-       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);
+       }
 
-       popt_common_credentials_set_ignore_missing_conf();
+       pc = samba_popt_get_context(getprogname(),
+                                   argc,
+                                   argv_const,
+                                   long_options,
+                                   POPT_CONTEXT_KEEP_FIRST);
+       if (pc == NULL) {
+               DBG_ERR("Failed to setup popt context!\n");
+               TALLOC_FREE(frame);
+               exit(1);
+       }
 
-       pc = poptGetContext("smbtree", argc, argv_const, long_options,
-                           POPT_CONTEXT_KEEP_FIRST);
        while(poptGetNextOpt(pc) != -1);
-       popt_burn_cmdline_password(argc, argv);
+       samba_cmdline_burn(argc, argv);
 
        debuglevel = DEBUGLEVEL;
 
@@ -254,8 +265,6 @@ int main(int argc, char *argv[])
                goto fail;
        }
 
-       popt_free_cmdline_auth_info();
-
        result = 0;
 fail:
        if (ctx != NULL) {
index 26cab64d3399011120cab55a1ef90e1c5e411f74..0683e9b17440f42c1e25bd0eed97516066c4ae63 100644 (file)
@@ -31,7 +31,7 @@ bld.SAMBA3_BINARY('smbtree',
                  smbconf
                  smbclient
                  msrpc3
-                 popt_samba3_cmdline
+                 CMDLINE_S3
                  RPC_NDR_SRVSVC''')
 
 bld.SAMBA3_BINARY('smbpasswd',