From a97f6670288097adc7a924a93bb1078062ceee32 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 28 Jul 2005 04:46:11 +0000 Subject: r8820: Push this common block of code into the caller. Use talloc_steal() rather than talloc_reference(). Andrew Bartlett (This used to be commit 8774f971f3926c5c37aad1e8dfeafa394de87d63) --- source4/librpc/rpc/dcerpc_util.c | 57 +++++++++++++--------------------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c index efcd36f24b..40f2fda3a4 100644 --- a/source4/librpc/rpc/dcerpc_util.c +++ b/source4/librpc/rpc/dcerpc_util.c @@ -1022,19 +1022,6 @@ static NTSTATUS dcerpc_pipe_connect_ncacn_np(TALLOC_CTX *tmp_ctx, return status; } - /* Look up identifier using the epmapper */ - if (!binding->endpoint) { - status = dcerpc_epm_map_binding(tmp_ctx, binding, - pipe_uuid, pipe_version, - p->conn->event_ctx); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("Failed to map DCERPC/TCP NCACN_NP pipe for '%s' - %s\n", - pipe_uuid, nt_errstr(status))); - return status; - } - DEBUG(2,("Mapped to DCERPC/NP pipe %s\n", binding->endpoint)); - } - pipe_name = binding->endpoint; status = dcerpc_pipe_open_smb(p->conn, cli->tree, pipe_name); @@ -1056,19 +1043,6 @@ static NTSTATUS dcerpc_pipe_connect_ncalrpc(TALLOC_CTX *tmp_ctx, { NTSTATUS status; - /* Look up identifier using the epmapper */ - if (!binding->endpoint) { - status = dcerpc_epm_map_binding(tmp_ctx, binding, - pipe_uuid, pipe_version, - p->conn->event_ctx); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("Failed to map DCERPC/TCP NCALRPC identifier for '%s' - %s\n", - pipe_uuid, nt_errstr(status))); - return status; - } - DEBUG(2,("Mapped to DCERPC/LRPC identifier %s\n", binding->endpoint)); - } - status = dcerpc_pipe_open_pipe(p->conn, binding->endpoint); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("Failed to open ncalrpc pipe '%s' - %s\n", @@ -1118,18 +1092,6 @@ static NTSTATUS dcerpc_pipe_connect_ncacn_ip_tcp(TALLOC_CTX *tmp_ctx, NTSTATUS status; uint32_t port = 0; - if (!binding->endpoint) { - status = dcerpc_epm_map_binding(tmp_ctx, binding, - pipe_uuid, pipe_version, - p->conn->event_ctx); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("Failed to map DCERPC/TCP port for '%s' - %s\n", - pipe_uuid, nt_errstr(status))); - return status; - } - DEBUG(2,("Mapped to DCERPC/TCP port %s\n", binding->endpoint)); - } - port = atoi(binding->endpoint); status = dcerpc_pipe_open_tcp(p->conn, binding->host, port); @@ -1166,6 +1128,23 @@ NTSTATUS dcerpc_pipe_connect_b(TALLOC_CTX *parent_ctx, } tmp_ctx = talloc_named(p, 0, "dcerpc_pipe_connect_b tmp_ctx"); + switch (binding->transport) { + case NCACN_NP: + case NCACN_IP_TCP: + case NCALRPC: + if (!binding->endpoint) { + status = dcerpc_epm_map_binding(tmp_ctx, binding, + pipe_uuid, pipe_version, + p->conn->event_ctx); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("Failed to map DCERPC endpoint for '%s' - %s\n", + pipe_uuid, nt_errstr(status))); + return status; + } + DEBUG(2,("Mapped to DCERPC endpoint %s\n", binding->endpoint)); + } + } + switch (binding->transport) { case NCACN_NP: status = dcerpc_pipe_connect_ncacn_np(tmp_ctx, @@ -1237,7 +1216,7 @@ NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx, credentials, ev); if (NT_STATUS_IS_OK(status)) { - *pp = talloc_reference(parent_ctx, *pp); + *pp = talloc_steal(parent_ctx, *pp); } talloc_free(tmp_ctx); -- cgit