Print this page
NEX-15959 SMB 2.1 negotiation failure after NEX-9808
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-15959 SMB 2.1 negotiation failure after NEX-9808
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-9808 SMB3 persistent handles
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-9808 SMB3 persistent handles
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-1643 dtrace provider for smbsrv
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
NEX-5273 SMB 3 Encryption
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
SMB-122 smbd core dumps in smbd_dc_update / smb_log
SMB-117 Win7 fails to open security properties
SMB-96 Codenomicon: SMB2 TC: 141500 - Panic in smb2_decode_create_ctx
SMB-11 SMB2 message parse & dispatch
SMB-12 SMB2 Negotiate Protocol
SMB-13 SMB2 Session Setup
SMB-14 SMB2 Logoff
SMB-15 SMB2 Tree Connect
SMB-16 SMB2 Tree Disconnect
SMB-17 SMB2 Create
SMB-18 SMB2 Close
SMB-19 SMB2 Flush
SMB-20 SMB2 Read
SMB-21 SMB2 Write
SMB-22 SMB2 Lock/Unlock
SMB-23 SMB2 Ioctl
SMB-24 SMB2 Cancel
SMB-25 SMB2 Echo
SMB-26 SMB2 Query Dir
SMB-27 SMB2 Change Notify
SMB-28 SMB2 Query Info
SMB-29 SMB2 Set Info
SMB-30 SMB2 Oplocks
SMB-53 SMB2 Create Context options
(SMB2 code review cleanup 1, 2, 3)
        
@@ -8,19 +8,21 @@
  * source.  A copy of the CDDL is also available via the Internet at
  * http://www.illumos.org/license/CDDL.
  */
 
 /*
- * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
  */
 
 /*
  * Dispatch function for SMB2_TREE_CONNECT
  */
 
 #include <smbsrv/smb2_kproto.h>
 
+#define SMB2_SHARE_CAP_CA SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY
+
 smb_sdrc_t
 smb2_tree_connect(smb_request_t *sr)
 {
         smb_arg_tcon_t  *tcon = &sr->sr_tcon;
         smb_tree_t      *tree = NULL;
@@ -64,11 +66,27 @@
             &sr->smb_data, "%#U",
             sr, (uint_t)PathLength, &tcon->path);
         if (rc)
                 return (SDRC_ERROR);
 
+        DTRACE_SMB2_START(op__TreeConnect, smb_request_t *, sr);
+
+        /*
+         * [MS-SMB2] 3.3.5.7 Receiving an SMB2 TREE_CONNECT Request
+         *
+         * If RejectUnencryptedAccess is TRUE,
+         * global EncryptData or Share.EncryptData is TRUE,
+         * we support 3.x, and srv_cap doesn't indicate encryption support,
+         * return ACCESS_DENIED.
+         *
+         * This also applies to SMB1, so do it in smb_tree_connect_core.
+         */
         status = smb_tree_connect(sr);
+
+        sr->smb2_status = status;
+        DTRACE_SMB2_DONE(op__TreeConnect, smb_request_t *, sr);
+
         if (status) {
                 (void) smb2sr_put_error(sr, status);
                 return (SDRC_SUCCESS);
         }
         tree = sr->tid_tree;
@@ -90,24 +108,30 @@
         }
 
         /*
          * XXX These need work..
          */
+        if (tree->t_encrypt != SMB_CONFIG_DISABLED)
+                ShareFlags = SMB2_SHAREFLAG_ENCRYPT_DATA;
+        else
         ShareFlags = 0;
+
         Capabilities = 0;
+        if ((tree->t_flags & SMB_TREE_DFSROOT) != 0)
+                Capabilities |= SMB2_SHARE_CAP_DFS;
+        if ((tree->t_flags & SMB_TREE_CA) != 0)
+                Capabilities |= SMB2_SHARE_CAP_CA;
 
         /*
          * SMB2 Tree Connect reply
          */
-        rc = smb_mbc_encodef(
+        (void) smb_mbc_encodef(
             &sr->reply,
             "wb.lll",
             16, /* StructSize */        /* w */
             ShareType,                  /* b */
             ShareFlags,                 /* l */
             Capabilities,               /* l */
             tree->t_access);            /* l */
-        if (rc)
-                return (SDRC_ERROR);
 
         return (SDRC_SUCCESS);
 }