1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

s3:rpc_server: Add a function to setup the endpoints

The pidl-generated initialization function for each endpoint server will
register the RPC interface in all endpoints defined in the idl file.

The interface registration code will create the endpoint if it does not
exists (as an endpoint can serve multiple interfaces) and will add it to
the endpoint list exiting in the dcesrv_context.

This commit adds a generic dcesrv_setup_endpoint_sockets function which
will be used by embedded services and non-preforking external daemons to
setup the sockets regardless the transport.

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Samuel Cabrero 2019-02-27 14:01:11 +01:00 committed by Samuel Cabrero
parent 4e7670ed12
commit c97a77297d
3 changed files with 84 additions and 4 deletions

View File

@ -22,9 +22,10 @@
#include "librpc/rpc/rpc_common.h" /* For enum dcerpc_transport_t */
#include "librpc/rpc/dcesrv_core.h"
struct pipes_struct;
struct auth_session_info;
struct dcesrv_call_state;
struct cli_credentials;
typedef void (*dcerpc_ncacn_termination_fn)(struct pipes_struct *, void *);

View File

@ -115,6 +115,77 @@ NTSTATUS rpc_setup_embedded(struct tevent_context *ev_ctx,
return NT_STATUS_OK;
}
NTSTATUS dcesrv_setup_endpoint_sockets(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
struct dcesrv_context *dce_ctx,
struct dcesrv_endpoint *e,
struct dcerpc_binding_vector *bvec,
dcerpc_ncacn_termination_fn term_fn,
void *term_data)
{
enum dcerpc_transport_t transport =
dcerpc_binding_get_transport(e->ep_description);
char *binding = NULL;
NTSTATUS status;
binding = dcerpc_binding_string(dce_ctx, e->ep_description);
if (binding == NULL) {
return NT_STATUS_NO_MEMORY;
}
DBG_DEBUG("Setting up endpoint '%s'\n", binding);
switch (transport) {
case NCALRPC:
/* TODO */
status = NT_STATUS_OK;
break;
case NCACN_IP_TCP:
/* TODO */
status = NT_STATUS_OK;
break;
case NCACN_NP:
/* TODO */
status = NT_STATUS_OK;
break;
default:
status = NT_STATUS_NOT_SUPPORTED;
break;
}
/* Build binding string again as the endpoint may have changed by
* dcesrv_create_<transport>_socket functions */
TALLOC_FREE(binding);
binding = dcerpc_binding_string(dce_ctx, e->ep_description);
if (binding == NULL) {
return NT_STATUS_NO_MEMORY;
}
if (!NT_STATUS_IS_OK(status)) {
struct dcesrv_if_list *iface = NULL;
DBG_ERR("Failed to setup '%s' sockets for ", binding);
for (iface = e->interface_list; iface; iface = iface->next) {
DEBUGADD(DBGLVL_ERR, ("'%s' ", iface->iface->name));
}
DEBUGADD(DBGLVL_ERR, (": %s\n", nt_errstr(status)));
return status;
} else {
struct dcesrv_if_list *iface = NULL;
DBG_INFO("Successfully listening on '%s' for ", binding);
for (iface = e->interface_list; iface; iface = iface->next) {
DEBUGADD(DBGLVL_INFO, ("'%s' ", iface->iface->name));
}
DEBUGADD(DBGLVL_INFO, ("\n"));
}
TALLOC_FREE(binding);
return status;
}
static NTSTATUS rpc_setup_winreg(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx)
{

View File

@ -22,15 +22,23 @@
#ifndef _RPC_EP_SETUP_H
#define _RPC_EP_SETUP_H
struct ndr_interface_table;
struct rpc_srv_callbacks;
struct dcesrv_context;
#include "rpc_server/rpc_server.h"
struct dcerpc_binding_vector;
NTSTATUS dcesrv_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
struct dcesrv_context *dce_ctx);
NTSTATUS dcesrv_setup_endpoint_sockets(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
struct dcesrv_context *dce_ctx,
struct dcesrv_endpoint *e,
struct dcerpc_binding_vector *bvec,
dcerpc_ncacn_termination_fn term_fn,
void *term_data);
NTSTATUS rpc_setup_embedded(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
const struct ndr_interface_table *t,