1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-10 12:58:35 +03:00

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>
This commit is contained in:
Stefan Metzmacher 2014-02-13 16:28:54 +01:00 committed by Andrew Bartlett
parent 374c5c4109
commit 3aebaf4c13
2 changed files with 34 additions and 5 deletions

View File

@ -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);

View File

@ -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, 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->binding,
"localaddress",
localaddr);
if (!composite_is_ok(c)) return;
c->status = dcerpc_binding_set_string_option(s->binding,
"host",
remoteaddr);
if (!composite_is_ok(c)) return;
continue_pipe_open(c);