smbXcli: Add "force_channel_sequence"
[metze/samba/wip.git] / libcli / smb / smbXcli_base.c
index cc8978975e10b031f2c8a6c0afd7e17c75ce8bea..e9fdc1dc32a83e2efae12b3df393b28a8079817d 100644 (file)
@@ -138,6 +138,8 @@ struct smbXcli_conn {
 
                uint8_t io_priority;
 
+               bool force_channel_sequence;
+
                uint8_t preauth_sha512[64];
        } smb2;
 
@@ -468,6 +470,11 @@ bool smbXcli_conn_use_unicode(struct smbXcli_conn *conn)
        return false;
 }
 
+bool smbXcli_conn_signing_mandatory(struct smbXcli_conn *conn)
+{
+       return conn->mandatory_signing;
+}
+
 /*
  * [MS-SMB] 2.2.2.3.5 - SMB1 support for passing through
  * query/set commands to the file system
@@ -544,6 +551,17 @@ const struct GUID *smbXcli_conn_server_guid(struct smbXcli_conn *conn)
        return &conn->smb1.server.guid;
 }
 
+bool smbXcli_conn_get_force_channel_sequence(struct smbXcli_conn *conn)
+{
+       return conn->smb2.force_channel_sequence;
+}
+
+void smbXcli_conn_set_force_channel_sequence(struct smbXcli_conn *conn,
+                                            bool v)
+{
+       conn->smb2.force_channel_sequence = v;
+}
+
 struct smbXcli_conn_samba_suicide_state {
        struct smbXcli_conn *conn;
        struct iovec iov;
@@ -873,7 +891,7 @@ static NTSTATUS smbXcli_req_cancel_write_req(struct tevent_req *req)
 
        /*
         * Check if it's possible to cancel the request.
-        * If the result is true it's not to late.
+        * If the result is true it's not too late.
         * See writev_cancel().
         */
        ok = tevent_req_cancel(state->write_req);
@@ -1661,6 +1679,9 @@ static NTSTATUS smb1cli_req_writev_submit(struct tevent_req *req,
        }
 
        if (state->conn->protocol > PROTOCOL_NT1) {
+               DBG_ERR("called for dialect[%s] server[%s]\n",
+                       smb_protocol_types_string(state->conn->protocol),
+                       smbXcli_conn_remote_name(state->conn));
                return NT_STATUS_REVISION_MISMATCH;
        }
 
@@ -2891,7 +2912,7 @@ struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx,
        uint32_t flags = 0;
        uint32_t tid = 0;
        uint64_t uid = 0;
-       bool use_channel_sequence = false;
+       bool use_channel_sequence = conn->smb2.force_channel_sequence;
        uint16_t channel_sequence = 0;
        bool use_replay_flag = false;
 
@@ -4913,10 +4934,19 @@ static void smbXcli_negprot_smb2_done(struct tevent_req *subreq)
                return;
        }
 
+       /*
+        * Here we are now at SMB3_11, so encryption should be
+        * negotiated via context, not capabilities.
+        */
+
        if (conn->smb2.server.capabilities & SMB2_CAP_ENCRYPTION) {
-               tevent_req_nterror(req,
-                               NT_STATUS_INVALID_NETWORK_RESPONSE);
-               return;
+               /*
+                * Server set SMB2_CAP_ENCRYPTION capability,
+                * but *SHOULD* not, not *MUST* not. Just mask it off.
+                * NetApp seems to do this:
+                * BUG: https://bugzilla.samba.org/show_bug.cgi?id=13009
+                */
+               conn->smb2.server.capabilities &= ~SMB2_CAP_ENCRYPTION;
        }
 
        negotiate_context_offset = IVAL(body, 60);