From: Samuel Cabrero Date: Wed, 30 Oct 2019 16:00:05 +0000 (+0100) Subject: s3:rpc_server: Add global dcesrv_context init and shutdown functions X-Git-Tag: ldb-2.2.0~1358 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20542bcfa9ba7b722e569a8ffbd4bfb41963349e;p=thirdparty%2Fsamba.git s3:rpc_server: Add global dcesrv_context init and shutdown functions Signed-off-by: Samuel Cabrero Reviewed-by: Andrew Bartlett --- diff --git a/source3/rpc_server/rpc_config.c b/source3/rpc_server/rpc_config.c index eed16c7bd69..1a436981e2f 100644 --- a/source3/rpc_server/rpc_config.c +++ b/source3/rpc_server/rpc_config.c @@ -20,10 +20,53 @@ #include "includes.h" #include "rpc_server/rpc_config.h" +#include "rpc_server/rpc_server.h" +#include "lib/param/param.h" +#include "librpc/rpc/dcesrv_core.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +static struct dcesrv_context *global_dcesrv_ctx = NULL; + +struct dcesrv_context *global_dcesrv_context(void) +{ + NTSTATUS status; + + if (global_dcesrv_ctx == NULL) { + struct loadparm_context *lp_ctx = NULL; + + DBG_INFO("Initializing DCE/RPC server context\n"); + + lp_ctx = loadparm_init_s3(NULL, loadparm_s3_helpers()); + if (lp_ctx == NULL) { + smb_panic("No memory"); + } + + /* + * Note we MUST use the NULL context here, not the + * autofree context, to avoid side effects in forked + * children exiting. + */ + status = dcesrv_init_context(global_event_context(), + lp_ctx, + NULL, + &global_dcesrv_ctx); + if (!NT_STATUS_IS_OK(status)) { + smb_panic("Failed to init DCE/RPC context"); + } + + talloc_steal(global_dcesrv_ctx, lp_ctx); + } + + return global_dcesrv_ctx; +} + +void global_dcesrv_context_free(void) +{ + TALLOC_FREE(global_dcesrv_ctx); +} + /* the default is "embedded" so this table * lists only services that are not using * the default in order to keep enumerating it diff --git a/source3/rpc_server/rpc_config.h b/source3/rpc_server/rpc_config.h index 50917042fe6..ee597ad4d6a 100644 --- a/source3/rpc_server/rpc_config.h +++ b/source3/rpc_server/rpc_config.h @@ -69,4 +69,8 @@ enum rpc_daemon_type_e rpc_daemon_type(const char *name); #define rpc_fss_daemon() rpc_daemon_type("fssd") #define rpc_mdssd_daemon() rpc_daemon_type("mdssd") +struct dcesrv_context; +struct dcesrv_context *global_dcesrv_context(void); +void global_dcesrv_context_free(void); + #endif /* _RPC_CONFIG_H */