From ca92ed140c7caef19225ec2024260e1c56244eab Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Sep 2005 14:35:51 +0000 Subject: r10580: More generic approach for adding endpoints (This used to be commit 0ef7fe6f4c979dcc3a0ab268253e493d8e929dd7) --- source4/rpc_server/dcerpc_server.c | 39 ++++++++++++++++++++++++++++++--- source4/rpc_server/dcerpc_sock.c | 44 +++----------------------------------- 2 files changed, 39 insertions(+), 44 deletions(-) (limited to 'source4') diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c index a00d6975208..17a097a4cc6 100644 --- a/source4/rpc_server/dcerpc_server.c +++ b/source4/rpc_server/dcerpc_server.c @@ -30,6 +30,7 @@ #include "rpc_server/dcerpc_server.h" #include "lib/events/events.h" #include "smbd/service_stream.h" +#include "system/filesys.h" /* see if two endpoints match @@ -1286,12 +1287,13 @@ const struct dcesrv_critical_sizes *dcerpc_module_version(void) } /* - initialise the dcerpc server context for socket based services + initialise the dcerpc server context */ static NTSTATUS dcesrv_init(struct event_context *event_context, const struct model_ops *model_ops) { NTSTATUS status; struct dcesrv_context *dce_ctx; + struct dcesrv_endpoint *e; status = dcesrv_init_context(event_context, lp_dcerpc_endpoint_servers(), @@ -1299,9 +1301,40 @@ static NTSTATUS dcesrv_init(struct event_context *event_context, const struct mo &dce_ctx); NT_STATUS_NOT_OK_RETURN(status); - return dcesrv_sock_init(dce_ctx, event_context, model_ops); -} + /* Make sure the directory for NCALRPC exists */ + if (!directory_exist(lp_ncalrpc_dir())) { + mkdir(lp_ncalrpc_dir(), 0755); + } + + for (e=dce_ctx->endpoint_list;e;e=e->next) { + switch (e->ep_description->transport) { + case NCACN_UNIX_STREAM: + status = dcesrv_add_ep_unix(dce_ctx, e, event_context, model_ops); + NT_STATUS_NOT_OK_RETURN(status); + break; + + case NCALRPC: + status = dcesrv_add_ep_ncalrpc(dce_ctx, e, event_context, model_ops); + NT_STATUS_NOT_OK_RETURN(status); + break; + + case NCACN_IP_TCP: + status = dcesrv_add_ep_tcp(dce_ctx, e, event_context, model_ops); + NT_STATUS_NOT_OK_RETURN(status); + break; + + case NCACN_NP: +/* FIXME: status = dcesrv_add_ep_np(dce_ctx, e, event_context, model_ops); + NT_STATUS_NOT_OK_RETURN(status); */ + break; + + default: + return NT_STATUS_NOT_SUPPORTED; + } + } + return NT_STATUS_OK; +} NTSTATUS server_service_rpc_init(void) { diff --git a/source4/rpc_server/dcerpc_sock.c b/source4/rpc_server/dcerpc_sock.c index 207813abfc3..e7ef621d391 100644 --- a/source4/rpc_server/dcerpc_sock.c +++ b/source4/rpc_server/dcerpc_sock.c @@ -157,7 +157,7 @@ static const struct stream_server_ops dcesrv_stream_ops = { -static NTSTATUS add_socket_rpc_unix(struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e, +NTSTATUS dcesrv_add_ep_unix(struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e, struct event_context *event_ctx, const struct model_ops *model_ops) { struct dcesrv_socket_context *dcesrv_sock; @@ -182,7 +182,7 @@ static NTSTATUS add_socket_rpc_unix(struct dcesrv_context *dce_ctx, struct dcesr return status; } -static NTSTATUS add_socket_rpc_ncalrpc(struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e, +NTSTATUS dcesrv_add_ep_ncalrpc(struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e, struct event_context *event_ctx, const struct model_ops *model_ops) { struct dcesrv_socket_context *dcesrv_sock; @@ -251,7 +251,7 @@ static NTSTATUS add_socket_rpc_tcp_iface(struct dcesrv_context *dce_ctx, struct return status; } -static NTSTATUS add_socket_rpc_tcp(struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e, +NTSTATUS dcesrv_add_ep_tcp(struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e, struct event_context *event_ctx, const struct model_ops *model_ops) { NTSTATUS status; @@ -273,42 +273,4 @@ static NTSTATUS add_socket_rpc_tcp(struct dcesrv_context *dce_ctx, struct dcesrv return NT_STATUS_OK; } -/**************************************************************************** - Open the listening sockets for RPC over NCACN_IP_TCP/NCALRPC/NCACN_UNIX_STREAM -****************************************************************************/ -NTSTATUS dcesrv_sock_init(struct dcesrv_context *dce_ctx, - struct event_context *event_ctx, const struct model_ops *model_ops) -{ - struct dcesrv_endpoint *e; - NTSTATUS status; - - /* Make sure the directory for NCALRPC exists */ - if (!directory_exist(lp_ncalrpc_dir())) { - mkdir(lp_ncalrpc_dir(), 0755); - } - - for (e=dce_ctx->endpoint_list;e;e=e->next) { - switch (e->ep_description->transport) { - case NCACN_UNIX_STREAM: - status = add_socket_rpc_unix(dce_ctx, e, event_ctx, model_ops); - NT_STATUS_NOT_OK_RETURN(status); - break; - - case NCALRPC: - status = add_socket_rpc_ncalrpc(dce_ctx, e, event_ctx, model_ops); - NT_STATUS_NOT_OK_RETURN(status); - break; - - case NCACN_IP_TCP: - status = add_socket_rpc_tcp(dce_ctx, e, event_ctx, model_ops); - NT_STATUS_NOT_OK_RETURN(status); - break; - - default: - break; - } - } - - return NT_STATUS_OK; -} -- cgit