diff options
| author | Stefan Metzmacher <metze@samba.org> | 2013-09-19 18:16:16 +0200 |
|---|---|---|
| committer | Stefan Metzmacher <metze@samba.org> | 2014-01-07 08:37:44 +0100 |
| commit | a08ee93a2fd75b99cfd8ba66c42e08c3f1403bf9 (patch) | |
| tree | 2ae38e8a8c76f3e526068f5559f16d87880754b4 /source4/librpc | |
| parent | f7b1ff2cf4f42562980e18b9b1cb0e262630f338 (diff) | |
| download | samba-a08ee93a2fd75b99cfd8ba66c42e08c3f1403bf9.tar.gz samba-a08ee93a2fd75b99cfd8ba66c42e08c3f1403bf9.tar.xz samba-a08ee93a2fd75b99cfd8ba66c42e08c3f1403bf9.zip | |
s4:librpc: pass smbXcli_{conn,session,tcon} to dcerpc_pipe_open_smb_send()
This will allow it to be used also for smb2 later.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source4/librpc')
| -rw-r--r-- | source4/librpc/rpc/dcerpc.h | 3 | ||||
| -rw-r--r-- | source4/librpc/rpc/dcerpc_connect.c | 35 | ||||
| -rw-r--r-- | source4/librpc/rpc/dcerpc_smb.c | 97 |
3 files changed, 98 insertions, 37 deletions
diff --git a/source4/librpc/rpc/dcerpc.h b/source4/librpc/rpc/dcerpc.h index 67059ac485..a298be7fc4 100644 --- a/source4/librpc/rpc/dcerpc.h +++ b/source4/librpc/rpc/dcerpc.h @@ -153,6 +153,9 @@ struct epm_floor; struct smbcli_tree; struct smb2_tree; +struct smbXcli_conn; +struct smbXcli_session; +struct smbXcli_tcon; struct socket_address; NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx, diff --git a/source4/librpc/rpc/dcerpc_connect.c b/source4/librpc/rpc/dcerpc_connect.c index 594e7f7432..089603d1b8 100644 --- a/source4/librpc/rpc/dcerpc_connect.c +++ b/source4/librpc/rpc/dcerpc_connect.c @@ -29,6 +29,7 @@ #include "lib/events/events.h" #include "libcli/smb2/smb2.h" #include "libcli/smb2/smb2_calls.h" +#include "libcli/smb/smbXcli_base.h" #include "librpc/rpc/dcerpc.h" #include "librpc/rpc/dcerpc_proto.h" #include "auth/credentials/credentials.h" @@ -38,7 +39,6 @@ struct pipe_np_smb_state { struct smb_composite_connect conn; - struct smbcli_tree *tree; struct dcerpc_pipe_connect io; }; @@ -69,17 +69,44 @@ static void continue_smb_connect(struct composite_context *ctx) struct composite_context); struct pipe_np_smb_state *s = talloc_get_type(c->private_data, struct pipe_np_smb_state); - + struct smbcli_tree *t; + struct smbXcli_conn *conn; + struct smbXcli_session *session; + struct smbXcli_tcon *tcon; + uint32_t timeout_msec; + /* receive result of smb connect request */ c->status = smb_composite_connect_recv(ctx, s->io.pipe->conn); if (!composite_is_ok(c)) return; /* prepare named pipe open parameters */ - s->tree = s->conn.out.tree; s->io.pipe_name = s->io.binding->endpoint; + t = s->conn.out.tree; + conn = t->session->transport->conn; + session = t->session->smbXcli; + tcon = t->smbXcli; + smb1cli_tcon_set_id(tcon, t->tid); + timeout_msec = t->session->transport->options.request_timeout * 1000; + + /* if we don't have a binding on this pipe yet, then create one */ + if (s->io.pipe->binding == NULL) { + const char *r = smbXcli_conn_remote_name(conn); + char *str; + SMB_ASSERT(r != NULL); + str = talloc_asprintf(s, "ncacn_np:%s", r); + if (composite_nomem(str, c)) return; + c->status = dcerpc_parse_binding(s->io.pipe, str, + &s->io.pipe->binding); + talloc_free(str); + if (!composite_is_ok(c)) return; + } + /* send named pipe open request */ - open_ctx = dcerpc_pipe_open_smb_send(s->io.pipe, s->tree, s->io.pipe_name); + open_ctx = dcerpc_pipe_open_smb_send(s->io.pipe->conn, + conn, session, + tcon, timeout_msec, + s->io.pipe_name); if (composite_nomem(open_ctx, c)) return; composite_continue(c, open_ctx, continue_pipe_open_smb, c); diff --git a/source4/librpc/rpc/dcerpc_smb.c b/source4/librpc/rpc/dcerpc_smb.c index 12a2407b28..8acc26f56f 100644 --- a/source4/librpc/rpc/dcerpc_smb.c +++ b/source4/librpc/rpc/dcerpc_smb.c @@ -37,12 +37,18 @@ struct smb_private { DATA_BLOB session_key; const char *server_name; - struct smbcli_tree *tree; - struct tstream_context *stream; struct tevent_queue *write_queue; struct tevent_req *read_subreq; uint32_t pending_reads; + + /* + * these are needed to open a secondary connection + */ + struct smbXcli_conn *conn; + struct smbXcli_session *session; + struct smbXcli_tcon *tcon; + uint32_t timeout_msec; }; @@ -422,37 +428,18 @@ struct dcerpc_pipe_open_smb_state { static void dcerpc_pipe_open_smb_done(struct tevent_req *subreq); -struct composite_context *dcerpc_pipe_open_smb_send(struct dcerpc_pipe *p, - struct smbcli_tree *tree, - const char *pipe_name) +struct composite_context *dcerpc_pipe_open_smb_send(struct dcecli_connection *c, + struct smbXcli_conn *conn, + struct smbXcli_session *session, + struct smbXcli_tcon *tcon, + uint32_t timeout_msec, + const char *pipe_name) { struct composite_context *ctx; struct dcerpc_pipe_open_smb_state *state; - struct dcecli_connection *c = p->conn; - struct smbXcli_conn *conn = tree->session->transport->conn; - struct smbXcli_session *session = tree->session->smbXcli; - struct smbXcli_tcon *tcon = tree->smbXcli; - uint16_t pid = tree->session->pid; - uint32_t timeout_msec = tree->session->transport->options.request_timeout * 1000; + uint16_t pid = 0; struct tevent_req *subreq; - /* if we don't have a binding on this pipe yet, then create one */ - if (p->binding == NULL) { - NTSTATUS status; - const char *r = smbXcli_conn_remote_name(conn); - char *s; - SMB_ASSERT(r != NULL); - s = talloc_asprintf(p, "ncacn_np:%s", r); - if (s == NULL) return NULL; - status = dcerpc_parse_binding(p, s, &p->binding); - talloc_free(s); - if (!NT_STATUS_IS_OK(status)) { - return NULL; - } - } - - smb1cli_tcon_set_id(tree->smbXcli, tree->tid); - ctx = composite_create(c, c->event_ctx); if (ctx == NULL) return NULL; @@ -477,7 +464,10 @@ struct composite_context *dcerpc_pipe_open_smb_send(struct dcerpc_pipe *p, state->smb = talloc_zero(state, struct smb_private); if (composite_nomem(state->smb, ctx)) return ctx; - state->smb->tree = tree; + state->smb->conn = conn; + state->smb->session = session; + state->smb->tcon = tcon; + state->smb->timeout_msec = timeout_msec; state->smb->server_name = strupper_talloc(state->smb, smbXcli_conn_remote_name(conn)); @@ -556,11 +546,47 @@ NTSTATUS dcerpc_pipe_open_smb_recv(struct composite_context *c) } _PUBLIC_ NTSTATUS dcerpc_pipe_open_smb(struct dcerpc_pipe *p, - struct smbcli_tree *tree, + struct smbcli_tree *t, const char *pipe_name) { - struct composite_context *ctx = dcerpc_pipe_open_smb_send(p, tree, - pipe_name); + struct smbXcli_conn *conn; + struct smbXcli_session *session; + struct smbXcli_tcon *tcon; + uint32_t timeout_msec; + struct composite_context *ctx; + + conn = t->session->transport->conn; + session = t->session->smbXcli; + tcon = t->smbXcli; + smb1cli_tcon_set_id(tcon, t->tid); + timeout_msec = t->session->transport->options.request_timeout * 1000; + + /* if we don't have a binding on this pipe yet, then create one */ + if (p->binding == NULL) { + NTSTATUS status; + const char *r = smbXcli_conn_remote_name(conn); + char *str; + SMB_ASSERT(r != NULL); + str = talloc_asprintf(p, "ncacn_np:%s", r); + if (str == NULL) { + return NT_STATUS_NO_MEMORY; + } + status = dcerpc_parse_binding(p, str, + &p->binding); + talloc_free(str); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + } + + ctx = dcerpc_pipe_open_smb_send(p->conn, + conn, session, + tcon, timeout_msec, + pipe_name); + if (ctx == NULL) { + return NT_STATUS_NO_MEMORY; + } + return dcerpc_pipe_open_smb_recv(ctx); } @@ -575,7 +601,12 @@ struct composite_context *dcerpc_secondary_smb_send(struct dcecli_connection *c1 smb = talloc_get_type(c1->transport.private_data, struct smb_private); if (!smb) return NULL; - return dcerpc_pipe_open_smb_send(p2, smb->tree, pipe_name); + return dcerpc_pipe_open_smb_send(p2->conn, + smb->conn, + smb->session, + smb->tcon, + smb->timeout_msec, + pipe_name); } NTSTATUS dcerpc_secondary_smb_recv(struct composite_context *c) |
