1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

s4:samba: split out a samba_service_init() helper function

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
This commit is contained in:
Stefan Metzmacher 2021-08-27 13:06:00 +02:00
parent 5d295e41af
commit ccfefe2890
3 changed files with 27 additions and 11 deletions

View 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 */

View 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;
}

View 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__ */