mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
librpc:core: Add public functions to initialize endpoint servers
The dcesrv_init_registered_ep_servers() will be used by the S3 server to initialize all registered endpoint servers (for embedded services), and the dcesrv_init_ep_server() function will be used by the external daemons to initialize the required ones. As serveral S3 services may require to initialize another one before itself (svcctl and eventlog for example require winreg) a boolean flag is added to track the initialization status. Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
39dfc5c82b
commit
90eb485cf9
@ -2361,18 +2361,10 @@ _PUBLIC_ NTSTATUS dcesrv_init_ep_servers(struct dcesrv_context *dce_ctx,
|
||||
}
|
||||
|
||||
for (i=0;endpoint_servers[i];i++) {
|
||||
const struct dcesrv_endpoint_server *ep_server;
|
||||
|
||||
ep_server = dcesrv_ep_server_byname(endpoint_servers[i]);
|
||||
if (!ep_server) {
|
||||
DEBUG(0,("dcesrv_init_context: failed to find endpoint server = '%s'\n", endpoint_servers[i]));
|
||||
return NT_STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
status = ep_server->init_server(dce_ctx, ep_server);
|
||||
status = dcesrv_init_ep_server(dce_ctx, endpoint_servers[i]);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0,("dcesrv_init_context: failed to init endpoint server = '%s': %s\n", endpoint_servers[i],
|
||||
nt_errstr(status)));
|
||||
DBG_ERR("failed to init endpoint server = '%s': %s\n",
|
||||
endpoint_servers[i], nt_errstr(status));
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@ -2387,6 +2379,53 @@ static struct ep_server {
|
||||
} *ep_servers = NULL;
|
||||
static int num_ep_servers = 0;
|
||||
|
||||
_PUBLIC_ NTSTATUS dcesrv_init_registered_ep_servers(
|
||||
struct dcesrv_context *dce_ctx)
|
||||
{
|
||||
NTSTATUS status;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num_ep_servers; i++) {
|
||||
status = dcesrv_init_ep_server(dce_ctx,
|
||||
ep_servers[i].ep_server->name);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
_PUBLIC_ NTSTATUS dcesrv_init_ep_server(struct dcesrv_context *dce_ctx,
|
||||
const char *ep_server_name)
|
||||
{
|
||||
struct dcesrv_endpoint_server *ep_server = NULL;
|
||||
NTSTATUS status;
|
||||
|
||||
ep_server = discard_const_p(struct dcesrv_endpoint_server,
|
||||
dcesrv_ep_server_byname(ep_server_name));
|
||||
if (ep_server == NULL) {
|
||||
DBG_ERR("Failed to find endpoint server '%s'\n",
|
||||
ep_server_name);
|
||||
return NT_STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
if (ep_server->initialized) {
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
status = ep_server->init_server(dce_ctx, ep_server);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DBG_ERR("Failed to init endpoint server '%s': %s\n",
|
||||
ep_server_name, nt_errstr(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
ep_server->initialized = true;
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
register a DCERPC endpoint server.
|
||||
|
||||
|
@ -325,6 +325,9 @@ struct dcesrv_endpoint_server {
|
||||
/* this is the name of the endpoint server */
|
||||
const char *name;
|
||||
|
||||
/* true if the endpoint server has been initialized */
|
||||
bool initialized;
|
||||
|
||||
/* this function should register endpoints and some other setup stuff,
|
||||
* it is called when the dcesrv_context gets initialized.
|
||||
*/
|
||||
@ -446,6 +449,9 @@ NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
|
||||
NTSTATUS dcerpc_register_ep_server(const struct dcesrv_endpoint_server *ep_server);
|
||||
NTSTATUS dcesrv_init_ep_servers(struct dcesrv_context *dce_ctx,
|
||||
const char **ep_servers);
|
||||
NTSTATUS dcesrv_init_registered_ep_servers(struct dcesrv_context *dce_ctx);
|
||||
NTSTATUS dcesrv_init_ep_server(struct dcesrv_context *dce_ctx,
|
||||
const char *ep_server_name);
|
||||
const struct dcesrv_endpoint_server *dcesrv_ep_server_byname(const char *name);
|
||||
|
||||
NTSTATUS dcesrv_init_context(TALLOC_CTX *mem_ctx,
|
||||
|
@ -268,6 +268,9 @@ NTSTATUS dcerpc_server_$name\_init(TALLOC_CTX *ctx)
|
||||
/* fill in our name */
|
||||
.name = \"$name\",
|
||||
|
||||
/* Initialization flag */
|
||||
.initialized = false,
|
||||
|
||||
/* fill in all the operations */
|
||||
#ifdef DCESRV_INTERFACE_$uname\_INIT_SERVER
|
||||
.init_server = DCESRV_INTERFACE_$uname\_INIT_SERVER,
|
||||
|
@ -496,6 +496,8 @@ NTSTATUS dcerpc_server_remote_init(TALLOC_CTX *ctx)
|
||||
/* fill in our name */
|
||||
.name = "remote",
|
||||
|
||||
.initialized = false,
|
||||
|
||||
/* fill in all the operations */
|
||||
.init_server = remote_op_init_server,
|
||||
|
||||
|
@ -458,6 +458,8 @@ static bool test_start_dcerpc_server(struct torture_context *tctx,
|
||||
/* fill in our name */
|
||||
ep_server.name = "spoolss";
|
||||
|
||||
ep_server.initialized = false;
|
||||
|
||||
/* fill in all the operations */
|
||||
ep_server.init_server = spoolss__op_init_server;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user