]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbd: Migrate smbd to new cmdline option parser
authorAndreas Schneider <asn@samba.org>
Tue, 5 Jan 2021 13:35:39 +0000 (14:35 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 29 Apr 2021 03:58:37 +0000 (03:58 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/smbd/server.c
source3/wscript_build

index 468bd21cf75400beb1fe6cbbf6df51899f94d59f..bb7820399cd91dd4b319988d48c8a81c051ac060 100644 (file)
@@ -25,7 +25,7 @@
 #include "system/filesys.h"
 #include "lib/util/server_id.h"
 #include "lib/util/close_low_fd.h"
-#include "popt_common.h"
+#include "lib/cmdline/cmdline.h"
 #include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
@@ -1624,6 +1624,7 @@ extern void build_options(bool screen);
                        .descrip    = "Set profiling level","PROFILE_LEVEL",
                },
                POPT_COMMON_SAMBA
+               POPT_COMMON_VERSION
                POPT_TABLEEND
        };
        struct smbd_parent_context *parent = NULL;
@@ -1654,6 +1655,7 @@ extern void build_options(bool screen);
                .exit_server = smbd_exit_server,
                .exit_server_cleanly = smbd_exit_server_cleanly,
        };
+       bool ok;
 
        /*
         * Do this before any other talloc operation
@@ -1661,8 +1663,6 @@ extern void build_options(bool screen);
        talloc_enable_null_tracking();
        frame = talloc_stackframe();
 
-       setup_logging(argv[0], DEBUG_DEFAULT_STDOUT);
-
        smb_init_locale();
 
        set_smbd_shim(&smbd_shim_fns);
@@ -1675,7 +1675,24 @@ extern void build_options(bool screen);
        set_auth_parameters(argc,argv);
 #endif
 
-       pc = poptGetContext("smbd", argc, argv, long_options, 0);
+       ok = samba_cmdline_init(frame,
+                               SAMBA_CMDLINE_CONFIG_SERVER,
+                               true /* require_smbconf */);
+       if (!ok) {
+               DBG_ERR("Failed to setup cmdline parser!\n");
+               exit(ENOMEM);
+       }
+
+       pc = samba_popt_get_context(getprogname(),
+                                   argc,
+                                   argv,
+                                   long_options,
+                                   0);
+       if (pc == NULL) {
+               DBG_ERR("Failed to get popt context!\n");
+               exit(ENOMEM);
+       }
+
        while((opt = poptGetNextOpt(pc)) != -1) {
                switch (opt)  {
                case OPT_DAEMON:
@@ -1750,7 +1767,6 @@ extern void build_options(bool screen);
        gain_root_privilege();
        gain_root_group_privilege();
 
-       fault_setup();
        dump_core_setup("smbd", lp_logfile(talloc_tos(), lp_sub));
 
        /* we are never interested in SIGPIPE */
@@ -1800,11 +1816,6 @@ extern void build_options(bool screen);
                exit(1);
        }
 
-       if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
-               DEBUG(0, ("error opening config file '%s'\n", get_dyn_CONFIGFILE()));
-               exit(1);
-       }
-
        /*
         * This calls unshare(CLONE_FS); on linux
         * in order to check if the running kernel/container
@@ -2132,11 +2143,11 @@ extern void build_options(bool screen);
 
                if (serving_printers) {
                        bool bgq = lp_parm_bool(-1, "smbd", "backgroundqueue", true);
-                       bool ok = printing_subsystem_init(ev_ctx,
-                                                         msg_ctx,
-                                                         dce_ctx,
-                                                         true,
-                                                         bgq);
+                       ok = printing_subsystem_init(ev_ctx,
+                                                    msg_ctx,
+                                                    dce_ctx,
+                                                    true,
+                                                    bgq);
                        if (!ok) {
                                exit_daemon("Samba failed to init printing subsystem", EACCES);
                        }
@@ -2149,11 +2160,11 @@ extern void build_options(bool screen);
                }
 #endif
        } else if (serving_printers) {
-               bool ok = printing_subsystem_init(ev_ctx,
-                                                 msg_ctx,
-                                                 dce_ctx,
-                                                 false,
-                                                 false);
+               ok = printing_subsystem_init(ev_ctx,
+                                            msg_ctx,
+                                            dce_ctx,
+                                            false,
+                                            false);
                if (!ok) {
                        exit(1);
                }
index a1e91d532b111238d50d0e72219fe829f2904bd7..6eea00acd6965220910ee35af2fda7918c769303 100644 (file)
@@ -1101,7 +1101,7 @@ bld.SAMBA3_SUBSYSTEM('fd_handle',
 bld.SAMBA3_BINARY('smbd/smbd',
                  source='smbd/server.c smbd/smbd_cleanupd.c',
                  deps='''
-                      popt_samba3
+                      CMDLINE_S3
                       smbd_base
                       EPMD
                       LSASD