summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2018-07-18 15:34:55 +0200
committerKarolin Seeger <kseeger@samba.org>2018-08-13 12:56:33 +0200
commit1136ff225fb021c39d9752bb06cbf397a1a0439a (patch)
tree290d25c3638f7cd02b230472aed2f0f08ba3e9db /source4/libcli
parent77ab463cba24482c049b6977fec82917f68b569a (diff)
downloadsamba-1136ff225fb021c39d9752bb06cbf397a1a0439a.tar.gz
s4:libcli: allow passing an already negotiated connection to smb_composite_connect()
It will just do the session setup and tree connect steps. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13308 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org> (cherry picked from commit 2b68f9b8b0dd944fa89b9e0037886ddd4fb4e5f9)
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/raw/clitree.c1
-rw-r--r--source4/libcli/smb_composite/connect.c48
-rw-r--r--source4/libcli/smb_composite/smb_composite.h1
3 files changed, 40 insertions, 10 deletions
diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c
index 11be5485f26..b1b6159e750 100644
--- a/source4/libcli/raw/clitree.c
+++ b/source4/libcli/raw/clitree.c
@@ -207,6 +207,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
io.in.called_name = strupper_talloc(tmp_ctx, dest_host);
io.in.service = service;
io.in.service_type = service_type;
+ io.in.existing_conn = NULL;
io.in.credentials = credentials;
io.in.gensec_settings = gensec_settings;
io.in.fallback_to_anonymous = false;
diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c
index fffa768ac97..582d43ef173 100644
--- a/source4/libcli/smb_composite/connect.c
+++ b/source4/libcli/smb_composite/connect.c
@@ -228,18 +228,10 @@ static NTSTATUS connect_session_setup(struct composite_context *c,
return NT_STATUS_OK;
}
-/*
- a negprot request has completed
-*/
-static NTSTATUS connect_negprot(struct composite_context *c,
- struct smb_composite_connect *io)
+static NTSTATUS connect_send_session(struct composite_context *c,
+ struct smb_composite_connect *io)
{
struct connect_state *state = talloc_get_type(c->private_data, struct connect_state);
- NTSTATUS status;
-
- status = smb_raw_negotiate_recv(state->subreq);
- TALLOC_FREE(state->subreq);
- NT_STATUS_NOT_OK_RETURN(status);
/* next step is a session setup */
state->session = smbcli_session_init(state->transport, state, true, io->in.session_options);
@@ -282,6 +274,22 @@ static NTSTATUS connect_negprot(struct composite_context *c,
}
/*
+ a negprot request has completed
+*/
+static NTSTATUS connect_negprot(struct composite_context *c,
+ struct smb_composite_connect *io)
+{
+ struct connect_state *state = talloc_get_type(c->private_data, struct connect_state);
+ NTSTATUS status;
+
+ status = smb_raw_negotiate_recv(state->subreq);
+ TALLOC_FREE(state->subreq);
+ NT_STATUS_NOT_OK_RETURN(status);
+
+ return connect_send_session(c, io);
+}
+
+/*
setup a negprot send
*/
static NTSTATUS connect_send_negprot(struct composite_context *c,
@@ -432,6 +440,26 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec
nbt_choose_called_name(state, &state->called,
io->in.called_name, NBT_NAME_SERVER);
+ if (io->in.existing_conn != NULL) {
+ NTSTATUS status;
+
+ status = smbcli_transport_raw_init(state,
+ c->event_ctx,
+ &io->in.existing_conn,
+ &io->in.options,
+ &state->transport);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto failed;
+ }
+
+ status = connect_send_session(c, io);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto failed;
+ }
+
+ return c;
+ }
+
state->creq = smbcli_sock_connect_send(state,
NULL,
io->in.dest_ports,
diff --git a/source4/libcli/smb_composite/smb_composite.h b/source4/libcli/smb_composite/smb_composite.h
index a92c9612c6a..383946f1307 100644
--- a/source4/libcli/smb_composite/smb_composite.h
+++ b/source4/libcli/smb_composite/smb_composite.h
@@ -118,6 +118,7 @@ struct smb_composite_connect {
const char *called_name;
const char *service;
const char *service_type;
+ struct smbXcli_conn *existing_conn; /* optional */
struct cli_credentials *credentials;
bool fallback_to_anonymous;
const char *workgroup;