Print this page
    
NEX-14666 Need to provide SMB 2.1 Client
NEX-17187 panic in smbfs_acl_store
NEX-17231 smbfs create xattr files finds wrong file
NEX-17224 smbfs lookup EINVAL should be ENOENT
NEX-17260 SMB1 client fails to list directory after NEX-14666
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
and: (cleanup)
NEX-16824 SMB client connection setup rework
NEX-17232 SMB client reconnect failures
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
and: (improve debug)
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/common/netsmb/smb.h
          +++ new/usr/src/uts/common/netsmb/smb.h
   1    1  /*
   2    2   * Copyright (c) 2000-2001 Boris Popov
   3    3   * All rights reserved.
   4    4   *
   5    5   * Now many of these defines are from samba4 code, by Andrew Tridgell.
   6    6   * (Permission given to Conrad Minshall at CIFS plugfest Aug 13 2003.)
   7    7   * (Note the main decision was whether to use defines found in MS includes
   8    8   * and web pages, versus Samba, and the deciding factor is which developers
   9    9   * are more likely to be looking at this code base.)
  10   10   *
  11   11   * Redistribution and use in source and binary forms, with or without
  12   12   * modification, are permitted provided that the following conditions
  13   13   * are met:
  14   14   * 1. Redistributions of source code must retain the above copyright
  15   15   *    notice, this list of conditions and the following disclaimer.
  16   16   * 2. Redistributions in binary form must reproduce the above copyright
  17   17   *    notice, this list of conditions and the following disclaimer in the
  18   18   *    documentation and/or other materials provided with the distribution.
  19   19   * 3. All advertising materials mentioning features or use of this software
  20   20   *    must display the following acknowledgement:
  21   21   *    This product includes software developed by Boris Popov.
  22   22   * 4. Neither the name of the author nor the names of any co-contributors
  23   23   *    may be used to endorse or promote products derived from this software
  24   24   *    without specific prior written permission.
  25   25   *
  26   26   * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  27   27   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28   28   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29   29   * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  30   30   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31   31   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  32   32   * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  
    | 
      ↓ open down ↓ | 
    32 lines elided | 
    
      ↑ open up ↑ | 
  
  33   33   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  34   34   * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  35   35   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36   36   * SUCH DAMAGE.
  37   37   *
  38   38   * $Id: smb.h,v 1.36.90.1 2005/05/27 02:35:29 lindak Exp $
  39   39   */
  40   40  
  41   41  /*
  42   42   * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
       43 + * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  43   44   */
  44   45  
  45   46  #ifndef _NETSMB_SMB_H_
  46   47  #define _NETSMB_SMB_H_
  47   48  
  48   49  /*
  49   50   * Common definitions and structures for SMB/CIFS protocol
  50   51   * This file should be purely SMB protocol definition stuff.
  51   52   * (Please don't make it a catch-all:)
  52   53   */
  53   54  
  54   55  #include <smb/doserror.h>
  55   56  #include <smb/lmerr.h>
  56   57  #include <smb/nterror.h>
  57   58  #include <smb/ntstatus.h>
  58   59  
  
    | 
      ↓ open down ↓ | 
    6 lines elided | 
    
      ↑ open up ↑ | 
  
  59   60  /*
  60   61   * SMB dialects that we have to deal with.
  61   62   */
  62   63  enum smb_dialects {
  63   64          SMB_DIALECT_NONE,
  64   65          SMB_DIALECT_CORE,               /* PC NETWORK PROGRAM 1.0, PCLAN1.0 */
  65   66          SMB_DIALECT_COREPLUS,           /* MICROSOFT NETWORKS 1.03 */
  66   67          SMB_DIALECT_LANMAN1_0,          /* MICROSOFT NETWORKS 3.0, LANMAN1.0 */
  67   68          SMB_DIALECT_LANMAN2_0,          /* LM1.2X002, DOS LM1.2X002, Samba */
  68   69          SMB_DIALECT_LANMAN2_1,          /* DOS LANMAN2.1, LANMAN2.1 */
  69      -        SMB_DIALECT_NTLM0_12            /* NT LM 0.12, Windows for Workgroups */
  70      -                                        /* 3.1a, * NT LANMAN 1.0 */
       70 +        SMB_DIALECT_NTLM0_12,           /* NT LM 0.12, etc. */
       71 +        SMB_DIALECT_SMB2_FF             /* SMB1 negotiate to SMB2 */
  71   72  };
  72   73  
  73   74  /*
  74   75   * Formats of data/string buffers
  75   76   */
  76   77  #define SMB_DT_DATA             1
  77   78  #define SMB_DT_DIALECT          2
  78   79  #define SMB_DT_PATHNAME         3
  79   80  #define SMB_DT_ASCII            4
  80   81  #define SMB_DT_VARIABLE         5
  81   82  
  82   83  /*
  83   84   * SMB header
  84   85   */
       86 +
  85   87  #define SMB_SIGNATURE           "\xFFSMB"
  86   88  #define SMB_SIGLEN              4
  87   89  #define SMB_HDRCMD(p)           (*((uchar_t *)(p) + SMB_SIGLEN))
  88   90  #define SMB_HDRMID(p)           (*(ushort_t *)((uchar_t *)(p) + 30))
       91 +#define SMB_HDR_OFF_MID         30
  89   92  #define SMB_HDRLEN              32
       93 +
       94 +#define SMB_HDR_V1      0xFF
       95 +#define SMB_HDR_V2      0xFE
       96 +#define SMB_HDR_V3E     0xFD    /* SMB3 encrypted */
       97 +
  90   98  /*
  91   99   * bits in the smb_flags field
  92  100   */
  93  101  #define SMB_FLAGS_SUPPORT_LOCKREAD      0x01
  94  102  #define SMB_FLAGS_CLIENT_BUF_AVAIL      0x02
  95  103  #define SMB_FLAGS_CASELESS              0x08
  96  104  #define SMB_FLAGS_CANONICAL_PATHNAMES   0x10
  97  105  #define SMB_FLAGS_REQUEST_OPLOCK        0x20
  98  106  #define SMB_FLAGS_REQUEST_BATCH_OPLOCK  0x40
  99  107  #define SMB_FLAGS_SERVER_RESP           0x80
 100  108  
 101  109  /*
 102  110   * bits in the smb_flags2 field
 103  111   */
 104  112  #define SMB_FLAGS2_KNOWS_LONG_NAMES     0x0001
 105  113  #define SMB_FLAGS2_KNOWS_EAS            0x0002  /* client know about EAs */
 106  114  #define SMB_FLAGS2_SECURITY_SIGNATURE   0x0004  /* check SMB integrity */
 107  115  #define SMB_FLAGS2_IS_LONG_NAME         0x0040  /* any path name is long name */
 108  116  #define SMB_FLAGS2_EXT_SEC              0x0800  /* client aware of Extended */
 109  117                                                  /* Security negotiation */
 110  118  #define SMB_FLAGS2_DFS                  0x1000  /* resolve paths in DFS */
 111  119  #define SMB_FLAGS2_PAGING_IO            0x2000  /* for exec */
 112  120  #define SMB_FLAGS2_ERR_STATUS           0x4000  /* 1 - status.status */
 113  121  #define SMB_FLAGS2_UNICODE              0x8000  /* use Unicode for strings */
 114  122  
 115  123  #define SMB_UID_UNKNOWN         0xffff
 116  124  #define SMB_TID_UNKNOWN         0xffff
 117  125  #define SMB_FID_UNUSED          0xffff
 118  126  
 119  127  /*
 120  128   * Security mode bits
 121  129   */
 122  130  #define SMB_SM_USER             0x01    /* server in the user security mode */
 123  131  #define SMB_SM_ENCRYPT          0x02    /* use challenge/responce */
 124  132  #define SMB_SM_SIGS             0x04
 125  133  #define SMB_SM_SIGS_REQUIRE     0x08
 126  134  
 127  135  /*
 128  136   * Action bits in session setup reply
 129  137   */
 130  138  #define SMB_ACT_GUEST           0x01
 131  139  
 132  140  /*
 133  141   * NTLM capabilities
 134  142   */
 135  143  #define SMB_CAP_RAW_MODE                0x0001
 136  144  #define SMB_CAP_MPX_MODE                0x0002
 137  145  #define SMB_CAP_UNICODE                 0x0004
 138  146  #define SMB_CAP_LARGE_FILES             0x0008  /* 64 bit offsets supported */
 139  147  #define SMB_CAP_NT_SMBS                 0x0010
 140  148  #define SMB_CAP_RPC_REMOTE_APIS         0x0020
 141  149  #define SMB_CAP_STATUS32                0x0040
 142  150  #define SMB_CAP_LEVEL_II_OPLOCKS        0x0080
 143  151  #define SMB_CAP_LOCK_AND_READ           0x0100
  
    | 
      ↓ open down ↓ | 
    44 lines elided | 
    
      ↑ open up ↑ | 
  
 144  152  #define SMB_CAP_NT_FIND                 0x0200
 145  153  #define SMB_CAP_DFS                     0x1000
 146  154  #define SMB_CAP_INFOLEVEL_PASSTHRU      0x2000
 147  155  #define SMB_CAP_LARGE_READX             0x4000
 148  156  #define SMB_CAP_LARGE_WRITEX            0x8000
 149  157  #define SMB_CAP_UNIX                    0x00800000
 150  158  #define SMB_CAP_BULK_TRANSFER           0x20000000
 151  159  #define SMB_CAP_COMPRESSED_DATA         0x40000000
 152  160  #define SMB_CAP_EXT_SECURITY            0x80000000
 153  161  
      162 +/* SMB_COM_TREE_CONNECT_ANDX  flags. See [MS-SMB] for a complete description. */
      163 +#define TREE_CONNECT_ANDX_DISCONNECT_TID                0x0001
      164 +#define TREE_CONNECT_ANDX_EXTENDED_SIGNATURES   0x0004
      165 +#define TREE_CONNECT_ANDX_EXTENDED_RESPONSE             0x0008
      166 +
 154  167  /*
      168 + * SMB_COM_TREE_CONNECT_ANDX  optional support flags. See [MS-SMB] for a
      169 + * complete description.
      170 + */
      171 +#define SMB_SUPPORT_SEARCH_BITS         0x0001  /* supports SearchAttributes */
      172 +#define SMB_SHARE_IS_IN_DFS             0x0002  /* share is managed by DFS */
      173 +#define SMB_CSC_MASK                    0x000C  /* Offline-caching bits. */
      174 +#define SMB_UNIQUE_FILE_NAME            0x0010  /* Long file names only */
      175 +#define SMB_EXTENDED_SIGNATURES         0x0020  /* Signing key protection. */
      176 +/* See [MS-SMB] for a complete description of SMB_CSC_MASK bits. */
      177 +#define SMB_CSC_CACHE_MANUAL_REINT      0x0000
      178 +#define SMB_CSC_CACHE_AUTO_REINT        0x0004
      179 +#define SMB_CSC_CACHE_VDO               0x0008
      180 +
      181 +/*
 155  182   * File attributes
 156  183   */
 157  184  #define SMB_FA_RDONLY           0x01
 158  185  #define SMB_FA_HIDDEN           0x02
 159  186  #define SMB_FA_SYSTEM           0x04
 160  187  #define SMB_FA_VOLUME           0x08
 161  188  #define SMB_FA_DIR              0x10
 162  189  #define SMB_FA_ARCHIVE          0x20
 163  190  
 164  191  /*
 165  192   * Extended file attributes
 166  193   */
 167  194  #define SMB_EFA_RDONLY                  0x00000001
 168  195  #define SMB_EFA_HIDDEN                  0x00000002
 169  196  #define SMB_EFA_SYSTEM                  0x00000004
 170  197  #define SMB_EFA_VOLUME                  0x00000008
 171  198  #define SMB_EFA_DIRECTORY               0x00000010
 172  199  #define SMB_EFA_ARCHIVE                 0x00000020
 173  200  #define SMB_EFA_DEVICE                  0x00000040
 174  201  #define SMB_EFA_NORMAL                  0x00000080
 175  202  #define SMB_EFA_TEMPORARY               0x00000100
 176  203  #define SMB_EFA_SPARSE                  0x00000200
 177  204  #define SMB_EFA_REPARSE_POINT           0x00000400
 178  205  #define SMB_EFA_COMPRESSED              0x00000800
 179  206  #define SMB_EFA_OFFLINE                 0x00001000
 180  207  #define SMB_EFA_NONINDEXED              0x00002000
 181  208  #define SMB_EFA_ENCRYPTED               0x00004000
 182  209  #define SMB_EFA_POSIX_SEMANTICS         0x01000000
 183  210  #define SMB_EFA_BACKUP_SEMANTICS        0x02000000
 184  211  #define SMB_EFA_DELETE_ON_CLOSE         0x04000000
 185  212  #define SMB_EFA_SEQUENTIAL_SCAN         0x08000000
 186  213  #define SMB_EFA_RANDOM_ACCESS           0x10000000
 187  214  #define SMB_EFA_NO_BUFFERING            0x20000000
 188  215  #define SMB_EFA_WRITE_THROUGH           0x80000000
 189  216  
 190  217  /*
 191  218   * Access Mode Encoding
 192  219   */
 193  220  #define SMB_AM_OPENREAD         0x0000
 194  221  #define SMB_AM_OPENWRITE        0x0001
 195  222  #define SMB_AM_OPENRW           0x0002
 196  223  #define SMB_AM_OPENEXEC         0x0003
 197  224  #define SMB_AM_OPENMODE         0x0003  /* mask for access mode bits */
 198  225  #define SMB_SM_COMPAT           0x0000
 199  226  #define SMB_SM_EXCLUSIVE        0x0010
 200  227  #define SMB_SM_DENYWRITE        0x0020
 201  228  #define SMB_SM_DENYREADEXEC     0x0030
 202  229  #define SMB_SM_DENYNONE         0x0040
 203  230  
 204  231  /* NT_CREATE_ANDX flags */
 205  232  #define NTCREATEX_FLAGS_REQUEST_OPLOCK          0x02
 206  233  #define NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK    0x04
 207  234  #define NTCREATEX_FLAGS_OPEN_DIRECTORY          0x08
 208  235  #define NTCREATEX_FLAGS_EXTENDED                0x10
 209  236  
 210  237  /* NT_CREATE_ANDX share_access (share mode) */
 211  238  #define NTCREATEX_SHARE_ACCESS_NONE             0
 212  239  #define NTCREATEX_SHARE_ACCESS_READ             1
 213  240  #define NTCREATEX_SHARE_ACCESS_WRITE            2
 214  241  #define NTCREATEX_SHARE_ACCESS_DELETE           4
 215  242  #define NTCREATEX_SHARE_ACCESS_ALL              7
 216  243  
 217  244  /* NT_CREATE_ANDX open_disposition */
 218  245  #define NTCREATEX_DISP_SUPERSEDE        0 /* if file exists supersede it */
 219  246  #define NTCREATEX_DISP_OPEN             1 /* exists ? open it : fail */
 220  247  #define NTCREATEX_DISP_CREATE           2 /* exists ? fail : create it */
 221  248  #define NTCREATEX_DISP_OPEN_IF          3 /* exists ? open it : create it */
 222  249  #define NTCREATEX_DISP_OVERWRITE        4 /* exists ? overwrite : fail */
 223  250  #define NTCREATEX_DISP_OVERWRITE_IF     5 /* exists ? overwrite : create */
 224  251  
 225  252  /* NT_CREATE_ANDX create_options */
 226  253  #define NTCREATEX_OPTIONS_DIRECTORY             0x0001
 227  254  #define NTCREATEX_OPTIONS_WRITE_THROUGH         0x0002
 228  255  #define NTCREATEX_OPTIONS_SEQUENTIAL_ONLY       0x0004
 229  256  #define NTCREATEX_OPTIONS_SYNC_ALERT            0x0010
 230  257  #define NTCREATEX_OPTIONS_ASYNC_ALERT           0x0020
 231  258  #define NTCREATEX_OPTIONS_NON_DIRECTORY_FILE    0x0040
 232  259  #define NTCREATEX_OPTIONS_NO_EA_KNOWLEDGE       0x0200
 233  260  #define NTCREATEX_OPTIONS_EIGHT_DOT_THREE_ONLY  0x0400
 234  261  #define NTCREATEX_OPTIONS_RANDOM_ACCESS         0x0800
 235  262  #define NTCREATEX_OPTIONS_DELETE_ON_CLOSE       0x1000
 236  263  #define NTCREATEX_OPTIONS_OPEN_BY_FILE_ID       0x2000
 237  264  
 238  265  /* NT_CREATE_ANDX "impersonation" */
 239  266  #define NTCREATEX_IMPERSONATION_ANONYMOUS               0
 240  267  #define NTCREATEX_IMPERSONATION_IDENTIFICATION          1
 241  268  #define NTCREATEX_IMPERSONATION_IMPERSONATION           2
 242  269  #define NTCREATEX_IMPERSONATION_DELEGATION              3
 243  270  
 244  271  /* NT_CREATE_ANDX security flags */
 245  272  #define NTCREATEX_SECURITY_DYNAMIC      1
 246  273  #define NTCREATEX_SECURITY_ALL          2
 247  274  
 248  275  /* NT_CREATE_ANDX create_action in reply */
 249  276  #define NTCREATEX_ACTION_EXISTED        1
 250  277  #define NTCREATEX_ACTION_CREATED        2
 251  278  #define NTCREATEX_ACTION_TRUNCATED      3
 252  279  
 253  280  /* SMB_TRANS2_FIND_FIRST2/SMB_TRANS2_FIND_NEXT2 flags */
 254  281  #define FIND2_CLOSE_AFTER_REQUEST       0x0001
 255  282  #define FIND2_CLOSE_ON_EOS              0x0002
 256  283  #define FIND2_RETURN_RESUME_KEYS        0x0004
 257  284  #define FIND2_CONTINUE_SEARCH           0x0008
 258  285  #define FIND2_BACKUP_INTENT             0x0010
 259  286  
 260  287  /*
 261  288   * SMB commands
 262  289   */
 263  290  #define SMB_COM_CREATE_DIRECTORY        0x00
 264  291  #define SMB_COM_DELETE_DIRECTORY        0x01
 265  292  #define SMB_COM_OPEN                    0x02
 266  293  #define SMB_COM_CREATE                  0x03
 267  294  #define SMB_COM_CLOSE                   0x04
 268  295  #define SMB_COM_FLUSH                   0x05
 269  296  #define SMB_COM_DELETE                  0x06
 270  297  #define SMB_COM_RENAME                  0x07
 271  298  #define SMB_COM_QUERY_INFORMATION       0x08
 272  299  #define SMB_COM_SET_INFORMATION         0x09
 273  300  #define SMB_COM_READ                    0x0A
 274  301  #define SMB_COM_WRITE                   0x0B
 275  302  #define SMB_COM_LOCK_BYTE_RANGE         0x0C
 276  303  #define SMB_COM_UNLOCK_BYTE_RANGE       0x0D
 277  304  #define SMB_COM_CREATE_TEMPORARY        0x0E
 278  305  #define SMB_COM_CREATE_NEW              0x0F
 279  306  #define SMB_COM_CHECK_DIRECTORY         0x10
 280  307  #define SMB_COM_PROCESS_EXIT            0x11
 281  308  #define SMB_COM_SEEK                    0x12
 282  309  #define SMB_COM_LOCK_AND_READ           0x13
 283  310  #define SMB_COM_WRITE_AND_UNLOCK        0x14
 284  311  #define SMB_COM_READ_RAW                0x1A
 285  312  #define SMB_COM_READ_MPX                0x1B
 286  313  #define SMB_COM_READ_MPX_SECONDARY      0x1C
 287  314  #define SMB_COM_WRITE_RAW               0x1D
 288  315  #define SMB_COM_WRITE_MPX               0x1E
 289  316  #define SMB_COM_WRITE_COMPLETE          0x20
 290  317  #define SMB_COM_SET_INFORMATION2        0x22
 291  318  #define SMB_COM_QUERY_INFORMATION2      0x23
 292  319  #define SMB_COM_LOCKING_ANDX            0x24
 293  320  #define SMB_COM_TRANSACTION             0x25
 294  321  #define SMB_COM_TRANSACTION_SECONDARY   0x26
 295  322  #define SMB_COM_IOCTL                   0x27
 296  323  #define SMB_COM_IOCTL_SECONDARY         0x28
 297  324  #define SMB_COM_COPY                    0x29
 298  325  #define SMB_COM_MOVE                    0x2A
 299  326  #define SMB_COM_ECHO                    0x2B
 300  327  #define SMB_COM_WRITE_AND_CLOSE         0x2C
 301  328  #define SMB_COM_OPEN_ANDX               0x2D
 302  329  #define SMB_COM_READ_ANDX               0x2E
 303  330  #define SMB_COM_WRITE_ANDX              0x2F
 304  331  #define SMB_COM_CLOSE_AND_TREE_DISC     0x31
 305  332  #define SMB_COM_TRANSACTION2            0x32
 306  333  #define SMB_COM_TRANSACTION2_SECONDARY  0x33
 307  334  #define SMB_COM_FIND_CLOSE2             0x34
 308  335  #define SMB_COM_FIND_NOTIFY_CLOSE       0x35
 309  336  #define SMB_COM_TREE_CONNECT            0x70
 310  337  #define SMB_COM_TREE_DISCONNECT         0x71
 311  338  #define SMB_COM_NEGOTIATE               0x72
 312  339  #define SMB_COM_SESSION_SETUP_ANDX      0x73
 313  340  #define SMB_COM_LOGOFF_ANDX             0x74
 314  341  #define SMB_COM_TREE_CONNECT_ANDX       0x75
 315  342  #define SMB_COM_QUERY_INFORMATION_DISK  0x80
 316  343  #define SMB_COM_SEARCH                  0x81
 317  344  #define SMB_COM_FIND                    0x82
 318  345  #define SMB_COM_FIND_UNIQUE             0x83
 319  346  #define SMB_COM_NT_TRANSACT             0xA0
 320  347  #define SMB_COM_NT_TRANSACT_SECONDARY   0xA1
 321  348  #define SMB_COM_NT_CREATE_ANDX          0xA2
 322  349  #define SMB_COM_NT_CANCEL               0xA4
 323  350  #define SMB_COM_OPEN_PRINT_FILE         0xC0
 324  351  #define SMB_COM_WRITE_PRINT_FILE        0xC1
 325  352  #define SMB_COM_CLOSE_PRINT_FILE        0xC2
 326  353  #define SMB_COM_GET_PRINT_QUEUE         0xC3
 327  354  #define SMB_COM_READ_BULK               0xD8
 328  355  #define SMB_COM_WRITE_BULK              0xD9
 329  356  #define SMB_COM_WRITE_BULK_DATA         0xDA
 330  357  
 331  358  /*
 332  359   * SMB_COM_TRANSACTION2 subcommands
 333  360   */
 334  361  #define SMB_TRANS2_OPEN2                        0x00
 335  362  #define SMB_TRANS2_FIND_FIRST2                  0x01
 336  363  #define SMB_TRANS2_FIND_NEXT2                   0x02
 337  364  #define SMB_TRANS2_QUERY_FS_INFORMATION         0x03
 338  365  #define SMB_TRANS2_SETFSINFO                    0x04
 339  366  #define SMB_TRANS2_QUERY_PATH_INFORMATION       0x05
 340  367  #define SMB_TRANS2_SET_PATH_INFORMATION         0x06
 341  368  #define SMB_TRANS2_QUERY_FILE_INFORMATION       0x07
 342  369  #define SMB_TRANS2_SET_FILE_INFORMATION         0x08
 343  370  #define SMB_TRANS2_FSCTL                        0x09
 344  371  #define SMB_TRANS2_IOCTL2                       0x0A
 345  372  #define SMB_TRANS2_FIND_NOTIFY_FIRST            0x0B
 346  373  #define SMB_TRANS2_FIND_NOTIFY_NEXT             0x0C
 347  374  #define SMB_TRANS2_CREATE_DIRECTORY             0x0D
 348  375  #define SMB_TRANS2_SESSION_SETUP                0x0E
 349  376  #define SMB_TRANS2_GET_DFS_REFERRAL             0x10
 350  377  #define SMB_TRANS2_REPORT_DFS_INCONSISTENCY     0x11
 351  378  
 352  379  /*
 353  380   * SMB_COM_NT_TRANSACT subcommands
 354  381   */
 355  382  #define NT_TRANSACT_CREATE              0x01
 356  383  #define NT_TRANSACT_IOCTL               0x02
 357  384  #define NT_TRANSACT_SET_SECURITY_DESC   0x03
 358  385  #define NT_TRANSACT_NOTIFY_CHANGE       0x04
 359  386  #define NT_TRANSACT_RENAME              0x05
 360  387  #define NT_TRANSACT_QUERY_SECURITY_DESC 0x06
 361  388  #define NT_TRANSACT_GET_USER_QUOTA      0x07
 362  389  #define NT_TRANSACT_SET_USER_QUOTA      0x08
 363  390  
 364  391  /*
  
    | 
      ↓ open down ↓ | 
    200 lines elided | 
    
      ↑ open up ↑ | 
  
 365  392   * SMB_TRANS2_QUERY_FS_INFORMATION levels
 366  393   */
 367  394  #define SMB_QFS_ALLOCATION                      1
 368  395  #define SMB_QFS_VOLUME                          2
 369  396  #define SMB_QFS_LABEL_INFO                      0x101
 370  397  #define SMB_QFS_VOLUME_INFO                     0x102
 371  398  #define SMB_QFS_SIZE_INFO                       0x103
 372  399  #define SMB_QFS_DEVICE_INFO                     0x104
 373  400  #define SMB_QFS_ATTRIBUTE_INFO                  0x105
 374  401  #define SMB_QFS_UNIX_INFO                       0x200
      402 +#define SMB_QFS_POSIX_WHOAMI                    0x202
 375  403  #define SMB_QFS_MAC_FS_INFO                     0x301
 376  404  #define SMB_QFS_VOLUME_INFORMATION              1001
 377  405  #define SMB_QFS_SIZE_INFORMATION                1003
 378  406  #define SMB_QFS_DEVICE_INFORMATION              1004
 379  407  #define SMB_QFS_ATTRIBUTE_INFORMATION           1005
 380  408  #define SMB_QFS_QUOTA_INFORMATION               1006
 381  409  #define SMB_QFS_FULL_SIZE_INFORMATION           1007
 382  410  #define SMB_QFS_OBJECTID_INFORMATION            1008
 383  411  
      412 +/*
      413 + * NT Notify Change Compeletion Filter
      414 + * NT Notify Actions
      415 + * (We don't use these.)
      416 + */
 384  417  
 385  418  /*
 386  419   * SMB_QFS_ATTRIBUTE_INFO bits.
 387  420   * The following info found in msdn
 388  421   * (http://msdn.microsoft.com/library/default.asp?
 389  422   * url=/library/en-us/wmisdk/wmi/win32_cdromdrive.asp)
 390  423   * Naming is mostly as in samba, to help Those Who Google.
 391  424   */
 392  425  #define FILE_CASE_SENSITIVE_SEARCH      0x00000001
 393  426  #define FILE_CASE_PRESERVED_NAMES       0x00000002
 394  427  #define FILE_UNICODE_ON_DISK            0x00000004
 395  428  #define FILE_PERSISTENT_ACLS            0x00000008
  
    | 
      ↓ open down ↓ | 
    2 lines elided | 
    
      ↑ open up ↑ | 
  
 396  429  #define FILE_FILE_COMPRESSION           0x00000010
 397  430  #define FILE_VOLUME_QUOTAS              0x00000020
 398  431  #define FILE_SUPPORTS_SPARSE_FILES      0x00000040
 399  432  #define FILE_SUPPORTS_REPARSE_POINTS    0x00000080
 400  433  #define FILE_SUPPORTS_REMOTE_STORAGE    0x00000100
 401  434  #define FILE_SUPPORTS_LONG_NAMES        0x00004000
 402  435  #define FILE_VOLUME_IS_COMPRESSED       0x00008000
 403  436  #define FILE_SUPPORTS_OBJECT_IDS        0x00010000
 404  437  #define FILE_SUPPORTS_ENCRYPTION        0x00020000
 405  438  #define FILE_NAMED_STREAMS              0x00040000
      439 +#define FILE_READ_ONLY_VOLUME           0x00080000
 406  440  
 407  441  /*
 408  442   * SMB_TRANS2_QUERY_PATH levels
 409  443   */
 410  444  #define SMB_QFILEINFO_STANDARD                  1
 411  445  #define SMB_QFILEINFO_EA_SIZE                   2
 412  446  #define SMB_QFILEINFO_EAS_FROM_LIST             3
 413  447  #define SMB_QFILEINFO_ALL_EAS                   4
 414  448  #define SMB_QFILEINFO_IS_NAME_VALID             6       /* QPATHINFO only? */
 415  449  #define SMB_QFILEINFO_BASIC_INFO                0x101
 416  450  #define SMB_QFILEINFO_STANDARD_INFO             0x102
  
    | 
      ↓ open down ↓ | 
    1 lines elided | 
    
      ↑ open up ↑ | 
  
 417  451  #define SMB_QFILEINFO_EA_INFO                   0x103
 418  452  #define SMB_QFILEINFO_NAME_INFO                 0x104
 419  453  #define SMB_QFILEINFO_ALLOCATION_INFO           0x105
 420  454  #define SMB_QFILEINFO_END_OF_FILE_INFO          0x106
 421  455  #define SMB_QFILEINFO_ALL_INFO                  0x107
 422  456  #define SMB_QFILEINFO_ALT_NAME_INFO             0x108
 423  457  #define SMB_QFILEINFO_STREAM_INFO               0x109
 424  458  #define SMB_QFILEINFO_COMPRESSION_INFO          0x10b
 425  459  #define SMB_QFILEINFO_UNIX_BASIC                0x200
 426  460  #define SMB_QFILEINFO_UNIX_LINK                 0x201
      461 +#define SMB_QFILEINFO_POSIX_ACL                 0x204
      462 +#define SMB_QFILEINFO_UNIX_INFO2                0x20B
 427  463  #define SMB_QFILEINFO_MAC_DT_GET_APPL           0x306
 428  464  #define SMB_QFILEINFO_MAC_DT_GET_ICON           0x307
 429  465  #define SMB_QFILEINFO_MAC_DT_GET_ICON_INFO      0x308
      466 +#define SMB_QFILEINFO_MAC_SPOTLIGHT             0x310
 430  467  #define SMB_QFILEINFO_BASIC_INFORMATION         1004
 431  468  #define SMB_QFILEINFO_STANDARD_INFORMATION      1005
 432  469  #define SMB_QFILEINFO_INTERNAL_INFORMATION      1006
 433  470  #define SMB_QFILEINFO_EA_INFORMATION            1007
 434  471  #define SMB_QFILEINFO_ACCESS_INFORMATION        1008
 435  472  #define SMB_QFILEINFO_NAME_INFORMATION          1009
 436  473  #define SMB_QFILEINFO_POSITION_INFORMATION      1014
 437  474  #define SMB_QFILEINFO_MODE_INFORMATION          1016
 438  475  #define SMB_QFILEINFO_ALIGNMENT_INFORMATION     1017
 439  476  #define SMB_QFILEINFO_ALL_INFORMATION           1018
 440  477  #define SMB_QFILEINFO_ALT_NAME_INFORMATION      1021
 441  478  #define SMB_QFILEINFO_STREAM_INFORMATION        1022
 442  479  #define SMB_QFILEINFO_COMPRESSION_INFORMATION   1028
 443  480  #define SMB_QFILEINFO_NETWORK_OPEN_INFORMATION  1034
 444  481  #define SMB_QFILEINFO_ATTRIBUTE_TAG_INFORMATION 1035
 445  482  
 446  483  /*
  
    | 
      ↓ open down ↓ | 
    7 lines elided | 
    
      ↑ open up ↑ | 
  
 447  484   * SMB_TRANS2_FIND_FIRST2 information levels
 448  485   */
 449  486  #define SMB_FIND_STANDARD               1
 450  487  #define SMB_FIND_EA_SIZE                2
 451  488  #define SMB_FIND_EAS_FROM_LIST          3
 452  489  #define SMB_FIND_DIRECTORY_INFO         0x101
 453  490  #define SMB_FIND_FULL_DIRECTORY_INFO    0x102
 454  491  #define SMB_FIND_NAME_INFO              0x103
 455  492  #define SMB_FIND_BOTH_DIRECTORY_INFO    0x104
 456  493  #define SMB_FIND_UNIX_INFO              0x200
      494 +/* Transact 2 Find First levels */
      495 +#define SMB_FIND_FILE_UNIX              0x202
      496 +#define SMB_FIND_FILE_UNIX_INFO2        0x20B /* UNIX File Info2 */
 457  497  
 458  498  /*
 459  499   * Selectors for NT_TRANSACT_QUERY_SECURITY_DESC and
 460  500   * NT_TRANSACT_SET_SECURITY_DESC.  Details found in the MSDN
 461  501   * library by searching on security_information.
 462  502   * Note the protected/unprotected bits did not exist in NT.
 463  503   */
 464  504  
 465  505  #define OWNER_SECURITY_INFORMATION              0x00000001
 466  506  #define GROUP_SECURITY_INFORMATION              0x00000002
 467  507  #define DACL_SECURITY_INFORMATION               0x00000004
 468  508  #define SACL_SECURITY_INFORMATION               0x00000008
 469  509  #define UNPROTECTED_SACL_SECURITY_INFORMATION   0x10000000
 470  510  #define UNPROTECTED_DACL_SECURITY_INFORMATION   0x20000000
 471  511  #define PROTECTED_SACL_SECURITY_INFORMATION     0x40000000
 472  512  #define PROTECTED_DACL_SECURITY_INFORMATION     0x80000000
 473  513  
 474  514  /*
 475  515   * security descriptor header
 476  516   * it is followed by the optional SIDs and ACLs
 477  517   * note this is "raw", ie little-endian
 478  518   */
 479  519  struct ntsecdesc {
 480  520          uint8_t         sd_revision;    /* 0x01 observed between W2K */
 481  521          uint8_t         sd_pad1;
 482  522          uint16_t        sd_flags;
 483  523          uint32_t        sd_owneroff;    /* offset to owner SID */
 484  524          uint32_t        sd_groupoff;    /* offset to group SID */
 485  525          uint32_t        sd_sacloff;     /* offset to system/audit ACL */
 486  526          uint32_t        sd_dacloff;     /* offset to discretionary ACL */
 487  527  }; /* XXX: __attribute__((__packed__)); */
 488  528  typedef struct ntsecdesc ntsecdesc_t;
 489  529  
 490  530  #define wset_sdrevision(s) ((s)->sd_revision = 0x01)
 491  531  #define sdflags(s) (letohs((s)->sd_flags))
 492  532  #define wset_sdflags(s, f) ((s)->sd_flags = letohs(f))
 493  533  #define sdowner(s) \
 494  534          ((struct ntsid *)((s)->sd_owneroff ? \
 495  535          (char *)(s) + letohl((s)->sd_owneroff) : \
 496  536          NULL))
 497  537  #define wset_sdowneroff(s, o) ((s)->sd_owneroff = htolel(o))
 498  538  #define sdgroup(s) \
 499  539          ((struct ntsid *)((s)->sd_groupoff ? \
 500  540          (char *)(s) + letohl((s)->sd_groupoff) : \
 501  541          NULL))
 502  542  #define wset_sdgroupoff(s, o) ((s)->sd_groupoff = htolel(o))
 503  543  #define sdsacl(s) \
 504  544          ((struct ntacl *)((s)->sd_sacloff ? \
 505  545          (char *)(s) + letohl((s)->sd_sacloff) : \
 506  546          NULL))
 507  547  #define wset_sdsacloff(s, o) ((s)->sd_sacloff = htolel(o))
 508  548  #define sddacl(s) \
 509  549          ((struct ntacl *)((s)->sd_dacloff ? \
 510  550          (char *)(s) + letohl((s)->sd_dacloff) : \
 511  551          NULL))
 512  552  #define wset_sddacloff(s, o) ((s)->sd_dacloff = htolel(o))
 513  553  
 514  554  /*
 515  555   * sd_flags bits
 516  556   */
 517  557  #define SD_OWNER_DEFAULTED              0x0001
 518  558  #define SD_GROUP_DEFAULTED              0x0002
 519  559  #define SD_DACL_PRESENT                 0x0004
 520  560  #define SD_DACL_DEFAULTED               0x0008
 521  561  #define SD_SACL_PRESENT                 0x0010
 522  562  #define SD_SACL_DEFAULTED               0x0020
 523  563  #define SD_DACL_TRUSTED                 0x0040
 524  564  #define SD_SERVER_SECURITY              0x0080
 525  565  #define SD_DACL_AUTO_INHERIT_REQ        0x0100
 526  566  #define SD_SACL_AUTO_INHERIT_REQ        0x0200
 527  567  #define SD_DACL_AUTO_INHERITED          0x0400
 528  568  #define SD_SACL_AUTO_INHERITED          0x0800
 529  569  #define SD_DACL_PROTECTED               0x1000
 530  570  #define SD_SACL_PROTECTED               0x2000
 531  571  #define SD_RM_CONTROL_VALID             0x4000
 532  572  #define SD_SELF_RELATIVE                0x8000
 533  573  
 534  574  /*
 535  575   * access control list header
 536  576   * it is followed by the ACEs
 537  577   * note this is "raw", ie little-endian
 538  578   */
 539  579  struct ntacl {
 540  580          uint8_t acl_revision;   /* 0x02 observed with W2K */
 541  581          uint8_t acl_pad1;
 542  582          uint16_t        acl_len; /* bytes; includes this header */
 543  583          uint16_t        acl_acecount;
 544  584          uint16_t        acl_pad2;
 545  585  }; /* XXX: __attribute__((__packed__)); */
 546  586  typedef struct ntacl ntacl_t;
 547  587  
 548  588  #define wset_aclrevision(a) ((a)->acl_revision = 0x02)
 549  589  #define acllen(a) (letohs((a)->acl_len))
 550  590  #define wset_acllen(a, l) ((a)->acl_len = htoles(l))
 551  591  #define aclacecount(a) (letohs((a)->acl_acecount))
 552  592  #define wset_aclacecount(a, c) ((a)->acl_acecount = htoles(c))
 553  593  #define aclace(a) ((struct ntace *)((char *)(a) + sizeof (struct ntacl)))
 554  594  
 555  595  /*
 556  596   * access control entry header
 557  597   * it is followed by type-specific ace data,
 558  598   * which for the simple types is just a SID
 559  599   * note this is "raw", ie little-endian
 560  600   */
 561  601  struct ntace {
 562  602          uint8_t ace_type;
 563  603          uint8_t ace_flags;
 564  604          uint16_t        ace_len; /* bytes; includes this header */
 565  605          uint32_t        ace_rights; /* generic, standard, specific, etc */
 566  606  }; /* XXX: __attribute__((__packed__)); */
 567  607  
 568  608  #define acetype(a) ((a)->ace_type)
 569  609  #define wset_acetype(a, t) ((a)->ace_type = (t))
 570  610  #define aceflags(a) ((a)->ace_flags)
 571  611  #define wset_aceflags(a, f) ((a)->ace_flags = (f))
 572  612  #define acelen(a) (letohs((a)->ace_len))
 573  613  #define wset_acelen(a, l) ((a)->ace_len = htoles(l))
 574  614  #define acerights(a) (letohl((a)->ace_rights))
 575  615  #define wset_acerights(a, r) ((a)->ace_rights = htolel(r))
 576  616  #define aceace(a) ((struct ntace *)((char *)(a) + acelen(a)))
 577  617  #define acesid(a) ((struct ntsid *)((char *)(a) + sizeof (struct ntace)))
 578  618  
 579  619  /*
 580  620   * ace_rights
 581  621   * (Samba bit names are used here, with permission, as the shorter Windows
 582  622   * names are more likely to cause namespace collisions)
 583  623   */
 584  624  #define SA_RIGHT_FILE_READ_DATA         0x00000001
 585  625  #define SA_RIGHT_FILE_WRITE_DATA        0x00000002
 586  626  #define SA_RIGHT_FILE_APPEND_DATA       0x00000004
 587  627  #define SA_RIGHT_FILE_READ_EA           0x00000008
 588  628  #define SA_RIGHT_FILE_WRITE_EA          0x00000010
 589  629  #define SA_RIGHT_FILE_EXECUTE           0x00000020
 590  630  #define SA_RIGHT_FILE_DELETE_CHILD      0x00000040
 591  631  #define SA_RIGHT_FILE_READ_ATTRIBUTES   0x00000080
 592  632  #define SA_RIGHT_FILE_WRITE_ATTRIBUTES  0x00000100
 593  633  #define SA_RIGHT_FILE_ALL_ACCESS        0x000001FF
 594  634  
 595  635  #define STD_RIGHT_DELETE_ACCESS         0x00010000
 596  636  #define STD_RIGHT_READ_CONTROL_ACCESS   0x00020000
 597  637  #define STD_RIGHT_WRITE_DAC_ACCESS      0x00040000
 598  638  #define STD_RIGHT_WRITE_OWNER_ACCESS    0x00080000
 599  639  #define STD_RIGHT_SYNCHRONIZE_ACCESS    0x00100000
 600  640  #define STD_RIGHT_ALL_ACCESS            0x001F0000
 601  641  
 602  642  #define SEC_RIGHT_SYSTEM_SECURITY       0x01000000
 603  643  /*
 604  644   * Don't use MAXIMUM_ALLOWED as Samba (2.2.3 at least) will
 605  645   * return NT_STATUS_INVALID_LOCK_SEQUENCE
 606  646   */
 607  647  #define SEC_RIGHT_MAXIMUM_ALLOWED       0x02000000
 608  648  
 609  649  #define GENERIC_RIGHT_ALL_ACCESS        0x10000000
 610  650  #define GENERIC_RIGHT_EXECUTE_ACCESS    0x20000000
 611  651  #define GENERIC_RIGHT_WRITE_ACCESS      0x40000000
 612  652  #define GENERIC_RIGHT_READ_ACCESS       0x80000000
 613  653  
 614  654  /*
 615  655   * these mappings are from Windows sample code but are likely incomplete
 616  656   *
 617  657   * GENERIC_RIGHT_READ_ACCESS :
 618  658   *      STD_RIGHT_SYNCHRONIZE_ACCESS |
 619  659   *      STD_RIGHT_READ_CONTROL_ACCESS |
 620  660   *      SA_RIGHT_FILE_READ_ATTRIBUTES |
 621  661   *      SA_RIGHT_FILE_READ_EA |
 622  662   *      SA_RIGHT_FILE_READ_DATA
 623  663   * GENERIC_RIGHT_WRITE_ACCESS :
 624  664   *      STD_RIGHT_SYNCHRONIZE_ACCESS |
 625  665   *      STD_RIGHT_READ_CONTROL_ACCESS |
 626  666   *      SA_RIGHT_FILE_WRITE_ATTRIBUTES |
 627  667   *      SA_RIGHT_FILE_WRITE_EA |
 628  668   *      SA_RIGHT_FILE_APPEND_DATA |
 629  669   *      SA_RIGHT_FILE_WRITE_DATA
 630  670   * GENERIC_RIGHT_EXECUTE_ACCESS :
 631  671   *      STD_RIGHT_SYNCHRONIZE_ACCESS |
 632  672   *      STD_RIGHT_READ_CONTROL_ACCESS |
 633  673   *      SA_RIGHT_FILE_READ_ATTRIBUTES |
 634  674   *      SA_RIGHT_FILE_EXECUTE
 635  675   * GENERIC_RIGHT_ALL_ACCESS :
 636  676   *      STD_RIGHT_SYNCHRONIZE_ACCESS |
 637  677   *      STD_RIGHT_WRITE_OWNER_ACCESS |
 638  678   *      STD_RIGHT_WRITE_DAC_ACCESS |
 639  679   *      STD_RIGHT_READ_CONTROL_ACCESS |
 640  680   *      STD_RIGHT_DELETE_ACCESS |
 641  681   *      SA_RIGHT_FILE_ALL_ACCESS
 642  682   */
 643  683  
 644  684  /*
 645  685   * security identifier header
 646  686   * it is followed by sid_numauth sub-authorities,
 647  687   * which are 32 bits each.
 648  688   * note the subauths are little-endian on the wire, but
 649  689   * need to be big-endian for memberd/DS
 650  690   */
 651  691  #define SIDAUTHSIZE 6
 652  692  struct ntsid {
 653  693          uint8_t sid_revision;
 654  694          uint8_t sid_subauthcount;
 655  695          uint8_t sid_authority[SIDAUTHSIZE]; /* ie not little endian */
 656  696  }; /* XXX: __attribute__((__packed__)); */
 657  697  typedef struct ntsid ntsid_t;
 658  698  
 659  699  #define sidsubauthcount(s) (s->sid_subauthcount)
 660  700  #define sidlen(s) (sizeof (struct ntsid) + 4 * (s)->sid_subauthcount)
 661  701  #define MAXSIDLEN (sizeof (struct ntsid) + 4 * KAUTH_NTSID_MAX_AUTHORITIES)
 662  702  #define sidsub(s) ((uint32_t *)((char *)(s) + sizeof (struct ntsid)))
 663  703  
 664  704  /*
 665  705   * MS' defined values for ace_type
 666  706   */
 667  707  #define ACCESS_ALLOWED_ACE_TYPE                 0x0
 668  708  #define ACCESS_DENIED_ACE_TYPE                  0x1
 669  709  #define SYSTEM_AUDIT_ACE_TYPE                   0x2
 670  710  #define SYSTEM_ALARM_ACE_TYPE                   0x3
 671  711  #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE        0x4
 672  712  #define ACCESS_ALLOWED_OBJECT_ACE_TYPE          0x5
 673  713  #define ACCESS_DENIED_OBJECT_ACE_TYPE           0x6
 674  714  #define SYSTEM_AUDIT_OBJECT_ACE_TYPE            0x7
 675  715  #define SYSTEM_ALARM_OBJECT_ACE_TYPE            0x8
 676  716  #define ACCESS_ALLOWED_CALLBACK_ACE_TYPE        0x9
 677  717  #define ACCESS_DENIED_CALLBACK_ACE_TYPE         0xA
 678  718  #define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE 0xB
 679  719  #define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE  0xC
 680  720  #define SYSTEM_AUDIT_CALLBACK_ACE_TYPE          0xD
 681  721  #define SYSTEM_ALARM_CALLBACK_ACE_TYPE          0xE
 682  722  #define SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE   0xF
 683  723  #define SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE   0x10
 684  724  
 685  725  /*
 686  726   * MS' defined values for ace_flags
 687  727   */
 688  728  #define OBJECT_INHERIT_ACE_FLAG                 0x01
 689  729  #define CONTAINER_INHERIT_ACE_FLAG              0x02
 690  730  #define NO_PROPAGATE_INHERIT_ACE_FLAG           0x04
 691  731  #define INHERIT_ONLY_ACE_FLAG                   0x08
 692  732  #define INHERITED_ACE_FLAG                      0x10
 693  733  #define UNDEF_ACE_FLAG                          0x20 /* MS doesn't define it */
 694  734  #define VALID_INHERIT_ACE_FLAGS                 0x1F
 695  735  #define SUCCESSFUL_ACCESS_ACE_FLAG              0x40
 696  736  #define FAILED_ACCESS_ACE_FLAG                  0x80
 697  737  
 698  738  /*
 699  739   * Set PATH/FILE information levels
  
    | 
      ↓ open down ↓ | 
    233 lines elided | 
    
      ↑ open up ↑ | 
  
 700  740   */
 701  741  #define SMB_SFILEINFO_STANDARD                  1
 702  742  #define SMB_SFILEINFO_EA_SET                    2
 703  743  #define SMB_SFILEINFO_BASIC_INFO                0x101
 704  744  #define SMB_SFILEINFO_DISPOSITION_INFO          0x102
 705  745  #define SMB_SFILEINFO_ALLOCATION_INFO           0x103
 706  746  #define SMB_SFILEINFO_END_OF_FILE_INFO          0x104
 707  747  #define SMB_SFILEINFO_UNIX_BASIC                0x200
 708  748  #define SMB_SFILEINFO_UNIX_LINK                 0x201
 709  749  #define SMB_SFILEINFO_UNIX_HLINK                0x203
      750 +#define SMB_SFILEINFO_POSIX_ACL                 0x204
      751 +#define SMB_SFILEINFO_POSIX_UNLINK              0x20A
      752 +#define SMB_SFILEINFO_UNIX_INFO2                0x20B
 710  753  #define SMB_SFILEINFO_DIRECTORY_INFORMATION     1001
 711  754  #define SMB_SFILEINFO_FULL_DIRECTORY_INFORMATION        1002
 712  755  #define SMB_SFILEINFO_BOTH_DIRECTORY_INFORMATION        1003
 713  756  #define SMB_SFILEINFO_BASIC_INFORMATION         1004
 714  757  #define SMB_SFILEINFO_STANDARD_INFORMATION      1005
 715  758  #define SMB_SFILEINFO_INTERNAL_INFORMATION      1006
 716  759  #define SMB_SFILEINFO_EA_INFORMATION            1007
 717  760  #define SMB_SFILEINFO_ACCESS_INFORMATION        1008
 718  761  #define SMB_SFILEINFO_NAME_INFORMATION          1009
 719  762  #define SMB_SFILEINFO_RENAME_INFORMATION        1010
 720  763  #define SMB_SFILEINFO_LINK_INFORMATION          1011
 721  764  #define SMB_SFILEINFO_NAMES_INFORMATION         1012
 722  765  #define SMB_SFILEINFO_DISPOSITION_INFORMATION   1013
 723  766  #define SMB_SFILEINFO_POSITION_INFORMATION      1014
 724  767  #define SMB_SFILEINFO_1015                      1015 /* ? */
 725  768  #define SMB_SFILEINFO_MODE_INFORMATION          1016
 726  769  #define SMB_SFILEINFO_ALIGNMENT_INFORMATION     1017
 727  770  #define SMB_SFILEINFO_ALL_INFORMATION           1018
 728  771  #define SMB_SFILEINFO_ALLOCATION_INFORMATION    1019
 729  772  #define SMB_SFILEINFO_END_OF_FILE_INFORMATION   1020
 730  773  #define SMB_SFILEINFO_ALT_NAME_INFORMATION      1021
 731  774  #define SMB_SFILEINFO_STREAM_INFORMATION        1022
 732  775  #define SMB_SFILEINFO_PIPE_INFORMATION          1023
 733  776  #define SMB_SFILEINFO_PIPE_LOCAL_INFORMATION    1024
 734  777  #define SMB_SFILEINFO_PIPE_REMOTE_INFORMATION   1025
 735  778  #define SMB_SFILEINFO_MAILSLOT_QUERY_INFORMATION        1026
 736  779  #define SMB_SFILEINFO_MAILSLOT_SET_INFORMATION          1027
 737  780  #define SMB_SFILEINFO_COMPRESSION_INFORMATION           1028
 738  781  #define SMB_SFILEINFO_OBJECT_ID_INFORMATION             1029
 739  782  #define SMB_SFILEINFO_COMPLETION_INFORMATION            1030
 740  783  #define SMB_SFILEINFO_MOVE_CLUSTER_INFORMATION          1031
 741  784  #define SMB_SFILEINFO_QUOTA_INFORMATION         1032
 742  785  #define SMB_SFILEINFO_REPARSE_POINT_INFORMATION 1033
 743  786  #define SMB_SFILEINFO_NETWORK_OPEN_INFORMATION  1034
 744  787  #define SMB_SFILEINFO_ATTRIBUTE_TAG_INFORMATION 1035
 745  788  #define SMB_SFILEINFO_TRACKING_INFORMATION      1036
 746  789  #define SMB_SFILEINFO_MAXIMUM_INFORMATION       1037
 747  790  
 748  791  /*
 749  792   * LOCKING_ANDX LockType flags
 750  793   */
 751  794  #define SMB_LOCKING_ANDX_SHARED_LOCK    0x01
 752  795  #define SMB_LOCKING_ANDX_OPLOCK_RELEASE 0x02
 753  796  #define SMB_LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
 754  797  #define SMB_LOCKING_ANDX_CANCEL_LOCK    0x08
 755  798  #define SMB_LOCKING_ANDX_LARGE_FILES    0x10
 756  799  
 757  800  
 758  801  /*
 759  802   * size of the GUID returned in an extended security negotiate response
 760  803   */
 761  804  #define SMB_GUIDLEN     16
 762  805  
 763  806  typedef uint16_t        smbfh;
 764  807  
 765  808  /*
 766  809   * NTLMv2 blob header structure.
 767  810   */
 768  811  struct ntlmv2_blobhdr {
 769  812          uint32_t        header;
 770  813          uint32_t        reserved;
 771  814          uint64_t        timestamp;
 772  815          uint64_t        client_nonce;
 773  816          uint32_t        unknown1;
 774  817  };
 775  818  typedef struct ntlmv2_blobhdr ntlmv2_blobhdr_t;
 776  819  
 777  820  /*
 778  821   * NTLMv2 name header structure, for names in a blob.
 779  822   */
 780  823  struct ntlmv2_namehdr {
 781  824          uint16_t        type;
 782  825          uint16_t        len;
 783  826  };
 784  827  typedef struct ntlmv2_namehdr ntlmv2_namehdr_t;
 785  828  
 786  829  #define NAMETYPE_EOL            0x0000  /* end of list of names */
 787  830  #define NAMETYPE_MACHINE_NB     0x0001  /* NetBIOS machine name */
 788  831  #define NAMETYPE_DOMAIN_NB      0x0002  /* NetBIOS domain name */
 789  832  #define NAMETYPE_MACHINE_DNS    0x0003  /* DNS machine name */
 790  833  #define NAMETYPE_DOMAIN_DNS     0x0004  /* DNS Active Directory domain name */
 791  834  
 792  835  /*
 793  836   * Named pipe commands.
 794  837   */
 795  838  #define TRANS_CALL_NAMED_PIPE           0x54    /* open/write/read/close pipe */
 796  839  #define TRANS_WAIT_NAMED_PIPE           0x53    /* wait for pipe to be !busy */
 797  840  #define TRANS_PEEK_NAMED_PIPE           0x23    /* read but don't remove data */
 798  841  #define TRANS_Q_NAMED_PIPE_HAND_STATE   0x21    /* query pipe handle modes */
 799  842  #define TRANS_SET_NAMED_PIPE_HAND_STATE 0x01    /* set pipe handle modes */
 800  843  #define TRANS_Q_NAMED_PIPE_INFO         0x22    /* query pipe attributes */
 801  844  #define TRANS_TRANSACT_NAMED_PIPE       0x26    /* r/w operation on pipe */
 802  845  #define TRANS_READ_NAMED_PIPE           0x11    /* read pipe in "raw" mode */
 803  846                                                  /* (non message mode) */
 804  847  #define TRANS_WRITE_NAMED_PIPE          0x31    /* write pipe "raw" mode */
 805  848                                                  /* (non message mode) */
 806  849  
 807  850  /*
 808  851   * Share types, visible via NetShareEnum
  
    | 
      ↓ open down ↓ | 
    89 lines elided | 
    
      ↑ open up ↑ | 
  
 809  852   */
 810  853  #define STYPE_DISKTREE                  0x00000000
 811  854  #define STYPE_PRINTQ                    0x00000001
 812  855  #define STYPE_DEVICE                    0x00000002
 813  856  #define STYPE_IPC                       0x00000003
 814  857  #define STYPE_UNKNOWN                   0x00000004
 815  858  #define STYPE_MASK                      0x0000000F
 816  859  #define STYPE_TEMPORARY                 0x40000000
 817  860  #define STYPE_HIDDEN                    0x80000000
 818  861  
      862 +/*
      863 + * Characters that are not allowed in an SMB file name component.
      864 + * From MSDN: Naming Files, Paths, ...
      865 + *      < (less than)
      866 + *      > (greater than)
      867 + *      : (colon)
      868 + *      " (double quote)
      869 + *      / (forward slash)
      870 + *      \ (backslash)
      871 + *      | (vertical bar or pipe)
      872 + *      ? (question mark)
      873 + *      * (asterisk)
      874 + */
      875 +#define SMB_FILENAME_INVALID_CHARS      "<>:\"/\\|?*"
      876 +
 819  877  #endif /* _NETSMB_SMB_H_ */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX