From dfee05744797459d1303a54edb5955dec1e4cb1a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 13 Feb 2014 09:53:49 +0100 Subject: s4:librpc/rpc: avoid using dcerpc_unix_socket_path() We use information stored in the dcerpc_binding in order to open a secondary connection. The goals are: - dcerpc_secondary_connection_* should just use the dcerpc_binding information for the first connection and just call dcerpc_pipe_connect_* - Get rid of dcerpc_pipe->transport.* and just use a tstream_context. All other details should be maintained only by the higher levels. - Hide dcerpc_pipe and dcecli_connection behind dcerpc_binding_handle. - Have just one entry point to create a new connection. For source4/librpc this will be dcerpc_pipe_connect_*. For source3/rpc_client we need a similar function. - We'll have a new dcerpc_connection layer, with also just one entry point to create a new connection. - Replace dcerpc_pipe and dcecli_connection with the new dcerpc_connection layer. - Replace rpc_pipe_client with the new dcerpc_connection layer. - When the client side is unified we can change the server as it needs to act as a client in order to register the endpoint mappings. - Then the core of the server will be changed to use the new dcerpc_connection layer. As dcerpc_unix_socket_path() uses p->transport.private_data as 'struct sock_private', we should avoid it. We can then remove dcerpc_unix_socket_path() and 'struct sock_private'. Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett --- source4/librpc/rpc/dcerpc_secondary.c | 45 ++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) (limited to 'source4/librpc') diff --git a/source4/librpc/rpc/dcerpc_secondary.c b/source4/librpc/rpc/dcerpc_secondary.c index be886a2077..fbad46c55a 100644 --- a/source4/librpc/rpc/dcerpc_secondary.c +++ b/source4/librpc/rpc/dcerpc_secondary.c @@ -44,7 +44,8 @@ struct sec_conn_state { static void continue_open_smb(struct composite_context *ctx); static void continue_open_tcp(struct composite_context *ctx); -static void continue_open_pipe(struct composite_context *ctx); +static void continue_open_ncalrpc(struct composite_context *ctx); +static void continue_open_ncacn_unix(struct composite_context *ctx); static void continue_pipe_open(struct composite_context *c); @@ -60,6 +61,8 @@ _PUBLIC_ struct composite_context* dcerpc_secondary_connection_send(struct dcerp struct composite_context *pipe_smb_req; struct composite_context *pipe_tcp_req; struct composite_context *pipe_ncalrpc_req; + const char *ncalrpc_dir = NULL; + struct composite_context *pipe_unix_req; const char *target_hostname; const char *endpoint; @@ -123,10 +126,27 @@ _PUBLIC_ struct composite_context* dcerpc_secondary_connection_send(struct dcerp return c; case NCALRPC: + ncalrpc_dir = dcerpc_binding_get_string_option(s->binding, + "ncalrpc_dir"); + if (ncalrpc_dir == NULL) { + ncalrpc_dir = dcerpc_binding_get_string_option(s->pipe->binding, + "ncalrpc_dir"); + } + if (ncalrpc_dir == NULL) { + composite_error(c, NT_STATUS_INVALID_PARAMETER_MIX); + return c; + } + + pipe_ncalrpc_req = dcerpc_pipe_open_pipe_send(s->pipe2->conn, + ncalrpc_dir, + endpoint); + composite_continue(c, pipe_ncalrpc_req, continue_open_ncalrpc, c); + return c; + case NCACN_UNIX_STREAM: - pipe_ncalrpc_req = dcerpc_pipe_open_unix_stream_send(s->pipe2->conn, - dcerpc_unix_socket_path(s->pipe->conn)); - composite_continue(c, pipe_ncalrpc_req, continue_open_pipe, c); + pipe_unix_req = dcerpc_pipe_open_unix_stream_send(s->pipe2->conn, + endpoint); + composite_continue(c, pipe_unix_req, continue_open_ncacn_unix, c); return c; default: @@ -167,11 +187,24 @@ static void continue_open_tcp(struct composite_context *ctx) continue_pipe_open(c); } - /* Stage 2 of secondary_connection: Receive result of pipe open request on ncalrpc */ -static void continue_open_pipe(struct composite_context *ctx) +static void continue_open_ncalrpc(struct composite_context *ctx) +{ + struct composite_context *c = talloc_get_type(ctx->async.private_data, + struct composite_context); + + c->status = dcerpc_pipe_open_pipe_recv(ctx); + if (!composite_is_ok(c)) return; + + continue_pipe_open(c); +} + +/* + Stage 2 of secondary_connection: Receive result of pipe open request on ncacn_unix +*/ +static void continue_open_ncacn_unix(struct composite_context *ctx) { struct composite_context *c = talloc_get_type(ctx->async.private_data, struct composite_context); -- cgit