s3:libsmb: calculate the negotiated SMB1 capabilities in cli_negprot_done()
authorStefan Metzmacher <metze@samba.org>
Thu, 8 Sep 2011 14:14:51 +0000 (16:14 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 15 Sep 2011 06:33:13 +0000 (08:33 +0200)
We calculate the negotiated capabilities based on the mask for:
 - client only flags
 - flags used in both directions
 - server only flags

metze

source3/libsmb/cliconnect.c

index f162e7e3056807c509a35d2c0a3008616fae4c18..e15d0990865fe1dcec97a5731ac8a62e04bd85a2 100644 (file)
@@ -2592,6 +2592,7 @@ static void cli_negprot_done(struct tevent_req *subreq)
        NTSTATUS status;
        uint16_t protnum;
        uint8_t *inbuf;
+       uint32_t both_capabilities;
        uint32_t server_capabilities = 0;
 
        status = cli_smb_recv(subreq, state, &inbuf, 1, &wct, &vwv,
@@ -2729,12 +2730,17 @@ static void cli_negprot_done(struct tevent_req *subreq)
 
        cli->max_xmit = MIN(cli->max_xmit, CLI_BUFFER_SIZE);
 
-       cli->capabilities = server_capabilities;
-
-       /* a way to force ascii SMB */
-       if (cli->force_ascii) {
-               cli->capabilities &= ~CAP_UNICODE;
-       }
+       /*
+        * Now calculate the negotiated capabilities
+        * based on the mask for:
+        * - client only flags
+        * - flags used in both directions
+        * - server only flags
+        */
+       both_capabilities = cli->capabilities & server_capabilities;
+       cli->capabilities = cli->capabilities & SMB_CAP_CLIENT_MASK;
+       cli->capabilities |= both_capabilities & SMB_CAP_BOTH_MASK;
+       cli->capabilities |= server_capabilities & SMB_CAP_SERVER_MASK;
 
        tevent_req_done(req);
 }