]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:rpc_server: Add global dcesrv_context init and shutdown functions
authorSamuel Cabrero <scabrero@suse.de>
Wed, 30 Oct 2019 16:00:05 +0000 (17:00 +0100)
committerSamuel Cabrero <scabrero@sn-devel-184>
Fri, 20 Mar 2020 15:36:32 +0000 (15:36 +0000)
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/rpc_server/rpc_config.c
source3/rpc_server/rpc_config.h

index eed16c7bd69c43e3a84434ea44ac552a0ac7e147..1a436981e2f24bf0dc847a8c62e8c1c41cc48a7f 100644 (file)
 
 #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
index 50917042fe66125d3ec90c1c3c5779bf29114da0..ee597ad4d6aad1b3c297a65c93837167ba0356d8 100644 (file)
@@ -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 */