From: Andreas Schneider Date: Wed, 13 Jan 2021 12:28:11 +0000 (+0100) Subject: s3:utils: Migrate smbcontrol to new cmdline option parser X-Git-Tag: tevent-0.11.0~747 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=824c355ed786994e0b696c446edfb86e6a79d2c1;p=thirdparty%2Fsamba.git s3:utils: Migrate smbcontrol to new cmdline option parser Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c index 57c029b7e53..070e16b97f6 100644 --- a/source3/utils/smbcontrol.c +++ b/source3/utils/smbcontrol.c @@ -26,7 +26,7 @@ #include "includes.h" #include "system/filesys.h" #include "lib/util/server_id.h" -#include "popt_common.h" +#include "lib/cmdline/cmdline.h" #include "librpc/gen_ndr/spoolss.h" #include "nt_printing.h" #include "printing/notify.h" @@ -1703,7 +1703,7 @@ int main(int argc, const char **argv) struct tevent_context *evt_ctx; struct messaging_context *msg_ctx; - static struct poptOption long_options[] = { + struct poptOption long_options[] = { /* POPT_AUTOHELP */ { NULL, '\0', POPT_ARG_INCLUDE_TABLE, help_options, 0, "Help options:", NULL }, @@ -1711,20 +1711,37 @@ int main(int argc, const char **argv) "Set timeout value in seconds", "TIMEOUT" }, POPT_COMMON_SAMBA + POPT_COMMON_VERSION POPT_TABLEEND }; TALLOC_CTX *frame = talloc_stackframe(); int ret = 0; + bool ok; smb_init_locale(); - setup_logging(argv[0], DEBUG_STDOUT); + 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("log level", "0"); /* Parse command line arguments using popt */ - pc = poptGetContext( - "smbcontrol", argc, (const char **)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(frame); + exit(1); + } poptSetOtherOptionHelp(pc, "[OPTION...] " ""); @@ -1768,8 +1785,6 @@ int main(int argc, const char **argv) evt_ctx = global_event_context(); - lp_load_global(get_dyn_CONFIGFILE()); - /* Need to invert sense of return code -- samba * routines mostly return True==1 for success, but * shell needs 0. */ diff --git a/source3/utils/wscript_build b/source3/utils/wscript_build index 23c03cfdf5c..85bec26536e 100644 --- a/source3/utils/wscript_build +++ b/source3/utils/wscript_build @@ -20,7 +20,7 @@ bld.SAMBA3_BINARY('smbcontrol', deps=''' talloc smbconf - popt_samba3 + CMDLINE_S3 cmdline_contexts PRINTBASE''')