From 156a0ffe542339952a6e2db191ffc586227edd5a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 21 Jul 2011 11:02:59 -0400 Subject: s3-rpc_server: Create common function to allocate pipes_struct Avoid code duplication and fix bug where a new pipe was not added to InternalPipes upon creation in make_server_pipes_struct() Signed-off-by: Andreas Schneider Autobuild-User: Andreas Schneider Autobuild-Date: Thu Jul 21 19:50:02 CEST 2011 on sn-devel-104 --- source3/rpc_server/rpc_handles.c | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'source3/rpc_server/rpc_handles.c') diff --git a/source3/rpc_server/rpc_handles.c b/source3/rpc_server/rpc_handles.c index 1fbee9e3c0..c40029bd08 100644 --- a/source3/rpc_server/rpc_handles.c +++ b/source3/rpc_server/rpc_handles.c @@ -25,6 +25,7 @@ #include "auth.h" #include "rpc_server/rpc_pipes.h" #include "../libcli/security/security.h" +#include "lib/tsocket/tsocket.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV @@ -41,6 +42,55 @@ static struct pipes_struct *InternalPipes; * system _anyway_. so that's the next step... */ +int make_base_pipes_struct(TALLOC_CTX *mem_ctx, + struct messaging_context *msg_ctx, + const char *pipe_name, + enum dcerpc_transport_t transport, + bool endian, bool ncalrpc_as_system, + const struct tsocket_address *remote_address, + const struct tsocket_address *local_address, + struct pipes_struct **_p) +{ + struct pipes_struct *p; + + p = talloc_zero(mem_ctx, struct pipes_struct); + if (!p) { + return ENOMEM; + } + + p->mem_ctx = talloc_named(p, 0, "pipe %s %p", pipe_name, p); + if (!p->mem_ctx) { + talloc_free(p); + return ENOMEM; + } + + p->msg_ctx = msg_ctx; + p->transport = transport; + p->endian = endian; + p->ncalrpc_as_system = ncalrpc_as_system; + + p->remote_address = tsocket_address_copy(remote_address, p); + if (p->remote_address == NULL) { + talloc_free(p); + return ENOMEM; + } + + if (local_address) { + p->local_address = tsocket_address_copy(remote_address, p); + if (p->local_address == NULL) { + talloc_free(p); + return ENOMEM; + } + } + + DLIST_ADD(InternalPipes, p); + talloc_set_destructor(p, close_internal_rpc_pipe_hnd); + + *_p = p; + return 0; +} + + bool check_open_pipes(void) { struct pipes_struct *p; -- cgit