s3:libsmb: split out cli_cm_force_encryption_creds()
authorStefan Metzmacher <metze@samba.org>
Thu, 3 Nov 2016 16:26:41 +0000 (17:26 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 21 Dec 2016 17:35:13 +0000 (18:35 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/libsmb/clidfs.c
source3/libsmb/proto.h

index 0bfe50dc3fdb4f4d9248621c68feea3d2c599a9e..fc6c30a01c4b64e235c1e5cae4c3760be6b4990a 100644 (file)
  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;
 }
 
 /********************************************************************
index aee37717180f9e375507116084544fa732b582b7..62720fd54cd7e0fdf7e098aaffb223fef442fb8a 100644 (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,