s3:utils: Migrate sharesec to new cmdline option parser
authorAndreas Schneider <asn@samba.org>
Wed, 13 Jan 2021 12:40:26 +0000 (13:40 +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/sharesec.c
source3/utils/wscript_build

index 54e78634561e17b0060114e720b2b7539b52337d..cec1da1e94ddf1c4b8906451832f5d4501513715 100644 (file)
@@ -24,7 +24,7 @@
 struct cli_state;
 
 #include "includes.h"
-#include "popt_common.h"
+#include "lib/cmdline/cmdline.h"
 #include "../libcli/security/security.h"
 #include "passdb/machine_sid.h"
 #include "util_sd.h"
@@ -335,6 +335,7 @@ int main(int argc, const char *argv[])
        int snum;
        poptContext pc;
        bool initialize_sid = False;
+       bool ok;
        struct poptOption long_options[] = {
                POPT_AUTOHELP
                {
@@ -430,6 +431,7 @@ int main(int argc, const char *argv[])
                        .argDescrip = "ACLS",
                },
                POPT_COMMON_SAMBA
+               POPT_COMMON_VERSION
                POPT_TABLEEND
        };
 
@@ -438,14 +440,29 @@ int main(int argc, const char *argv[])
                return -1;
        }
 
-       /* set default debug level to 1 regardless of what smb.conf sets */
-       setup_logging( "sharesec", DEBUG_STDERR);
-
        smb_init_locale();
 
+       ok = samba_cmdline_init(ctx,
+                               SAMBA_CMDLINE_CONFIG_NONE,
+                               false /* require_smbconf */);
+       if (!ok) {
+               DBG_ERR("Failed to init cmdline parser!\n");
+               TALLOC_FREE(ctx);
+               exit(1);
+       }
+       /* set default debug level to 1 regardless of what smb.conf sets */
        lp_set_cmdline("log level", "1");
 
-       pc = poptGetContext("sharesec", argc, argv, long_options, 0);
+       pc = samba_popt_get_context(getprogname(),
+                                   argc,
+                                   argv,
+                                   long_options,
+                                   0);
+       if (pc == NULL) {
+               DBG_ERR("Failed to setup popt context!\n");
+               TALLOC_FREE(ctx);
+               exit(1);
+       }
 
        poptSetOtherOptionHelp(pc, "sharename\n");
 
index 640a7fde26093802efddcd30f493a288a750a034..b01d4d41b20c57b2050e68888a4525cb3bc11dd1 100644 (file)
@@ -103,7 +103,7 @@ bld.SAMBA3_BINARY('sharesec',
                  talloc
                  msrpc3
                  libcli_lsa3
-                 popt_samba3
+                 CMDLINE_S3
                  cmdline_contexts
                  ''')