diff options
author | Stefan Metzmacher <metze@samba.org> | 2014-02-04 11:30:38 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2014-02-13 11:54:18 +0100 |
commit | f309d67fcd3051628a1cc9d147d5a0bf56e2e286 (patch) | |
tree | 5cc170f6798f99f799c19579e751d8570dda41b1 /source4/librpc | |
parent | 4bed466352e093a4583b0cd96ddb301715cad959 (diff) | |
download | samba-f309d67fcd3051628a1cc9d147d5a0bf56e2e286.tar.gz samba-f309d67fcd3051628a1cc9d147d5a0bf56e2e286.tar.xz samba-f309d67fcd3051628a1cc9d147d5a0bf56e2e286.zip |
s4:librpc/rpc: make use of dcerpc_binding_get_string_option("endpoint")
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Diffstat (limited to 'source4/librpc')
-rw-r--r-- | source4/librpc/rpc/dcerpc_connect.c | 56 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_secondary.c | 22 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_util.c | 5 |
3 files changed, 62 insertions, 21 deletions
diff --git a/source4/librpc/rpc/dcerpc_connect.c b/source4/librpc/rpc/dcerpc_connect.c index 325a1c4c712..a67e376186b 100644 --- a/source4/librpc/rpc/dcerpc_connect.c +++ b/source4/librpc/rpc/dcerpc_connect.c @@ -88,7 +88,11 @@ static void continue_smb_connect(struct composite_context *ctx) if (!composite_is_ok(c)) return; /* prepare named pipe open parameters */ - s->io.pipe_name = s->io.binding->endpoint; + s->io.pipe_name = dcerpc_binding_get_string_option(s->io.binding, "endpoint"); + if (s->io.pipe_name == NULL) { + composite_error(c, NT_STATUS_INVALID_PARAMETER_MIX); + return; + } t = s->conn.out.tree; conn = t->session->transport->conn; @@ -242,7 +246,11 @@ static void continue_smb2_connect(struct tevent_req *subreq) if (!composite_is_ok(c)) return; /* prepare named pipe open parameters */ - s->io.pipe_name = s->io.binding->endpoint; + s->io.pipe_name = dcerpc_binding_get_string_option(s->io.binding, "endpoint"); + if (s->io.pipe_name == NULL) { + composite_error(c, NT_STATUS_INVALID_PARAMETER_MIX); + return; + } conn = t->session->transport->conn; session = t->session->smbXcli; @@ -375,6 +383,7 @@ static struct composite_context* dcerpc_pipe_connect_ncacn_ip_tcp_send(TALLOC_CT struct composite_context *c; struct pipe_ip_tcp_state *s; struct composite_context *pipe_req; + const char *endpoint; /* composite context allocation and setup */ c = composite_create(mem_ctx, io->pipe->conn->event_ctx); @@ -396,8 +405,16 @@ static struct composite_context* dcerpc_pipe_connect_ncacn_ip_tcp_send(TALLOC_CT s->target_hostname = talloc_strdup(s, io->binding->target_hostname); if (composite_nomem(s->target_hostname, c)) return c; } - /* port number is a binding endpoint here */ - s->port = atoi(io->binding->endpoint); + endpoint = dcerpc_binding_get_string_option(io->binding, "endpoint"); + /* port number is a binding endpoint here */ + if (endpoint != NULL) { + s->port = atoi(endpoint); + } + + if (s->port == 0) { + composite_error(c, NT_STATUS_INVALID_PARAMETER_MIX); + return c; + } /* send pipe open request on tcp/ip */ pipe_req = dcerpc_pipe_open_tcp_send(s->io.pipe->conn, s->localaddr, s->host, s->target_hostname, @@ -463,16 +480,13 @@ static struct composite_context* dcerpc_pipe_connect_ncacn_unix_stream_send(TALL /* prepare pipe open parameters and store them in state structure also, verify whether biding endpoint is not null */ s->io = *io; - - if (!io->binding->endpoint) { - DEBUG(0, ("Path to unix socket not specified\n")); - composite_error(c, NT_STATUS_INVALID_PARAMETER); + + s->path = dcerpc_binding_get_string_option(io->binding, "endpoint"); + if (s->path == NULL) { + composite_error(c, NT_STATUS_INVALID_PARAMETER_MIX); return c; } - s->path = talloc_strdup(c, io->binding->endpoint); /* path is a binding endpoint here */ - if (composite_nomem(s->path, c)) return c; - /* send pipe open request on unix socket */ pipe_req = dcerpc_pipe_open_unix_stream_send(s->io.pipe->conn, s->path); composite_continue(c, pipe_req, continue_pipe_open_ncacn_unix_stream, c); @@ -524,6 +538,7 @@ static struct composite_context* dcerpc_pipe_connect_ncalrpc_send(TALLOC_CTX *me struct composite_context *c; struct pipe_ncalrpc_state *s; struct composite_context *pipe_req; + const char *endpoint; /* composite context allocation and setup */ c = composite_create(mem_ctx, io->pipe->conn->event_ctx); @@ -536,9 +551,16 @@ static struct composite_context* dcerpc_pipe_connect_ncalrpc_send(TALLOC_CTX *me /* store input parameters in state structure */ s->io = *io; + endpoint = dcerpc_binding_get_string_option(io->binding, "endpoint"); + if (endpoint == NULL) { + composite_error(c, NT_STATUS_INVALID_PARAMETER_MIX); + return c; + } + /* send pipe open request */ - pipe_req = dcerpc_pipe_open_pipe_send(s->io.pipe->conn, lpcfg_ncalrpc_dir(lp_ctx), - s->io.binding->endpoint); + pipe_req = dcerpc_pipe_open_pipe_send(s->io.pipe->conn, + lpcfg_ncalrpc_dir(lp_ctx), + endpoint); composite_continue(c, pipe_req, continue_pipe_open_ncalrpc, c); return c; } @@ -585,12 +607,14 @@ static void continue_map_binding(struct composite_context *ctx) struct composite_context); struct pipe_connect_state *s = talloc_get_type(c->private_data, struct pipe_connect_state); - + const char *endpoint; + c->status = dcerpc_epm_map_binding_recv(ctx); if (!composite_is_ok(c)) return; - DEBUG(4,("Mapped to DCERPC endpoint %s\n", s->binding->endpoint)); - + endpoint = dcerpc_binding_get_string_option(s->binding, "endpoint"); + DEBUG(4,("Mapped to DCERPC endpoint %s\n", endpoint)); + continue_connect(c, s); } diff --git a/source4/librpc/rpc/dcerpc_secondary.c b/source4/librpc/rpc/dcerpc_secondary.c index 89a4df86f98..68746b6dfe2 100644 --- a/source4/librpc/rpc/dcerpc_secondary.c +++ b/source4/librpc/rpc/dcerpc_secondary.c @@ -60,7 +60,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 *endpoint; + /* composite context allocation and setup */ c = composite_create(p, p->conn->event_ctx); if (c == NULL) return NULL; @@ -79,11 +80,24 @@ _PUBLIC_ struct composite_context* dcerpc_secondary_connection_send(struct dcerp if (DEBUGLEVEL >= 10) s->pipe2->conn->packet_log_dir = s->pipe->conn->packet_log_dir; + endpoint = dcerpc_binding_get_string_option(s->binding, "endpoint"); + if (endpoint == NULL) { + /* + * We may fallback to the endpoint of the given connection + */ + endpoint = dcerpc_binding_get_string_option(s->pipe->binding, "endpoint"); + } + if (endpoint == NULL) { + composite_error(c, NT_STATUS_INVALID_PARAMETER_MIX); + return c; + } + /* open second dcerpc pipe using the same transport as for primary pipe */ switch (s->pipe->conn->transport.transport) { case NCACN_NP: - pipe_smb_req = dcerpc_secondary_smb_send(s->pipe->conn, s->pipe2->conn, - s->binding->endpoint); + pipe_smb_req = dcerpc_secondary_smb_send(s->pipe->conn, + s->pipe2->conn, + endpoint); composite_continue(c, pipe_smb_req, continue_open_smb, c); return c; @@ -101,7 +115,7 @@ _PUBLIC_ struct composite_context* dcerpc_secondary_connection_send(struct dcerp s->localaddress, s->peer_addr->addr, s->binding->target_hostname, - atoi(s->binding->endpoint), + atoi(endpoint), resolve_context_init(s)); composite_continue(c, pipe_tcp_req, continue_open_tcp, c); return c; diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c index 1cfd6aa8a74..f95678eb779 100644 --- a/source4/librpc/rpc/dcerpc_util.c +++ b/source4/librpc/rpc/dcerpc_util.c @@ -445,6 +445,7 @@ static void continue_auth_auto(struct composite_context *ctx) NT_STATUS_UNSUCCESSFUL on a authentication error on RPC */ const char *principal; + const char *endpoint; principal = gensec_get_target_principal(s->pipe->conn->security_state.generic_state); if (principal == NULL) { @@ -455,9 +456,11 @@ static void continue_auth_auto(struct composite_context *ctx) } } + endpoint = dcerpc_binding_get_string_option(s->binding, "endpoint"); + if ((cli_credentials_failed_kerberos_login(s->credentials, principal, &s->logon_retries) || cli_credentials_wrong_password(s->credentials)) && - s->binding->endpoint != NULL) { + endpoint != NULL) { /* * Retry SPNEGO with a better password * send a request for secondary rpc connection |