]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:libsmb: Pass cli_credentials to clidfs do_connect()
authorAndreas Schneider <asn@samba.org>
Tue, 18 Aug 2020 15:15:09 +0000 (17:15 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 9 Oct 2020 19:16:45 +0000 (19:16 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail.d/smbclient-encryption [deleted file]
source3/libsmb/clidfs.c

diff --git a/selftest/knownfail.d/smbclient-encryption b/selftest/knownfail.d/smbclient-encryption
deleted file mode 100644 (file)
index 972096b..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-^samba3.blackbox.smbclient.encryption.smbclient.smb3.client.encrypt.required...LOCALSHARE4.enc_desired..simpleserver
-^samba3.blackbox.smbclient.encryption.smbclient.smb3.client.encrypt.required...LOCALSHARE4.tmp..simpleserver
index 736c565a7a82105c760d42ba79557feed806350a..d536e0597af688d23e0d94fa22bb42f68ffbe9d7 100644 (file)
@@ -106,7 +106,7 @@ static NTSTATUS cli_cm_force_encryption_creds(struct cli_state *c,
 static NTSTATUS do_connect(TALLOC_CTX *ctx,
                                        const char *server,
                                        const char *share,
-                                       const struct user_auth_info *auth_info,
+                                       struct cli_credentials *creds,
                                        int max_protocol,
                                        const struct sockaddr_storage *dest_ss,
                                        int port,
@@ -120,12 +120,12 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
        NTSTATUS status;
        int flags = 0;
        enum protocol_types protocol = PROTOCOL_NONE;
-       int signing_state = get_cmdline_auth_info_signing_state(auth_info);
-       struct cli_credentials *creds = NULL;
-       bool force_encrypt =
-               get_cmdline_auth_info_smb_encrypt(auth_info);
+       enum smb_signing_setting signing_state =
+               cli_credentials_get_smb_signing(creds);
+       enum smb_encryption_setting encryption_state =
+               cli_credentials_get_smb_encryption(creds);
 
-       if (force_encrypt) {
+       if (encryption_state >= SMB_ENCRYPTION_DESIRED) {
                signing_state = SMB_SIGNING_REQUIRED;
        }
 
@@ -192,13 +192,12 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
                smb2cli_conn_set_max_credits(c->conn, DEFAULT_SMB2_MAX_CREDITS);
        }
 
-       creds = get_cmdline_auth_info_creds(auth_info);
-
        status = cli_session_setup_creds(c, creds);
        if (!NT_STATUS_IS_OK(status)) {
                /* If a password was not supplied then
                 * try again with a null username. */
-               if (force_encrypt || smbXcli_conn_signing_mandatory(c->conn) ||
+               if (encryption_state == SMB_ENCRYPTION_REQUIRED ||
+                       smbXcli_conn_signing_mandatory(c->conn) ||
                        cli_credentials_authentication_requested(creds) ||
                        cli_credentials_is_anonymous(creds) ||
                        !NT_STATUS_IS_OK(status = cli_session_setup_anon(c)))
@@ -233,7 +232,7 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
                                creds)) {
                cli_shutdown(c);
                return do_connect(ctx, newserver,
-                               newshare, auth_info,
+                               newshare, creds,
                                max_protocol,
                                NULL, port, name_type, pcli);
        }
@@ -247,13 +246,19 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
                return status;
        }
 
-       if (force_encrypt) {
+       if (encryption_state >= SMB_ENCRYPTION_DESIRED) {
                status = cli_cm_force_encryption_creds(c,
                                                       creds,
                                                       sharename);
                if (!NT_STATUS_IS_OK(status)) {
-                       cli_shutdown(c);
-                       return status;
+                       switch (encryption_state) {
+                       case SMB_ENCRYPTION_DESIRED:
+                               break;
+                       case SMB_ENCRYPTION_REQUIRED:
+                       default:
+                               cli_shutdown(c);
+                               return status;
+                       }
                }
        }
 
@@ -295,10 +300,11 @@ static NTSTATUS cli_cm_connect(TALLOC_CTX *ctx,
                               struct cli_state **pcli)
 {
        struct cli_state *cli = NULL;
+       struct cli_credentials *creds = get_cmdline_auth_info_creds(auth_info);
        NTSTATUS status;
 
        status = do_connect(ctx, server, share,
-                               auth_info,
+                               creds,
                                max_protocol,
                                dest_ss, port, name_type, &cli);