1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-22 22:04:08 +03:00

s3:libsmb: split out cli_cm_force_encryption_creds()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Stefan Metzmacher 2016-11-03 17:26:41 +01:00 committed by Andreas Schneider
parent b4340ea774
commit ff23ee7ef2
2 changed files with 28 additions and 15 deletions

View File

@ -42,16 +42,13 @@
Ensure a connection is encrypted.
********************************************************************/
NTSTATUS cli_cm_force_encryption(struct cli_state *c,
const char *username,
const char *password,
const char *domain,
const char *sharename)
NTSTATUS cli_cm_force_encryption_creds(struct cli_state *c,
struct cli_credentials *creds,
const char *sharename)
{
uint16_t major, minor;
uint32_t caplow, caphigh;
NTSTATUS status;
struct cli_credentials *creds = NULL;
if (smbXcli_conn_protocol(c->conn) >= PROTOCOL_SMB2_02) {
status = smb2cli_session_encryption_on(c->smb2.session);
@ -90,6 +87,26 @@ NTSTATUS cli_cm_force_encryption(struct cli_state *c,
return NT_STATUS_UNSUPPORTED_COMPRESSION;
}
status = cli_smb1_setup_encryption(c, creds);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Encryption required and "
"setup failed with error %s.\n",
nt_errstr(status));
return status;
}
return NT_STATUS_OK;
}
NTSTATUS cli_cm_force_encryption(struct cli_state *c,
const char *username,
const char *password,
const char *domain,
const char *sharename)
{
struct cli_credentials *creds = NULL;
NTSTATUS status;
creds = cli_session_creds_init(c,
username,
domain,
@ -103,17 +120,10 @@ NTSTATUS cli_cm_force_encryption(struct cli_state *c,
return NT_STATUS_NO_MEMORY;
}
status = cli_smb1_setup_encryption(c, creds);
status = cli_cm_force_encryption_creds(c, creds, sharename);
/* gensec currently references the creds so we can't free them here */
talloc_unlink(c, creds);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Encryption required and "
"setup failed with error %s.\n",
nt_errstr(status));
return status;
}
return NT_STATUS_OK;
return status;
}
/********************************************************************

View File

@ -133,6 +133,9 @@ struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx,
/* The following definitions come from libsmb/clidfs.c */
NTSTATUS cli_cm_force_encryption_creds(struct cli_state *c,
struct cli_credentials *creds,
const char *sharename);
NTSTATUS cli_cm_force_encryption(struct cli_state *c,
const char *username,
const char *password,