1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 * 25 * Copyright 2017 Nexenta Systems, Inc. All rights reserved. 26 * Copyright (c) 2016 by Delphix. All rights reserved. 27 */ 28 29 #ifndef _SMBSRV_NTIFS_H 30 #define _SMBSRV_NTIFS_H 31 32 /* 33 * This file provides definitions compatible with the NT Installable 34 * File System (IFS) interface. This header file also defines the Security 35 * Descriptor module from Windows. 36 */ 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 #include <sys/acl.h> 43 #include <sys/list.h> 44 #include <smbsrv/smb_sid.h> 45 46 /* 47 * The Volume and Directory bits are for SMB rather than NT. 48 * NT has an explicit Normal bit; this bit is implied in SMB 49 * when the Hidden, System and Directory bits are not set. 50 * 51 * File attributes and creation flags share the same 32-bit 52 * space. 53 */ 54 #define FILE_ATTRIBUTE_READONLY 0x00000001 55 #define FILE_ATTRIBUTE_HIDDEN 0x00000002 56 #define FILE_ATTRIBUTE_SYSTEM 0x00000004 57 #define FILE_ATTRIBUTE_VOLUME 0x00000008 58 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010 59 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020 60 #define FILE_ATTRIBUTE_DEVICE 0x00000040 61 #define FILE_ATTRIBUTE_NORMAL 0x00000080 62 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100 63 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 64 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 65 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800 66 #define FILE_ATTRIBUTE_OFFLINE 0x00001000 67 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 68 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 69 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000 70 #define FILE_FLAG_OPEN_NO_RECALL 0x00100000 71 #define FILE_FLAG_OPEN_REPARSE_POINT 0x00200000 72 #define FILE_FLAG_POSIX_SEMANTICS 0x01000000 73 #define FILE_FLAG_BACKUP_SEMANTICS 0x02000000 74 #define FILE_FLAG_DELETE_ON_CLOSE 0x04000000 75 #define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000 76 #define FILE_FLAG_RANDOM_ACCESS 0x10000000 77 #define FILE_FLAG_NO_BUFFERING 0x20000000 78 #define FILE_FLAG_OVERLAPPED 0x40000000 79 #define FILE_FLAG_WRITE_THROUGH 0x80000000 80 81 #define FILE_ATTRIBUTE_VALID_FLAGS 0x00001fb7 82 #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x00001fa7 83 #define FILE_ATTRIBUTE_MASK 0x00003FFF 84 85 /* 86 * The create/open option flags: used in NtCreateAndx and NtTransactCreate 87 * SMB requests. 88 * 89 * The CreateOptions specify the options to be applied when creating or 90 * opening the file, as a compatible combination of the following flags: 91 * 92 * FILE_DIRECTORY_FILE 93 * The file being created or opened is a directory file. With this 94 * flag, the Disposition parameter must be set to one of FILE_CREATE, 95 * FILE_OPEN, or FILE_OPEN_IF. With this flag, other compatible 96 * CreateOptions flags include only the following: 97 * FILE_SYNCHRONOUS_IO_ALERT 98 * FILE_SYNCHRONOUS_IO_NONALERT 99 * FILE_WRITE_THROUGH 100 * FILE_OPEN_FOR_BACKUP_INTENT 101 * FILE_OPEN_BY_FILE_ID 102 * 103 * FILE_NON_DIRECTORY_FILE 104 * The file being opened must not be a directory file or this call 105 * will fail. The file object being opened can represent a data file, 106 * a logical, virtual, or physical device, or a volume. 107 * 108 * FILE_WRITE_THROUGH 109 * System services, FSDs, and drivers that write data to the file must 110 * actually transfer the data into the file before any requested write 111 * operation is considered complete. This flag is automatically set if 112 * the CreateOptions flag FILE_NO_INTERMEDIATE _BUFFERING is set. 113 * 114 * FILE_SEQUENTIAL_ONLY 115 * All accesses to the file will be sequential. 116 * 117 * FILE_RANDOM_ACCESS 118 * Accesses to the file can be random, so no sequential read-ahead 119 * operations should be performed on the file by FSDs or the system. 120 * FILE_NO_INTERMEDIATE _BUFFERING The file cannot be cached or 121 * buffered in a driver's internal buffers. This flag is incompatible 122 * with the DesiredAccess FILE_APPEND_DATA flag. 123 * 124 * FILE_SYNCHRONOUS_IO_ALERT 125 * All operations on the file are performed synchronously. Any wait 126 * on behalf of the caller is subject to premature termination from 127 * alerts. This flag also causes the I/O system to maintain the file 128 * position context. If this flag is set, the DesiredAccess 129 * SYNCHRONIZE flag also must be set. 130 * 131 * FILE_SYNCHRONOUS_IO _NONALERT 132 * All operations on the file are performed synchronously. Waits in 133 * the system to synchronize I/O queuing and completion are not subject 134 * to alerts. This flag also causes the I/O system to maintain the file 135 * position context. If this flag is set, the DesiredAccess SYNCHRONIZE 136 * flag also must be set. 137 * 138 * FILE_CREATE_TREE _CONNECTION 139 * Create a tree connection for this file in order to open it over the 140 * network. This flag is irrelevant to device and intermediate drivers. 141 * 142 * FILE_COMPLETE_IF_OPLOCKED 143 * Complete this operation immediately with an alternate success code 144 * if the target file is oplocked, rather than blocking the caller's 145 * thread. If the file is oplocked, another caller already has access 146 * to the file over the network. This flag is irrelevant to device and 147 * intermediate drivers. 148 * 149 * FILE_NO_EA_KNOWLEDGE 150 * If the extended attributes on an existing file being opened indicate 151 * that the caller must understand EAs to properly interpret the file, 152 * fail this request because the caller does not understand how to deal 153 * with EAs. Device and intermediate drivers can ignore this flag. 154 * 155 * FILE_DELETE_ON_CLOSE 156 * Delete the file when the last reference to it is passed to close. 157 * 158 * FILE_OPEN_BY_FILE_ID 159 * The file name contains the name of a device and a 64-bit ID to 160 * be used to open the file. This flag is irrelevant to device and 161 * intermediate drivers. 162 * 163 * FILE_OPEN_FOR_BACKUP _INTENT 164 * The file is being opened for backup intent, hence, the system should 165 * check for certain access rights and grant the caller the appropriate 166 * accesses to the file before checking the input DesiredAccess against 167 * the file's security descriptor. This flag is irrelevant to device 168 * and intermediate drivers. 169 */ 170 #define FILE_DIRECTORY_FILE 0x00000001 171 #define FILE_WRITE_THROUGH 0x00000002 172 #define FILE_SEQUENTIAL_ONLY 0x00000004 173 #define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008 174 175 #define FILE_SYNCHRONOUS_IO_ALERT 0x00000010 176 #define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020 177 #define FILE_NON_DIRECTORY_FILE 0x00000040 178 #define FILE_CREATE_TREE_CONNECTION 0x00000080 179 180 #define FILE_COMPLETE_IF_OPLOCKED 0x00000100 181 #define FILE_NO_EA_KNOWLEDGE 0x00000200 182 /* UNUSED 0x00000400 */ 183 #define FILE_RANDOM_ACCESS 0x00000800 184 185 #define FILE_DELETE_ON_CLOSE 0x00001000 186 #define FILE_OPEN_BY_FILE_ID 0x00002000 187 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000 188 #define FILE_NO_COMPRESSION 0x00008000 189 190 #define FILE_RESERVE_OPFILTER 0x00100000 191 #define FILE_RESERVED0 0x00200000 192 #define FILE_RESERVED1 0x00400000 193 #define FILE_RESERVED2 0x00800000 194 195 #define FILE_VALID_OPTION_FLAGS 0x00ffffff 196 #define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032 197 #define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032 198 #define FILE_VALID_SET_FLAGS 0x00000036 199 200 /* 201 * "Granular" oplock flags; [MS-FSA], WinDDK/ntifs.h 202 * Same as smb2.h SMB2_LEASE_... 203 */ 204 #define OPLOCK_LEVEL_CACHE_READ 0x01 205 #define OPLOCK_LEVEL_CACHE_HANDLE 0x02 206 #define OPLOCK_LEVEL_CACHE_WRITE 0x04 207 #define OPLOCK_LEVEL_CACHE_MASK 0x07 208 209 /* 210 * [MS-FSA] oplock types (also "levels") 211 */ 212 #define OPLOCK_LEVEL_NONE 0 213 #define OPLOCK_LEVEL_TWO 0x100 214 #define OPLOCK_LEVEL_ONE 0x200 215 #define OPLOCK_LEVEL_BATCH 0x400 216 #define OPLOCK_LEVEL_GRANULAR 0x800 217 #define OPLOCK_LEVEL_TYPE_MASK 0xf00 218 219 /* 220 * Define the file information class values used by the NT DDK and HAL. 221 */ 222 typedef enum _FILE_INFORMATION_CLASS { 223 FileDirectoryInformation = 1, 224 FileFullDirectoryInformation, /* 2 */ 225 FileBothDirectoryInformation, /* 3 */ 226 FileBasicInformation, /* 4 */ 227 FileStandardInformation, /* 5 */ 228 FileInternalInformation, /* 6 */ 229 FileEaInformation, /* 7 */ 230 FileAccessInformation, /* 8 */ 231 FileNameInformation, /* 9 */ 232 FileRenameInformation, /* 10 */ 233 FileLinkInformation, /* 11 */ 234 FileNamesInformation, /* 12 */ 235 FileDispositionInformation, /* 13 */ 236 FilePositionInformation, /* 14 */ 237 FileFullEaInformation, /* 15 */ 238 FileModeInformation, /* 16 */ 239 FileAlignmentInformation, /* 17 */ 240 FileAllInformation, /* 18 */ 241 FileAllocationInformation, /* 19 */ 242 FileEndOfFileInformation, /* 20 */ 243 FileAlternateNameInformation, /* 21 */ 244 FileStreamInformation, /* 22 */ 245 FilePipeInformation, /* 23 */ 246 FilePipeLocalInformation, /* 24 */ 247 FilePipeRemoteInformation, /* 25 */ 248 FileMailslotQueryInformation, /* 26 */ 249 FileMailslotSetInformation, /* 27 */ 250 FileCompressionInformation, /* 28 */ 251 FileObjectIdInformation, /* 29 */ 252 FileCompletionInformation, /* 30 */ 253 FileMoveClusterInformation, /* 31 */ 254 FileQuotaInformation, /* 32 */ 255 FileReparsePointInformation, /* 33 */ 256 FileNetworkOpenInformation, /* 34 */ 257 FileAttributeTagInformation, /* 35 */ 258 FileTrackingInformation, /* 36 */ 259 FileIdBothDirectoryInformation, /* 37 */ 260 FileIdFullDirectoryInformation, /* 38 */ 261 FileValidDataLengthInformation, /* 39 */ 262 FileShortNameInformation, /* 40 */ 263 FileInformationReserved41, /* 41 */ 264 FileInformationReserved42, /* 42 */ 265 FileInformationReserved43, /* 43 */ 266 FileSfioReserveInformation, /* 44 */ 267 FileSfioVolumeInformation, /* 45 */ 268 FileHardLinkInformation, /* 46 */ 269 FileInformationReserved47, /* 47 */ 270 FileNormalizedNameInformation, /* 48 */ 271 FileInformationReserved49, /* 49 */ 272 FileIdGlobalTxDirectoryInformation, /* 50 */ 273 FileInformationReserved51, /* 51 */ 274 FileInformationReserved52, /* 52 */ 275 FileInformationReserved53, /* 53 */ 276 FileStandardLinkInformation, /* 54 */ 277 FileMaximumInformation 278 } FILE_INFORMATION_CLASS; 279 280 /* 281 * Define the file system information class values. 282 */ 283 typedef enum _FILE_FS_INFORMATION_CLASS { 284 FileFsVolumeInformation = 1, 285 FileFsLabelInformation, /* 2 */ 286 FileFsSizeInformation, /* 3 */ 287 FileFsDeviceInformation, /* 4 */ 288 FileFsAttributeInformation, /* 5 */ 289 FileFsControlInformation, /* 6 */ 290 FileFsFullSizeInformation, /* 7 */ 291 FileFsObjectIdInformation, /* 8 */ 292 FileFsDriverPathInformation /* 9 */ 293 } FILE_FS_INFORMATION_CLASS; 294 295 /* 296 * Discretionary Access Control List (DACL) 297 * 298 * A Discretionary Access Control List (DACL), often abbreviated to 299 * ACL, is a list of access controls which either allow or deny access 300 * for users or groups to a resource. There is a list header followed 301 * by a list of access control entries (ACE). Each ACE specifies the 302 * access allowed or denied to a single user or group (identified by 303 * a SID). 304 * 305 * There is another access control list object called a System Access 306 * Control List (SACL), which is used to control auditing, but no 307 * support is provideed for SACLs at this time. 308 * 309 * ACL header format: 310 * 311 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 312 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 313 * +-------------------------------+---------------+---------------+ 314 * | AclSize | Sbz1 | AclRevision | 315 * +-------------------------------+---------------+---------------+ 316 * | Sbz2 | AceCount | 317 * +-------------------------------+-------------------------------+ 318 * 319 * AclRevision specifies the revision level of the ACL. This value should 320 * be ACL_REVISION, unless the ACL contains an object-specific ACE, in which 321 * case this value must be ACL_REVISION_DS. All ACEs in an ACL must be at the 322 * same revision level. 323 * 324 * ACE header format: 325 * 326 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 327 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 328 * +---------------+-------+-------+---------------+---------------+ 329 * | AceSize | AceFlags | AceType | 330 * +---------------+-------+-------+---------------+---------------+ 331 * 332 * Access mask format: 333 * 334 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 335 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 336 * +---------------+---------------+-------------------------------+ 337 * |G|G|G|G|Res'd|A| StandardRights| SpecificRights | 338 * |R|W|E|A| |S| | | 339 * +-+-------------+---------------+-------------------------------+ 340 * 341 * typedef struct ACCESS_MASK { 342 * WORD SpecificRights; 343 * BYTE StandardRights; 344 * BYTE AccessSystemAcl : 1; 345 * BYTE Reserved : 3; 346 * BYTE GenericAll : 1; 347 * BYTE GenericExecute : 1; 348 * BYTE GenericWrite : 1; 349 * BYTE GenericRead : 1; 350 * } ACCESS_MASK; 351 * 352 */ 353 354 #define ACL_REVISION1 1 355 #define ACL_REVISION2 2 356 #define MIN_ACL_REVISION2 ACL_REVISION2 357 #define ACL_REVISION3 3 358 #define ACL_REVISION4 4 359 #define MAX_ACL_REVISION ACL_REVISION4 360 361 /* 362 * Current ACE and ACL revision Levels 363 */ 364 #define ACE_REVISION 1 365 #define ACL_REVISION ACL_REVISION2 366 #define ACL_REVISION_DS ACL_REVISION4 367 368 369 #define ACCESS_ALLOWED_ACE_TYPE 0 370 #define ACCESS_DENIED_ACE_TYPE 1 371 #define SYSTEM_AUDIT_ACE_TYPE 2 372 #define SYSTEM_ALARM_ACE_TYPE 3 373 374 /* 375 * se_flags 376 * ---------- 377 * Specifies a set of ACE type-specific control flags. This member can be a 378 * combination of the following values. 379 * 380 * CONTAINER_INHERIT_ACE: Child objects that are containers, such as 381 * directories, inherit the ACE as an effective ACE. The inherited 382 * ACE is inheritable unless the NO_PROPAGATE_INHERIT_ACE bit flag 383 * is also set. 384 * 385 * INHERIT_ONLY_ACE: Indicates an inherit-only ACE which does not control 386 * access to the object to which it is attached. 387 * If this flag is not set, 388 * the ACE is an effective ACE which controls access to the object 389 * to which it is attached. 390 * Both effective and inherit-only ACEs can be inherited 391 * depending on the state of the other inheritance flags. 392 * 393 * INHERITED_ACE: Windows 2000/XP: Indicates that the ACE was inherited. 394 * The system sets this bit when it propagates an 395 * inherited ACE to a child object. 396 * 397 * NO_PROPAGATE_INHERIT_ACE: If the ACE is inherited by a child object, the 398 * system clears the OBJECT_INHERIT_ACE and CONTAINER_INHERIT_ACE 399 * flags in the inherited ACE. 400 * This prevents the ACE from being inherited by 401 * subsequent generations of objects. 402 * 403 * OBJECT_INHERIT_ACE: Noncontainer child objects inherit the ACE as an 404 * effective ACE. For child objects that are containers, 405 * the ACE is inherited as an inherit-only ACE unless the 406 * NO_PROPAGATE_INHERIT_ACE bit flag is also set. 407 */ 408 #define OBJECT_INHERIT_ACE 0x01 409 #define CONTAINER_INHERIT_ACE 0x02 410 #define NO_PROPOGATE_INHERIT_ACE 0x04 411 #define INHERIT_ONLY_ACE 0x08 412 #define INHERITED_ACE 0x10 413 #define INHERIT_MASK_ACE 0x1F 414 415 416 /* 417 * These flags are only used in system audit or alarm ACEs to 418 * indicate when an audit message should be generated, i.e. 419 * on successful access or on unsuccessful access. 420 */ 421 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40 422 #define FAILED_ACCESS_ACE_FLAG 0x80 423 424 /* 425 * se_bsize is the size, in bytes, of ACE as it appears on the wire. 426 * se_sln is used to sort the ACL when it's required. 427 */ 428 typedef struct smb_acehdr { 429 uint8_t se_type; 430 uint8_t se_flags; 431 uint16_t se_bsize; 432 } smb_acehdr_t; 433 434 typedef struct smb_ace { 435 smb_acehdr_t se_hdr; 436 uint32_t se_mask; 437 list_node_t se_sln; 438 smb_sid_t *se_sid; 439 } smb_ace_t; 440 441 /* 442 * sl_bsize is the size of ACL in bytes as it appears on the wire. 443 */ 444 typedef struct smb_acl { 445 uint8_t sl_revision; 446 uint16_t sl_bsize; 447 uint16_t sl_acecnt; 448 smb_ace_t *sl_aces; 449 list_t sl_sorted; 450 } smb_acl_t; 451 452 /* 453 * ACE/ACL header size, in byte, as it appears on the wire 454 */ 455 #define SMB_ACE_HDRSIZE 4 456 #define SMB_ACL_HDRSIZE 8 457 458 /* 459 * Security Descriptor (SD) 460 * 461 * Security descriptors provide protection for objects, for example 462 * files and directories. It identifies the owner and primary group 463 * (SIDs) and contains an access control list. When a user tries to 464 * access an object their SID is compared to the permissions in the 465 * DACL to determine if access should be allowed or denied. Note that 466 * this is a simplification because there are other factors, such as 467 * default behavior and privileges to be taken into account (see also 468 * access tokens). 469 * 470 * The boolean flags have the following meanings when set: 471 * 472 * SE_OWNER_DEFAULTED indicates that the SID pointed to by the Owner 473 * field was provided by a defaulting mechanism rather than explicitly 474 * provided by the original provider of the security descriptor. This 475 * may affect the treatment of the SID with respect to inheritance of 476 * an owner. 477 * 478 * SE_GROUP_DEFAULTED indicates that the SID in the Group field was 479 * provided by a defaulting mechanism rather than explicitly provided 480 * by the original provider of the security descriptor. This may 481 * affect the treatment of the SID with respect to inheritance of a 482 * primary group. 483 * 484 * SE_DACL_PRESENT indicates that the security descriptor contains a 485 * discretionary ACL. If this flag is set and the Dacl field of the 486 * SECURITY_DESCRIPTOR is null, then a null ACL is explicitly being 487 * specified. 488 * 489 * SE_DACL_DEFAULTED indicates that the ACL pointed to by the Dacl 490 * field was provided by a defaulting mechanism rather than explicitly 491 * provided by the original provider of the security descriptor. This 492 * may affect the treatment of the ACL with respect to inheritance of 493 * an ACL. This flag is ignored if the DaclPresent flag is not set. 494 * 495 * SE_SACL_PRESENT indicates that the security descriptor contains a 496 * system ACL pointed to by the Sacl field. If this flag is set and 497 * the Sacl field of the SECURITY_DESCRIPTOR is null, then an empty 498 * (but present) ACL is being specified. 499 * 500 * SE_SACL_DEFAULTED indicates that the ACL pointed to by the Sacl 501 * field was provided by a defaulting mechanism rather than explicitly 502 * provided by the original provider of the security descriptor. This 503 * may affect the treatment of the ACL with respect to inheritance of 504 * an ACL. This flag is ignored if the SaclPresent flag is not set. 505 * 506 * SE_DACL_PROTECTED Prevents ACEs set on the DACL of the parent container 507 * (and any objects above the parent container in the directory hierarchy) 508 * from being applied to the object's DACL. 509 * 510 * SE_SACL_PROTECTED Prevents ACEs set on the SACL of the parent container 511 * (and any objects above the parent container in the directory hierarchy) 512 * from being applied to the object's SACL. 513 * 514 * Note that the SE_DACL_PRESENT flag needs to be present to set 515 * SE_DACL_PROTECTED and SE_SACL_PRESENT needs to be present to set 516 * SE_SACL_PROTECTED. 517 * 518 * SE_SELF_RELATIVE indicates that the security descriptor is in self- 519 * relative form. In this form, all fields of the security descriptor 520 * are contiguous in memory and all pointer fields are expressed as 521 * offsets from the beginning of the security descriptor. 522 * 523 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 524 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 525 * +---------------------------------------------------------------+ 526 * | Control |Reserved1 (SBZ)| Revision | 527 * +---------------------------------------------------------------+ 528 * | Owner | 529 * +---------------------------------------------------------------+ 530 * | Group | 531 * +---------------------------------------------------------------+ 532 * | Sacl | 533 * +---------------------------------------------------------------+ 534 * | Dacl | 535 * +---------------------------------------------------------------+ 536 * 537 */ 538 539 #define SMB_OWNER_SECINFO 0x0001 540 #define SMB_GROUP_SECINFO 0x0002 541 #define SMB_DACL_SECINFO 0x0004 542 #define SMB_SACL_SECINFO 0x0008 543 #define SMB_ALL_SECINFO 0x000F 544 #define SMB_ACL_SECINFO (SMB_DACL_SECINFO | SMB_SACL_SECINFO) 545 546 #define SECURITY_DESCRIPTOR_REVISION 1 547 548 549 #define SE_OWNER_DEFAULTED 0x0001 550 #define SE_GROUP_DEFAULTED 0x0002 551 #define SE_DACL_PRESENT 0x0004 552 #define SE_DACL_DEFAULTED 0x0008 553 #define SE_SACL_PRESENT 0x0010 554 #define SE_SACL_DEFAULTED 0x0020 555 #define SE_DACL_AUTO_INHERIT_REQ 0x0100 556 #define SE_SACL_AUTO_INHERIT_REQ 0x0200 557 #define SE_DACL_AUTO_INHERITED 0x0400 558 #define SE_SACL_AUTO_INHERITED 0x0800 559 #define SE_DACL_PROTECTED 0x1000 560 #define SE_SACL_PROTECTED 0x2000 561 #define SE_SELF_RELATIVE 0x8000 562 563 #define SE_DACL_INHERITANCE_MASK 0x1500 564 #define SE_SACL_INHERITANCE_MASK 0x2A00 565 566 /* 567 * Security descriptor structures: 568 * 569 * smb_sd_t SD in SMB pointer form 570 * smb_fssd_t SD in filesystem form 571 * 572 * Filesystems (e.g. ZFS/UFS) don't have something equivalent 573 * to SD. The items comprising a SMB SD are kept separately in 574 * filesystem. smb_fssd_t is introduced as a helper to provide 575 * the required abstraction for CIFS code. 576 */ 577 578 typedef struct smb_sd { 579 uint8_t sd_revision; 580 uint16_t sd_control; 581 smb_sid_t *sd_owner; /* SID file owner */ 582 smb_sid_t *sd_group; /* SID group (for POSIX) */ 583 smb_acl_t *sd_sacl; /* ACL System (audits) */ 584 smb_acl_t *sd_dacl; /* ACL Discretionary (perm) */ 585 } smb_sd_t; 586 587 /* 588 * SD header size as it appears on the wire 589 */ 590 #define SMB_SD_HDRSIZE 20 591 592 /* 593 * values for smb_fssd.sd_flags 594 */ 595 #define SMB_FSSD_FLAGS_DIR 0x01 596 597 typedef struct smb_fssd { 598 uint32_t sd_secinfo; 599 uint32_t sd_flags; 600 uid_t sd_uid; 601 gid_t sd_gid; 602 acl_t *sd_zdacl; 603 acl_t *sd_zsacl; 604 } smb_fssd_t; 605 606 void smb_sd_init(smb_sd_t *, uint8_t); 607 void smb_sd_term(smb_sd_t *); 608 uint32_t smb_sd_get_secinfo(smb_sd_t *); 609 uint32_t smb_sd_len(smb_sd_t *, uint32_t); 610 uint32_t smb_sd_tofs(smb_sd_t *, smb_fssd_t *); 611 612 void smb_fssd_init(smb_fssd_t *, uint32_t, uint32_t); 613 void smb_fssd_term(smb_fssd_t *); 614 615 void smb_acl_sort(smb_acl_t *); 616 void smb_acl_free(smb_acl_t *); 617 smb_acl_t *smb_acl_alloc(uint8_t, uint16_t, uint16_t); 618 smb_acl_t *smb_acl_from_zfs(acl_t *); 619 uint32_t smb_acl_to_zfs(smb_acl_t *, uint32_t, int, acl_t **); 620 uint16_t smb_acl_len(smb_acl_t *); 621 boolean_t smb_acl_isvalid(smb_acl_t *, int); 622 623 void smb_fsacl_free(acl_t *); 624 acl_t *smb_fsacl_alloc(int, int); 625 626 #ifdef __cplusplus 627 } 628 #endif 629 630 #endif /* _SMBSRV_NTIFS_H */ 631