From: Andreas Schneider Date: Wed, 13 Jan 2021 08:28:34 +0000 (+0100) Subject: s3:utils: Migrate nmblookup to new cmdline option parser X-Git-Tag: tevent-0.11.0~760 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4a8a77c21d483331a09aaca95261666a6035897e;p=thirdparty%2Fsamba.git s3:utils: Migrate nmblookup to new cmdline option parser Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c index 325608d75e7..86902941746 100644 --- a/source3/utils/nmblookup.c +++ b/source3/utils/nmblookup.c @@ -20,7 +20,7 @@ */ #include "includes.h" -#include "popt_common.h" +#include "lib/cmdline/cmdline.h" #include "libsmb/nmblib.h" #include "libsmb/namequery.h" #include "lib/util/string_wrappers.h" @@ -241,6 +241,7 @@ int main(int argc, const char *argv[]) poptContext pc = NULL; TALLOC_CTX *frame = talloc_stackframe(); int rc = 0; + bool ok; struct poptOption long_options[] = { POPT_AUTOHELP @@ -319,6 +320,7 @@ int main(int argc, const char *argv[]) }, POPT_COMMON_SAMBA POPT_COMMON_CONNECTION + POPT_COMMON_VERSION POPT_TABLEEND }; @@ -326,10 +328,25 @@ int main(int argc, const char *argv[]) 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); + } - pc = poptGetContext("nmblookup", argc, argv, - long_options, POPT_CONTEXT_KEEP_FIRST); + pc = samba_popt_get_context(getprogname(), + argc, + argv, + long_options, + POPT_CONTEXT_KEEP_FIRST); + if (pc == NULL) { + DBG_ERR("Failed to setup popt context!\n"); + TALLOC_FREE(frame); + exit(1); + } poptSetOtherOptionHelp(pc, " ..."); @@ -383,12 +400,6 @@ int main(int argc, const char *argv[]) goto out; } - if (!lp_load_global(get_dyn_CONFIGFILE())) { - fprintf(stderr, "Can't load %s - run testparm to debug it\n", - get_dyn_CONFIGFILE()); - } - - load_interfaces(); if (!open_sockets()) { rc = 1; goto out; diff --git a/source3/utils/wscript_build b/source3/utils/wscript_build index 55ad6ee79db..1242a9f237e 100644 --- a/source3/utils/wscript_build +++ b/source3/utils/wscript_build @@ -67,7 +67,7 @@ bld.SAMBA3_BINARY('nmblookup', deps=''' talloc smbconf - popt_samba3 + CMDLINE_S3 LIBNMB''') bld.SAMBA3_BINARY('smbcacls',