diff options
author | Stefan Metzmacher <metze@samba.org> | 2014-02-13 16:28:54 +0100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2014-05-26 03:31:27 +0200 |
commit | 3aebaf4c1340292baec0db8448e60af2079600c1 (patch) | |
tree | cb55c7d92bb417f5e115e9ec22ce6c50e5a18e74 /source4 | |
parent | 374c5c4109facbcf3e9a20d1b116d369f14164c0 (diff) | |
download | samba-3aebaf4c1340292baec0db8448e60af2079600c1.tar.gz samba-3aebaf4c1340292baec0db8448e60af2079600c1.tar.xz samba-3aebaf4c1340292baec0db8448e60af2079600c1.zip |
s4:librpc/rpc: set "localaddress" and reset "host" for ncacn_ip_tcp
We should remember local and remote ip address in dcerpc_pipe->binding.
Note: that we still have the "target_hostname" unmodified, if present.
This way dcerpc_pipe->binding can be used to create a secondary connection
that is a additional connection for the existing association group.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4')
-rw-r--r-- | source4/librpc/rpc/dcerpc_connect.c | 18 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_secondary.c | 21 |
2 files changed, 34 insertions, 5 deletions
diff --git a/source4/librpc/rpc/dcerpc_connect.c b/source4/librpc/rpc/dcerpc_connect.c index 39ff941e77..88898857bf 100644 --- a/source4/librpc/rpc/dcerpc_connect.c +++ b/source4/librpc/rpc/dcerpc_connect.c @@ -38,7 +38,7 @@ struct dcerpc_pipe_connect { struct dcecli_connection *conn; - const struct dcerpc_binding *binding; + struct dcerpc_binding *binding; const char *pipe_name; const struct ndr_interface_table *interface; struct cli_credentials *creds; @@ -344,9 +344,23 @@ static void continue_pipe_open_ncacn_ip_tcp(struct composite_context *ctx) { struct composite_context *c = talloc_get_type(ctx->async.private_data, struct composite_context); + struct pipe_ip_tcp_state *s = talloc_get_type(c->private_data, + struct pipe_ip_tcp_state); + char *localaddr = NULL; + char *remoteaddr = NULL; /* receive result of named pipe open request on tcp/ip */ - c->status = dcerpc_pipe_open_tcp_recv(ctx, NULL, NULL, NULL); + c->status = dcerpc_pipe_open_tcp_recv(ctx, s, &localaddr, &remoteaddr); + if (!composite_is_ok(c)) return; + + c->status = dcerpc_binding_set_string_option(s->io.binding, + "localaddress", + localaddr); + if (!composite_is_ok(c)) return; + + c->status = dcerpc_binding_set_string_option(s->io.binding, + "host", + remoteaddr); if (!composite_is_ok(c)) return; composite_done(c); diff --git a/source4/librpc/rpc/dcerpc_secondary.c b/source4/librpc/rpc/dcerpc_secondary.c index 8fc159867b..a84f3e6b1e 100644 --- a/source4/librpc/rpc/dcerpc_secondary.c +++ b/source4/librpc/rpc/dcerpc_secondary.c @@ -36,7 +36,7 @@ struct sec_conn_state { struct dcerpc_pipe *pipe; struct dcerpc_pipe *pipe2; - const struct dcerpc_binding *binding; + struct dcerpc_binding *binding; struct socket_address *peer_addr; const char *localaddress; }; @@ -75,7 +75,8 @@ _PUBLIC_ struct composite_context* dcerpc_secondary_connection_send(struct dcerp c->private_data = s; s->pipe = p; - s->binding = b; + s->binding = dcerpc_binding_dup(s, b); + if (composite_nomem(s->binding, c)) return c; /* initialise second dcerpc pipe based on primary pipe's event context */ s->pipe2 = dcerpc_pipe_init(c, s->pipe->conn->event_ctx); @@ -180,8 +181,22 @@ static void continue_open_tcp(struct composite_context *ctx) { struct composite_context *c = talloc_get_type(ctx->async.private_data, struct composite_context); + struct sec_conn_state *s = talloc_get_type_abort(c->private_data, + struct sec_conn_state); + char *localaddr = NULL; + char *remoteaddr = NULL; + + c->status = dcerpc_pipe_open_tcp_recv(ctx, s, &localaddr, &remoteaddr); + if (!composite_is_ok(c)) return; + + c->status = dcerpc_binding_set_string_option(s->binding, + "localaddress", + localaddr); + if (!composite_is_ok(c)) return; - c->status = dcerpc_pipe_open_tcp_recv(ctx, NULL, NULL, NULL); + c->status = dcerpc_binding_set_string_option(s->binding, + "host", + remoteaddr); if (!composite_is_ok(c)) return; continue_pipe_open(c); |