#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"
struct pipe_np_smb_state {
struct smb_composite_connect conn;
- struct smbcli_tree *tree;
struct dcerpc_pipe_connect io;
};
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);
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;
};
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;
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));
}
_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);
}
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)