1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

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>
This commit is contained in:
Samuel Cabrero 2019-10-30 17:00:05 +01:00 committed by Samuel Cabrero
parent ed02614edb
commit 20542bcfa9
2 changed files with 47 additions and 0 deletions

View File

@ -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

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