summaryrefslogtreecommitdiff
path: root/source3/libsmb/clidfs.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2020-08-18 17:15:09 +0200
committerJeremy Allison <jra@samba.org>2020-10-09 19:16:45 +0000
commit276563de06f2071ec2ed9a8b73f92215ab621bba (patch)
treeaba9114c6949d26694f2b9a1691ff18685f02a1f /source3/libsmb/clidfs.c
parent4ddec1ca257fff418847c5d1e83a3fb7cb5ade1a (diff)
downloadsamba-276563de06f2071ec2ed9a8b73f92215ab621bba.tar.gz
s3:libsmb: Pass cli_credentials to clidfs do_connect()
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/libsmb/clidfs.c')
-rw-r--r--source3/libsmb/clidfs.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index 736c565a7a8..d536e0597af 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -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);