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

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>
This commit is contained in:
Stefan Metzmacher 2014-02-04 11:30:38 +01:00 committed by Günther Deschner
parent 4bed466352
commit f309d67fcd
3 changed files with 62 additions and 21 deletions

View File

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

View File

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

View File

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