libsmb: Allow smb2 neg ctx in cli_full_connection_creds_send()
authorVolker Lendecke <vl@samba.org>
Fri, 26 Aug 2022 12:17:26 +0000 (14:17 +0200)
committerRalph Boehme <slow@samba.org>
Fri, 2 Sep 2022 13:31:38 +0000 (13:31 +0000)
Will be used to test smb3 posix contexts

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/libsmb/cliconnect.c
source3/libsmb/proto.h
source3/libsmb/pylibsmb.c

index 0fb2b6ea45ae86d94b6b071892438415797c22be..edbd2477f603ede3498411f7127f222089e6f98f 100644 (file)
@@ -2794,7 +2794,8 @@ static struct tevent_req *cli_start_connection_send(
        TALLOC_CTX *mem_ctx, struct tevent_context *ev,
        const char *my_name, const char *dest_host,
        const struct sockaddr_storage *dest_ss, int port,
-       enum smb_signing_setting signing_state, int flags)
+       enum smb_signing_setting signing_state, int flags,
+       struct smb2_negotiate_contexts *negotiate_contexts)
 {
        struct tevent_req *req, *subreq;
        struct cli_start_connection_state *state;
@@ -2848,6 +2849,26 @@ static struct tevent_req *cli_start_connection_send(
                }
        }
 
+       if (negotiate_contexts != NULL) {
+               uint16_t i;
+
+               for (i=0; i<negotiate_contexts->num_contexts; i++) {
+                       struct smb2_negotiate_context *ctx =
+                               &negotiate_contexts->contexts[i];
+                       NTSTATUS status;
+
+                       status = smb2_negotiate_context_add(
+                               state->negotiate_contexts,
+                               state->negotiate_contexts,
+                               ctx->type,
+                               ctx->data.data,
+                               ctx->data.length);
+                       if (tevent_req_nterror(req, status)) {
+                               return tevent_req_post(req, ev);
+                       }
+               }
+       }
+
        subreq = cli_connect_nb_send(state, ev, dest_host, dest_ss, port,
                                     0x20, my_name, signing_state, flags);
        if (tevent_req_nomem(subreq, req)) {
@@ -2939,7 +2960,7 @@ NTSTATUS cli_start_connection(struct cli_state **output_cli,
                goto fail;
        }
        req = cli_start_connection_send(ev, ev, my_name, dest_host, dest_ss,
-                                       port, signing_state, flags);
+                                       port, signing_state, flags, NULL);
        if (req == NULL) {
                goto fail;
        }
@@ -3413,7 +3434,8 @@ struct tevent_req *cli_full_connection_creds_send(
        const struct sockaddr_storage *dest_ss, int port,
        const char *service, const char *service_type,
        struct cli_credentials *creds,
-       int flags)
+       int flags,
+       struct smb2_negotiate_contexts *negotiate_contexts)
 {
        struct tevent_req *req, *subreq;
        struct cli_full_connection_creds_state *state;
@@ -3452,7 +3474,8 @@ struct tevent_req *cli_full_connection_creds_send(
 
        subreq = cli_start_connection_send(
                state, ev, my_name, dest_host, dest_ss, port,
-               signing_state, flags);
+               signing_state, flags,
+               negotiate_contexts);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
@@ -3783,7 +3806,8 @@ NTSTATUS cli_full_connection_creds(struct cli_state **output_cli,
        }
        req = cli_full_connection_creds_send(
                ev, ev, my_name, dest_host, dest_ss, port, service,
-               service_type, creds, flags);
+               service_type, creds, flags,
+               NULL);
        if (req == NULL) {
                goto fail;
        }
index ec66582e28a6894e6795e158d56419c2cbd09ea5..46db49015fba97e960e8929eaaea84336c24ac08 100644 (file)
@@ -92,13 +92,16 @@ NTSTATUS cli_start_connection(struct cli_state **output_cli,
                              enum smb_signing_setting signing_state, int flags);
 NTSTATUS cli_smb1_setup_encryption(struct cli_state *cli,
                                   struct cli_credentials *creds);
+
+struct smb2_negotiate_contexts;
 struct tevent_req *cli_full_connection_creds_send(
        TALLOC_CTX *mem_ctx, struct tevent_context *ev,
        const char *my_name, const char *dest_host,
        const struct sockaddr_storage *dest_ss, int port,
        const char *service, const char *service_type,
        struct cli_credentials *creds,
-       int flags);
+       int flags,
+       struct smb2_negotiate_contexts *negotiate_contexts);
 NTSTATUS cli_full_connection_creds_recv(struct tevent_req *req,
                                        struct cli_state **output_cli);
 NTSTATUS cli_full_connection_creds(struct cli_state **output_cli,
index a3ca41b38d2607a07be891a96e6bb955d8b2d72a..bef6b3de9a708858879c81f8e8f41ab71fb87b40 100644 (file)
@@ -523,7 +523,8 @@ static int py_cli_state_init(struct py_cli_state *self, PyObject *args,
 
        req = cli_full_connection_creds_send(
                NULL, self->ev, "myname", host, NULL, 0, share, "?????",
-               cli_creds, flags);
+               cli_creds, flags,
+               NULL);
        if (!py_tevent_req_wait_exc(self, req)) {
                return -1;
        }