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

index e2dfcccddd77d6388110c92e5e3e978fad2ead79..a2d6b6c849d6cc36606d30317377eb9f6625ab6f 100644 (file)
@@ -23,7 +23,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_lsa.h"
 #include "rpc_client/cli_lsarpc.h"
@@ -1572,6 +1572,7 @@ int main(int argc, char *argv[])
        struct cli_credentials *creds = NULL;
        char *targetfile = NULL;
        NTSTATUS status;
+       bool ok;
 
        struct poptOption long_options[] = {
                POPT_AUTOHELP
@@ -1693,15 +1694,6 @@ int main(int argc, char *argv[])
                        .val        = 0,
                        .descrip    = "Domain SID for sddl",
                        .argDescrip = "SID"},
-               {
-                       .longName   = "max-protocol",
-                       .shortName  = 'm',
-                       .argInfo    = POPT_ARG_STRING,
-                       .arg        = NULL,
-                       .val        = 'm',
-                       .descrip    = "Set the max protocol level",
-                       .argDescrip = "LEVEL",
-               },
                {
                        .longName   = "maximum-access",
                        .shortName  = 'x',
@@ -1713,6 +1705,8 @@ int main(int argc, char *argv[])
                POPT_COMMON_SAMBA
                POPT_COMMON_CONNECTION
                POPT_COMMON_CREDENTIALS
+               POPT_LEGACY_S3
+               POPT_COMMON_VERSION
                POPT_TABLEEND
        };
 
@@ -1723,15 +1717,29 @@ int main(int argc, char *argv[])
 
        smb_init_locale();
 
+       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);
+       }
        /* set default debug level to 1 regardless of what smb.conf sets */
-       setup_logging( "smbcacls", DEBUG_STDERR);
        lp_set_cmdline("log level", "1");
 
        setlinebuf(stdout);
 
-       popt_common_credentials_set_ignore_missing_conf();
-
-       pc = poptGetContext("smbcacls", argc, argv_const, long_options, 0);
+       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);
+       }
 
        poptSetOtherOptionHelp(pc, "//server1/share1 filename\nACLs look like: "
                "'ACL:user:[ALLOWED|DENIED]/flags/permissions'");
@@ -1806,8 +1814,7 @@ int main(int argc, char *argv[])
        }
 
        poptFreeContext(pc);
-       popt_burn_cmdline_password(argc, argv);
-       popt_common_credentials_post();
+       samba_cmdline_burn(argc, argv);
 
        string_replace(path,'/','\\');
 
@@ -1824,7 +1831,7 @@ int main(int argc, char *argv[])
        *share = 0;
        share++;
 
-       creds = get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
+       creds = samba_cmdline_get_creds();
 
        /* Make connection to server */
        if (!test_args) {
@@ -1833,7 +1840,6 @@ int main(int argc, char *argv[])
                        exit(EXIT_FAILED);
                }
        } else {
-               popt_free_cmdline_auth_info();
                exit(0);
        }
 
@@ -1886,7 +1892,6 @@ int main(int argc, char *argv[])
                result = cacl_dump(targetcli, targetfile, numeric);
        }
 
-       popt_free_cmdline_auth_info();
        TALLOC_FREE(frame);
 
        return result;
index 68563f90444d28eaf597aff3b6adcddd6bbc240a..8d4616e50f7132f80798612da7948b3ad51b4662 100644 (file)
@@ -74,7 +74,7 @@ bld.SAMBA3_BINARY('smbcacls',
                  source='smbcacls.c ../lib/util_sd.c',
                  deps='''
                  talloc
-                 popt_samba3_cmdline
+                 CMDLINE_S3
                  msrpc3
                  libcli_lsa3
                  krb5samba''')