summaryrefslogtreecommitdiff
path: root/source3/rpc_server/rpc_config.c
diff options
context:
space:
mode:
authorSamuel Cabrero <scabrero@suse.de>2019-10-30 17:00:05 +0100
committerSamuel Cabrero <scabrero@sn-devel-184>2020-03-20 15:36:32 +0000
commit20542bcfa9ba7b722e569a8ffbd4bfb41963349e (patch)
tree58d8ce84b32f3a2336fd7359078d0ec777ab027b /source3/rpc_server/rpc_config.c
parented02614edb46359d74adb8bfd144216f877610ff (diff)
downloadsamba-20542bcfa9ba7b722e569a8ffbd4bfb41963349e.tar.gz
s3:rpc_server: Add global dcesrv_context init and shutdown functions
Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source3/rpc_server/rpc_config.c')
-rw-r--r--source3/rpc_server/rpc_config.c43
1 files changed, 43 insertions, 0 deletions
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