s3:nmbd: Migrate nmbd to new cmdline option parser
authorAndreas Schneider <asn@samba.org>
Tue, 5 Jan 2021 13:28:53 +0000 (14:28 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 29 Apr 2021 03:58:37 +0000 (03:58 +0000)
This removes --log-stdout as we already have --debug-stdout in the
common options!

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/nmbd/nmbd.c
source3/nmbd/wscript_build

index dce746a833971da73e1dbe40a4d68cb610bfc2a9..2311ad8dde361b5ec8338dc94d5ebe4295ae740e 100644 (file)
@@ -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;
        }
 
index 843c900a4bafb25d43480a28e06f4a0797c2b068..22057dfb6b0e3dfe7bf208eb470e534cbb4b4af3 100644 (file)
@@ -35,6 +35,6 @@ bld.SAMBA3_BINARY('nmbd',
                  tevent
                  smbconf
                  libsmb
-                 popt_samba3
+                 CMDLINE_S3
                  ''',
                  install_path='${SBINDIR}')