s4:libcli: allow passing an already negotiated connection to smb2_connect_send()
authorStefan Metzmacher <metze@samba.org>
Wed, 18 Jul 2018 14:44:16 +0000 (16:44 +0200)
committerKarolin Seeger <kseeger@samba.org>
Mon, 13 Aug 2018 10:56:34 +0000 (12:56 +0200)
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 f20e607c15b4c8ae56ade5d7e68d832542a2cd5e)

source4/libcli/smb2/connect.c
source4/librpc/rpc/dcerpc_connect.c

index ac37eae6aa89289082c932444c7643a95ed7a978..2dee5021869485110e101d701e4c77889ce16666 100644 (file)
@@ -64,6 +64,7 @@ struct tevent_req *smb2_connect_send(TALLOC_CTX *mem_ctx,
                                     const char *share,
                                     struct resolve_context *resolve_ctx,
                                     struct cli_credentials *credentials,
+                                    struct smbXcli_conn **existing_conn,
                                     uint64_t previous_session_id,
                                     const struct smbcli_options *options,
                                     const char *socket_options,
@@ -107,6 +108,25 @@ struct tevent_req *smb2_connect_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
+       if (existing_conn != NULL) {
+               NTSTATUS status;
+
+               status = smb2_transport_raw_init(state, ev,
+                                                existing_conn,
+                                                options,
+                                                &state->transport);
+               if (tevent_req_nterror(req, status)) {
+                       return tevent_req_post(req, ev);
+               }
+
+               smb2_connect_session_start(req);
+               if (!tevent_req_is_in_progress(req)) {
+                       return tevent_req_post(req, ev);
+               }
+
+               return req;
+       }
+
        creq = smbcli_sock_connect_send(state, NULL, state->ports,
                                        state->host, state->resolve_ctx,
                                        state->ev, state->socket_options,
@@ -311,6 +331,7 @@ NTSTATUS smb2_connect_ext(TALLOC_CTX *mem_ctx,
                                   share,
                                   resolve_ctx,
                                   credentials,
+                                  NULL, /* existing_conn */
                                   previous_session_id,
                                   options,
                                   socket_options,
index 1252e74b5a9d231b664cf29ddc5ab339c81a5417..a3f25efc0b47e9b5930ef94c89cfb379a216a2d0 100644 (file)
@@ -301,6 +301,7 @@ static struct composite_context *dcerpc_pipe_connect_ncacn_np_smb2_send(
                        "IPC$",
                        s->io.resolve_ctx,
                        s->io.creds,
+                       NULL, /* existing_conn */
                        0, /* previous_session_id */
                        &options,
                        lpcfg_socket_options(lp_ctx),