From: Andreas Schneider Date: Wed, 13 Jan 2021 12:40:26 +0000 (+0100) Subject: s3:utils: Migrate sharesec to new cmdline option parser X-Git-Url: http://git.samba.org/samba.git/?a=commitdiff_plain;h=b41a0cd199dfc0e67664026b90ba3b5cb87e5c23;p=bbaumbach%2Fsamba-autobuild%2F.git s3:utils: Migrate sharesec to new cmdline option parser Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c index 54e78634561..cec1da1e94d 100644 --- a/source3/utils/sharesec.c +++ b/source3/utils/sharesec.c @@ -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"); diff --git a/source3/utils/wscript_build b/source3/utils/wscript_build index 640a7fde260..b01d4d41b20 100644 --- a/source3/utils/wscript_build +++ b/source3/utils/wscript_build @@ -103,7 +103,7 @@ bld.SAMBA3_BINARY('sharesec', talloc msrpc3 libcli_lsa3 - popt_samba3 + CMDLINE_S3 cmdline_contexts ''')