From 87927173e85712c458cf7d0582da14dd2959d2ac Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 5 Jan 2021 14:28:53 +0100 Subject: [PATCH] s3:nmbd: Migrate nmbd to new cmdline option parser This removes --log-stdout as we already have --debug-stdout in the common options! Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- source3/nmbd/nmbd.c | 33 +++++++++++++++++++++++---------- source3/nmbd/wscript_build | 2 +- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index dce746a8339..2311ad8dde3 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -21,7 +21,7 @@ #include "includes.h" #include "system/filesys.h" -#include "popt_common.h" +#include "lib/cmdline/cmdline.h" #include "nmbd/nmbd.h" #include "serverid.h" #include "messages.h" @@ -847,6 +847,7 @@ static bool open_sockets(bool isdaemon, int port) .descrip = "Listen on the specified port", }, POPT_COMMON_SAMBA + POPT_COMMON_VERSION POPT_TABLEEND }; const struct loadparm_substitution *lp_sub = @@ -867,13 +868,30 @@ static bool open_sockets(bool isdaemon, int port) */ umask(0); - setup_logging(argv[0], DEBUG_DEFAULT_STDOUT); - smb_init_locale(); + ok = samba_cmdline_init(frame, + SAMBA_CMDLINE_CONFIG_SERVER, + true /* require_smbconf */); + if (!ok) { + DBG_ERR("Failed to init cmdline parser!\n"); + TALLOC_FREE(frame); + exit(ENOMEM); + } + global_nmb_port = NMB_PORT; - pc = poptGetContext("nmbd", 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(frame); + exit(1); + } + while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case OPT_DAEMON: @@ -915,7 +933,6 @@ static bool open_sockets(bool isdaemon, int port) SAFE_FREE(lfile); } - fault_setup(); dump_core_setup("nmbd", lp_logfile(talloc_tos(), lp_sub)); /* POSIX demands that signals are inherited. If the invoking process has @@ -958,11 +975,6 @@ static bool open_sockets(bool isdaemon, int port) DEBUG(0,("nmbd version %s started.\n", samba_version_string())); DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE)); - if (!lp_load_initial_only(get_dyn_CONFIGFILE())) { - DEBUG(0, ("error opening config file '%s'\n", get_dyn_CONFIGFILE())); - exit(1); - } - reopen_logs(); if (lp_server_role() == ROLE_ACTIVE_DIRECTORY_DC @@ -981,6 +993,7 @@ static bool open_sockets(bool isdaemon, int port) msg = messaging_init(NULL, global_event_context()); if (msg == NULL) { + DBG_ERR("Failed to init messaging context!\n"); return 1; } diff --git a/source3/nmbd/wscript_build b/source3/nmbd/wscript_build index 843c900a4ba..22057dfb6b0 100644 --- a/source3/nmbd/wscript_build +++ b/source3/nmbd/wscript_build @@ -35,6 +35,6 @@ bld.SAMBA3_BINARY('nmbd', tevent smbconf libsmb - popt_samba3 + CMDLINE_S3 ''', install_path='${SBINDIR}') -- 2.47.3