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 2016 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 * Define the file information class values used by the NT DDK and HAL. 202 */ 203 typedef enum _FILE_INFORMATION_CLASS { 204 FileDirectoryInformation = 1, 205 FileFullDirectoryInformation, /* 2 */ 206 FileBothDirectoryInformation, /* 3 */ 207 FileBasicInformation, /* 4 */ 208 FileStandardInformation, /* 5 */ 209 FileInternalInformation, /* 6 */ 210 FileEaInformation, /* 7 */ 211 FileAccessInformation, /* 8 */ 212 FileNameInformation, /* 9 */ 213 FileRenameInformation, /* 10 */ 214 FileLinkInformation, /* 11 */ 215 FileNamesInformation, /* 12 */ 216 FileDispositionInformation, /* 13 */ 217 FilePositionInformation, /* 14 */ 218 FileFullEaInformation, /* 15 */ 219 FileModeInformation, /* 16 */ 220 FileAlignmentInformation, /* 17 */ 221 FileAllInformation, /* 18 */ 222 FileAllocationInformation, /* 19 */ 223 FileEndOfFileInformation, /* 20 */ 224 FileAlternateNameInformation, /* 21 */ 225 FileStreamInformation, /* 22 */ 226 FilePipeInformation, /* 23 */ 227 FilePipeLocalInformation, /* 24 */ 228 FilePipeRemoteInformation, /* 25 */ 229 FileMailslotQueryInformation, /* 26 */ 230 FileMailslotSetInformation, /* 27 */ 231 FileCompressionInformation, /* 28 */ 232 FileObjectIdInformation, /* 29 */ 233 FileCompletionInformation, /* 30 */ 234 FileMoveClusterInformation, /* 31 */ 235 FileQuotaInformation, /* 32 */ 236 FileReparsePointInformation, /* 33 */ 237 FileNetworkOpenInformation, /* 34 */ 238 FileAttributeTagInformation, /* 35 */ 239 FileTrackingInformation, /* 36 */ 240 FileIdBothDirectoryInformation, /* 37 */ 241 FileIdFullDirectoryInformation, /* 38 */ 242 FileValidDataLengthInformation, /* 39 */ 243 FileShortNameInformation, /* 40 */ 244 FileInformationReserved41, /* 41 */ 245 FileInformationReserved42, /* 42 */ 246 FileInformationReserved43, /* 43 */ 247 FileSfioReserveInformation, /* 44 */ 248 FileSfioVolumeInformation, /* 45 */ 249 FileHardLinkInformation, /* 46 */ 250 FileInformationReserved47, /* 47 */ 251 FileNormalizedNameInformation, /* 48 */ 252 FileInformationReserved49, /* 49 */ 253 FileIdGlobalTxDirectoryInformation, /* 50 */ 254 FileInformationReserved51, /* 51 */ 255 FileInformationReserved52, /* 52 */ 256 FileInformationReserved53, /* 53 */ 257 FileStandardLinkInformation, /* 54 */ 258 FileMaximumInformation 259 } FILE_INFORMATION_CLASS; 260 261 /* 262 * Define the file system information class values. 263 */ 264 typedef enum _FILE_FS_INFORMATION_CLASS { 265 FileFsVolumeInformation = 1, 266 FileFsLabelInformation, /* 2 */ 267 FileFsSizeInformation, /* 3 */ 268 FileFsDeviceInformation, /* 4 */ 269 FileFsAttributeInformation, /* 5 */ 270 FileFsControlInformation, /* 6 */ 271 FileFsFullSizeInformation, /* 7 */ 272 FileFsObjectIdInformation, /* 8 */ 273 FileFsDriverPathInformation /* 9 */ 274 } FILE_FS_INFORMATION_CLASS; 275 276 /* 277 * Discretionary Access Control List (DACL) 278 * 279 * A Discretionary Access Control List (DACL), often abbreviated to 280 * ACL, is a list of access controls which either allow or deny access 281 * for users or groups to a resource. There is a list header followed 282 * by a list of access control entries (ACE). Each ACE specifies the 283 * access allowed or denied to a single user or group (identified by 284 * a SID). 285 * 286 * There is another access control list object called a System Access 287 * Control List (SACL), which is used to control auditing, but no 288 * support is provideed for SACLs at this time. 289 * 290 * ACL header format: 291 * 292 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 293 * 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 294 * +-------------------------------+---------------+---------------+ 295 * | AclSize | Sbz1 | AclRevision | 296 * +-------------------------------+---------------+---------------+ 297 * | Sbz2 | AceCount | 298 * +-------------------------------+-------------------------------+ 299 * 300 * AclRevision specifies the revision level of the ACL. This value should 301 * be ACL_REVISION, unless the ACL contains an object-specific ACE, in which 302 * case this value must be ACL_REVISION_DS. All ACEs in an ACL must be at the 303 * same revision level. 304 * 305 * ACE header format: 306 * 307 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 308 * 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 309 * +---------------+-------+-------+---------------+---------------+ 310 * | AceSize | AceFlags | AceType | 311 * +---------------+-------+-------+---------------+---------------+ 312 * 313 * Access mask format: 314 * 315 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 316 * 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 317 * +---------------+---------------+-------------------------------+ 318 * |G|G|G|G|Res'd|A| StandardRights| SpecificRights | 319 * |R|W|E|A| |S| | | 320 * +-+-------------+---------------+-------------------------------+ 321 * 322 * typedef struct ACCESS_MASK { 323 * WORD SpecificRights; 324 * BYTE StandardRights; 325 * BYTE AccessSystemAcl : 1; 326 * BYTE Reserved : 3; 327 * BYTE GenericAll : 1; 328 * BYTE GenericExecute : 1; 329 * BYTE GenericWrite : 1; 330 * BYTE GenericRead : 1; 331 * } ACCESS_MASK; 332 * 333 */ 334 335 #define ACL_REVISION1 1 336 #define ACL_REVISION2 2 337 #define MIN_ACL_REVISION2 ACL_REVISION2 338 #define ACL_REVISION3 3 339 #define ACL_REVISION4 4 340 #define MAX_ACL_REVISION ACL_REVISION4 341 342 /* 343 * Current ACE and ACL revision Levels 344 */ 345 #define ACE_REVISION 1 346 #define ACL_REVISION ACL_REVISION2 347 #define ACL_REVISION_DS ACL_REVISION4 348 349 350 #define ACCESS_ALLOWED_ACE_TYPE 0 351 #define ACCESS_DENIED_ACE_TYPE 1 352 #define SYSTEM_AUDIT_ACE_TYPE 2 353 #define SYSTEM_ALARM_ACE_TYPE 3 354 355 /* 356 * se_flags 357 * ---------- 358 * Specifies a set of ACE type-specific control flags. This member can be a 359 * combination of the following values. 360 * 361 * CONTAINER_INHERIT_ACE: Child objects that are containers, such as 362 * directories, inherit the ACE as an effective ACE. The inherited 363 * ACE is inheritable unless the NO_PROPAGATE_INHERIT_ACE bit flag 364 * is also set. 365 * 366 * INHERIT_ONLY_ACE: Indicates an inherit-only ACE which does not control 367 * access to the object to which it is attached. 368 * If this flag is not set, 369 * the ACE is an effective ACE which controls access to the object 370 * to which it is attached. 371 * Both effective and inherit-only ACEs can be inherited 372 * depending on the state of the other inheritance flags. 373 * 374 * INHERITED_ACE: Windows 2000/XP: Indicates that the ACE was inherited. 375 * The system sets this bit when it propagates an 376 * inherited ACE to a child object. 377 * 378 * NO_PROPAGATE_INHERIT_ACE: If the ACE is inherited by a child object, the 379 * system clears the OBJECT_INHERIT_ACE and CONTAINER_INHERIT_ACE 380 * flags in the inherited ACE. 381 * This prevents the ACE from being inherited by 382 * subsequent generations of objects. 383 * 384 * OBJECT_INHERIT_ACE: Noncontainer child objects inherit the ACE as an 385 * effective ACE. For child objects that are containers, 386 * the ACE is inherited as an inherit-only ACE unless the 387 * NO_PROPAGATE_INHERIT_ACE bit flag is also set. 388 */ 389 #define OBJECT_INHERIT_ACE 0x01 390 #define CONTAINER_INHERIT_ACE 0x02 391 #define NO_PROPOGATE_INHERIT_ACE 0x04 392 #define INHERIT_ONLY_ACE 0x08 393 #define INHERITED_ACE 0x10 394 #define INHERIT_MASK_ACE 0x1F 395 396 397 /* 398 * These flags are only used in system audit or alarm ACEs to 399 * indicate when an audit message should be generated, i.e. 400 * on successful access or on unsuccessful access. 401 */ 402 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40 403 #define FAILED_ACCESS_ACE_FLAG 0x80 404 405 /* 406 * se_bsize is the size, in bytes, of ACE as it appears on the wire. 407 * se_sln is used to sort the ACL when it's required. 408 */ 409 typedef struct smb_acehdr { 410 uint8_t se_type; 411 uint8_t se_flags; 412 uint16_t se_bsize; 413 } smb_acehdr_t; 414 415 typedef struct smb_ace { 416 smb_acehdr_t se_hdr; 417 uint32_t se_mask; 418 list_node_t se_sln; 419 smb_sid_t *se_sid; 420 } smb_ace_t; 421 422 /* 423 * sl_bsize is the size of ACL in bytes as it appears on the wire. 424 */ 425 typedef struct smb_acl { 426 uint8_t sl_revision; 427 uint16_t sl_bsize; 428 uint16_t sl_acecnt; 429 smb_ace_t *sl_aces; 430 list_t sl_sorted; 431 } smb_acl_t; 432 433 /* 434 * ACE/ACL header size, in byte, as it appears on the wire 435 */ 436 #define SMB_ACE_HDRSIZE 4 437 #define SMB_ACL_HDRSIZE 8 438 439 /* 440 * Security Descriptor (SD) 441 * 442 * Security descriptors provide protection for objects, for example 443 * files and directories. It identifies the owner and primary group 444 * (SIDs) and contains an access control list. When a user tries to 445 * access an object their SID is compared to the permissions in the 446 * DACL to determine if access should be allowed or denied. Note that 447 * this is a simplification because there are other factors, such as 448 * default behavior and privileges to be taken into account (see also 449 * access tokens). 450 * 451 * The boolean flags have the following meanings when set: 452 * 453 * SE_OWNER_DEFAULTED indicates that the SID pointed to by the Owner 454 * field was provided by a defaulting mechanism rather than explicitly 455 * provided by the original provider of the security descriptor. This 456 * may affect the treatment of the SID with respect to inheritance of 457 * an owner. 458 * 459 * SE_GROUP_DEFAULTED indicates that the SID in the Group field was 460 * provided by a defaulting mechanism rather than explicitly provided 461 * by the original provider of the security descriptor. This may 462 * affect the treatment of the SID with respect to inheritance of a 463 * primary group. 464 * 465 * SE_DACL_PRESENT indicates that the security descriptor contains a 466 * discretionary ACL. If this flag is set and the Dacl field of the 467 * SECURITY_DESCRIPTOR is null, then a null ACL is explicitly being 468 * specified. 469 * 470 * SE_DACL_DEFAULTED indicates that the ACL pointed to by the Dacl 471 * field was provided by a defaulting mechanism rather than explicitly 472 * provided by the original provider of the security descriptor. This 473 * may affect the treatment of the ACL with respect to inheritance of 474 * an ACL. This flag is ignored if the DaclPresent flag is not set. 475 * 476 * SE_SACL_PRESENT indicates that the security descriptor contains a 477 * system ACL pointed to by the Sacl field. If this flag is set and 478 * the Sacl field of the SECURITY_DESCRIPTOR is null, then an empty 479 * (but present) ACL is being specified. 480 * 481 * SE_SACL_DEFAULTED indicates that the ACL pointed to by the Sacl 482 * field was provided by a defaulting mechanism rather than explicitly 483 * provided by the original provider of the security descriptor. This 484 * may affect the treatment of the ACL with respect to inheritance of 485 * an ACL. This flag is ignored if the SaclPresent flag is not set. 486 * 487 * SE_DACL_PROTECTED Prevents ACEs set on the DACL of the parent container 488 * (and any objects above the parent container in the directory hierarchy) 489 * from being applied to the object's DACL. 490 * 491 * SE_SACL_PROTECTED Prevents ACEs set on the SACL of the parent container 492 * (and any objects above the parent container in the directory hierarchy) 493 * from being applied to the object's SACL. 494 * 495 * Note that the SE_DACL_PRESENT flag needs to be present to set 496 * SE_DACL_PROTECTED and SE_SACL_PRESENT needs to be present to set 497 * SE_SACL_PROTECTED. 498 * 499 * SE_SELF_RELATIVE indicates that the security descriptor is in self- 500 * relative form. In this form, all fields of the security descriptor 501 * are contiguous in memory and all pointer fields are expressed as 502 * offsets from the beginning of the security descriptor. 503 * 504 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 505 * 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 506 * +---------------------------------------------------------------+ 507 * | Control |Reserved1 (SBZ)| Revision | 508 * +---------------------------------------------------------------+ 509 * | Owner | 510 * +---------------------------------------------------------------+ 511 * | Group | 512 * +---------------------------------------------------------------+ 513 * | Sacl | 514 * +---------------------------------------------------------------+ 515 * | Dacl | 516 * +---------------------------------------------------------------+ 517 * 518 */ 519 520 #define SMB_OWNER_SECINFO 0x0001 521 #define SMB_GROUP_SECINFO 0x0002 522 #define SMB_DACL_SECINFO 0x0004 523 #define SMB_SACL_SECINFO 0x0008 524 #define SMB_ALL_SECINFO 0x000F 525 #define SMB_ACL_SECINFO (SMB_DACL_SECINFO | SMB_SACL_SECINFO) 526 527 #define SECURITY_DESCRIPTOR_REVISION 1 528 529 530 #define SE_OWNER_DEFAULTED 0x0001 531 #define SE_GROUP_DEFAULTED 0x0002 532 #define SE_DACL_PRESENT 0x0004 533 #define SE_DACL_DEFAULTED 0x0008 534 #define SE_SACL_PRESENT 0x0010 535 #define SE_SACL_DEFAULTED 0x0020 536 #define SE_DACL_AUTO_INHERIT_REQ 0x0100 537 #define SE_SACL_AUTO_INHERIT_REQ 0x0200 538 #define SE_DACL_AUTO_INHERITED 0x0400 539 #define SE_SACL_AUTO_INHERITED 0x0800 540 #define SE_DACL_PROTECTED 0x1000 541 #define SE_SACL_PROTECTED 0x2000 542 #define SE_SELF_RELATIVE 0x8000 543 544 #define SE_DACL_INHERITANCE_MASK 0x1500 545 #define SE_SACL_INHERITANCE_MASK 0x2A00 546 547 /* 548 * Security descriptor structures: 549 * 550 * smb_sd_t SD in SMB pointer form 551 * smb_fssd_t SD in filesystem form 552 * 553 * Filesystems (e.g. ZFS/UFS) don't have something equivalent 554 * to SD. The items comprising a SMB SD are kept separately in 555 * filesystem. smb_fssd_t is introduced as a helper to provide 556 * the required abstraction for CIFS code. 557 */ 558 559 typedef struct smb_sd { 560 uint8_t sd_revision; 561 uint16_t sd_control; 562 smb_sid_t *sd_owner; /* SID file owner */ 563 smb_sid_t *sd_group; /* SID group (for POSIX) */ 564 smb_acl_t *sd_sacl; /* ACL System (audits) */ 565 smb_acl_t *sd_dacl; /* ACL Discretionary (perm) */ 566 } smb_sd_t; 567 568 /* 569 * SD header size as it appears on the wire 570 */ 571 #define SMB_SD_HDRSIZE 20 572 573 /* 574 * values for smb_fssd.sd_flags 575 */ 576 #define SMB_FSSD_FLAGS_DIR 0x01 577 578 typedef struct smb_fssd { 579 uint32_t sd_secinfo; 580 uint32_t sd_flags; 581 uid_t sd_uid; 582 gid_t sd_gid; 583 acl_t *sd_zdacl; 584 acl_t *sd_zsacl; 585 } smb_fssd_t; 586 587 void smb_sd_init(smb_sd_t *, uint8_t); 588 void smb_sd_term(smb_sd_t *); 589 uint32_t smb_sd_get_secinfo(smb_sd_t *); 590 uint32_t smb_sd_len(smb_sd_t *, uint32_t); 591 uint32_t smb_sd_tofs(smb_sd_t *, smb_fssd_t *); 592 593 void smb_fssd_init(smb_fssd_t *, uint32_t, uint32_t); 594 void smb_fssd_term(smb_fssd_t *); 595 596 void smb_acl_sort(smb_acl_t *); 597 void smb_acl_free(smb_acl_t *); 598 smb_acl_t *smb_acl_alloc(uint8_t, uint16_t, uint16_t); 599 smb_acl_t *smb_acl_from_zfs(acl_t *); 600 uint32_t smb_acl_to_zfs(smb_acl_t *, uint32_t, int, acl_t **); 601 uint16_t smb_acl_len(smb_acl_t *); 602 boolean_t smb_acl_isvalid(smb_acl_t *, int); 603 604 void smb_fsacl_free(acl_t *); 605 acl_t *smb_fsacl_alloc(int, int); 606 607 #ifdef __cplusplus 608 } 609 #endif 610 611 #endif /* _SMBSRV_NTIFS_H */ 612