]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:samba: split out a samba_service_init() helper function
authorStefan Metzmacher <metze@samba.org>
Fri, 27 Aug 2021 11:06:00 +0000 (13:06 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 30 Nov 2021 16:44:57 +0000 (16:44 +0000)
The loading function should be in the same SAMBA_LIBRARY()
as the modules.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Nov 30 16:44:57 UTC 2021 on sn-devel-184

source4/samba/server.c
source4/samba/service.c
source4/samba/service.h

index d8948337847d0a0949ba4bcfbcf9878b64562d17..2915cd327c2cad3d1993a929c03cea5562aebf33 100644 (file)
@@ -40,7 +40,6 @@
 #include "librpc/gen_ndr/ndr_irpc.h"
 #include "cluster/cluster.h"
 #include "dynconfig/dynconfig.h"
-#include "lib/util/samba_modules.h"
 #include "nsswitch/winbind_client.h"
 #include "libds/common/roles.h"
 #include "lib/util/tfork.h"
@@ -510,10 +509,6 @@ static int binary_smbd_main(TALLOC_CTX *mem_ctx,
        int opt;
        int ret;
        poptContext pc;
-#define _MODULE_PROTO(init) extern NTSTATUS init(TALLOC_CTX *);
-       STATIC_service_MODULES_PROTO;
-       init_module_fn static_init[] = { STATIC_service_MODULES };
-       init_module_fn *shared_init;
        uint16_t stdin_event_flags;
        NTSTATUS status;
        const char *model = "prefork";
@@ -705,12 +700,7 @@ static int binary_smbd_main(TALLOC_CTX *mem_ctx,
 
        process_model_init(lp_ctx);
 
-       shared_init = load_samba_modules(mem_ctx, "service");
-
-       run_init_functions(mem_ctx, static_init);
-       run_init_functions(mem_ctx, shared_init);
-
-       TALLOC_FREE(shared_init);
+       samba_service_init();
 
        /* the event context is the top level structure in smbd. Everything else
           should hang off that */
index f801e4c8eaba9673f1fa05ec7c8cbc2f1171ce00..2ad6c8f371592bb928767caecfe00635b15e7ffe 100644 (file)
@@ -23,6 +23,7 @@
 #include "includes.h"
 #include "../lib/util/dlinklist.h"
 #include "samba/process_model.h"
+#include "lib/util/samba_modules.h"
 
 #undef strcasecmp
 
@@ -114,3 +115,26 @@ NTSTATUS server_service_startup(struct tevent_context *event_ctx,
 
        return NT_STATUS_OK;
 }
+
+_PUBLIC_ NTSTATUS samba_service_init(void)
+{
+#define _MODULE_PROTO(init) extern NTSTATUS init(TALLOC_CTX *);
+       STATIC_service_MODULES_PROTO;
+       init_module_fn static_init[] = { STATIC_service_MODULES };
+       init_module_fn *shared_init = NULL;
+       static bool initialised;
+
+       if (initialised) {
+               return NT_STATUS_OK;
+       }
+       initialised = true;
+
+       shared_init = load_samba_modules(NULL, "service");
+
+       run_init_functions(NULL, static_init);
+       run_init_functions(NULL, shared_init);
+
+       TALLOC_FREE(shared_init);
+
+       return NT_STATUS_OK;
+}
index 88d2478dfe560deee25be8e5bc28fefe4f65fa9a..7649101b97b077d2ea4c1431b1d032065d4e317a 100644 (file)
@@ -75,6 +75,8 @@ struct service_details {
        void (*post_fork) (struct task_server *, struct process_details *);
 };
 
+NTSTATUS samba_service_init(void);
+
 #include "samba/service_proto.h"
 
 #endif /* __SERVICE_H__ */