1da6c28aaSamw /* 2da6c28aaSamw * CDDL HEADER START 3da6c28aaSamw * 4da6c28aaSamw * The contents of this file are subject to the terms of the 5da6c28aaSamw * Common Development and Distribution License (the "License"). 6da6c28aaSamw * You may not use this file except in compliance with the License. 7da6c28aaSamw * 8da6c28aaSamw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9da6c28aaSamw * or http://www.opensolaris.org/os/licensing. 10da6c28aaSamw * See the License for the specific language governing permissions 11da6c28aaSamw * and limitations under the License. 12da6c28aaSamw * 13da6c28aaSamw * When distributing Covered Code, include this CDDL HEADER in each 14da6c28aaSamw * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15da6c28aaSamw * If applicable, add the following below this CDDL HEADER, with the 16da6c28aaSamw * fields enclosed by brackets "[]" replaced with your own identifying 17da6c28aaSamw * information: Portions Copyright [yyyy] [name of copyright owner] 18da6c28aaSamw * 19da6c28aaSamw * CDDL HEADER END 20da6c28aaSamw */ 21da6c28aaSamw /* 22f96bd5c8SAlan Wright * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 23da6c28aaSamw * Use is subject to license terms. 24da6c28aaSamw */ 25da6c28aaSamw 26da6c28aaSamw #ifndef _SMBSRV_NTIFS_H 27da6c28aaSamw #define _SMBSRV_NTIFS_H 28da6c28aaSamw 29da6c28aaSamw /* 30da6c28aaSamw * This file provides definitions compatible with the NT Installable 3129bd2886SAlan Wright * File System (IFS) interface. This header file also defines the Security 3229bd2886SAlan Wright * Descriptor module from Windows. 33da6c28aaSamw */ 34da6c28aaSamw 35da6c28aaSamw #ifdef __cplusplus 36da6c28aaSamw extern "C" { 37da6c28aaSamw #endif 38da6c28aaSamw 3929bd2886SAlan Wright #include <sys/acl.h> 4029bd2886SAlan Wright #include <sys/list.h> 4129bd2886SAlan Wright #include <smbsrv/smb_sid.h> 4229bd2886SAlan Wright 43da6c28aaSamw /* 443db3f65cSamw * The Volume and Directory bits are for SMB rather than NT. 453db3f65cSamw * NT has an explicit Normal bit; this bit is implied in SMB 463db3f65cSamw * when the Hidden, System and Directory bits are not set. 473db3f65cSamw * 483db3f65cSamw * File attributes and creation flags share the same 32-bit 493db3f65cSamw * space. 50da6c28aaSamw */ 513db3f65cSamw #define FILE_ATTRIBUTE_READONLY 0x00000001 523db3f65cSamw #define FILE_ATTRIBUTE_HIDDEN 0x00000002 533db3f65cSamw #define FILE_ATTRIBUTE_SYSTEM 0x00000004 543db3f65cSamw #define FILE_ATTRIBUTE_VOLUME 0x00000008 553db3f65cSamw #define FILE_ATTRIBUTE_DIRECTORY 0x00000010 563db3f65cSamw #define FILE_ATTRIBUTE_ARCHIVE 0x00000020 573db3f65cSamw #define FILE_ATTRIBUTE_DEVICE 0x00000040 583db3f65cSamw #define FILE_ATTRIBUTE_NORMAL 0x00000080 593db3f65cSamw #define FILE_ATTRIBUTE_TEMPORARY 0x00000100 603db3f65cSamw #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 613db3f65cSamw #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 623db3f65cSamw #define FILE_ATTRIBUTE_COMPRESSED 0x00000800 633db3f65cSamw #define FILE_ATTRIBUTE_OFFLINE 0x00001000 643db3f65cSamw #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 653db3f65cSamw #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 663db3f65cSamw #define FILE_ATTRIBUTE_VIRTUAL 0x00010000 67da6c28aaSamw #define FILE_FLAG_OPEN_NO_RECALL 0x00100000 683db3f65cSamw #define FILE_FLAG_OPEN_REPARSE_POINT 0x00200000 693db3f65cSamw #define FILE_FLAG_POSIX_SEMANTICS 0x01000000 703db3f65cSamw #define FILE_FLAG_BACKUP_SEMANTICS 0x02000000 713db3f65cSamw #define FILE_FLAG_DELETE_ON_CLOSE 0x04000000 723db3f65cSamw #define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000 733db3f65cSamw #define FILE_FLAG_RANDOM_ACCESS 0x10000000 743db3f65cSamw #define FILE_FLAG_NO_BUFFERING 0x20000000 753db3f65cSamw #define FILE_FLAG_OVERLAPPED 0x40000000 763db3f65cSamw #define FILE_FLAG_WRITE_THROUGH 0x80000000 773db3f65cSamw 783db3f65cSamw #define FILE_ATTRIBUTE_VALID_FLAGS 0x00001fb7 793db3f65cSamw #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x00001fa7 803db3f65cSamw #define FILE_ATTRIBUTE_MASK 0x00003FFF 81da6c28aaSamw 82da6c28aaSamw /* 83da6c28aaSamw * The create/open option flags: used in NtCreateAndx and NtTransactCreate 84da6c28aaSamw * SMB requests. 85da6c28aaSamw * 86da6c28aaSamw * The CreateOptions specify the options to be applied when creating or 87da6c28aaSamw * opening the file, as a compatible combination of the following flags: 88da6c28aaSamw * 89da6c28aaSamw * FILE_DIRECTORY_FILE 90da6c28aaSamw * The file being created or opened is a directory file. With this 91da6c28aaSamw * flag, the Disposition parameter must be set to one of FILE_CREATE, 92da6c28aaSamw * FILE_OPEN, or FILE_OPEN_IF. With this flag, other compatible 93da6c28aaSamw * CreateOptions flags include only the following: 94da6c28aaSamw * FILE_SYNCHRONOUS_IO_ALERT 95da6c28aaSamw * FILE_SYNCHRONOUS_IO_NONALERT 96da6c28aaSamw * FILE_WRITE_THROUGH 97da6c28aaSamw * FILE_OPEN_FOR_BACKUP_INTENT 98da6c28aaSamw * FILE_OPEN_BY_FILE_ID 99da6c28aaSamw * 100da6c28aaSamw * FILE_NON_DIRECTORY_FILE 101da6c28aaSamw * The file being opened must not be a directory file or this call 102da6c28aaSamw * will fail. The file object being opened can represent a data file, 103da6c28aaSamw * a logical, virtual, or physical device, or a volume. 104da6c28aaSamw * 105da6c28aaSamw * FILE_WRITE_THROUGH 106da6c28aaSamw * System services, FSDs, and drivers that write data to the file must 107da6c28aaSamw * actually transfer the data into the file before any requested write 108da6c28aaSamw * operation is considered complete. This flag is automatically set if 109da6c28aaSamw * the CreateOptions flag FILE_NO_INTERMEDIATE _BUFFERING is set. 110da6c28aaSamw * 111da6c28aaSamw * FILE_SEQUENTIAL_ONLY 112da6c28aaSamw * All accesses to the file will be sequential. 113da6c28aaSamw * 114da6c28aaSamw * FILE_RANDOM_ACCESS 115da6c28aaSamw * Accesses to the file can be random, so no sequential read-ahead 116da6c28aaSamw * operations should be performed on the file by FSDs or the system. 117da6c28aaSamw * FILE_NO_INTERMEDIATE _BUFFERING The file cannot be cached or 118da6c28aaSamw * buffered in a driver's internal buffers. This flag is incompatible 119da6c28aaSamw * with the DesiredAccess FILE_APPEND_DATA flag. 120da6c28aaSamw * 121da6c28aaSamw * FILE_SYNCHRONOUS_IO_ALERT 122da6c28aaSamw * All operations on the file are performed synchronously. Any wait 123da6c28aaSamw * on behalf of the caller is subject to premature termination from 124da6c28aaSamw * alerts. This flag also causes the I/O system to maintain the file 125da6c28aaSamw * position context. If this flag is set, the DesiredAccess 126da6c28aaSamw * SYNCHRONIZE flag also must be set. 127da6c28aaSamw * 128da6c28aaSamw * FILE_SYNCHRONOUS_IO _NONALERT 129da6c28aaSamw * All operations on the file are performed synchronously. Waits in 130da6c28aaSamw * the system to synchronize I/O queuing and completion are not subject 131da6c28aaSamw * to alerts. This flag also causes the I/O system to maintain the file 132da6c28aaSamw * position context. If this flag is set, the DesiredAccess SYNCHRONIZE 133da6c28aaSamw * flag also must be set. 134da6c28aaSamw * 135da6c28aaSamw * FILE_CREATE_TREE _CONNECTION 136da6c28aaSamw * Create a tree connection for this file in order to open it over the 137da6c28aaSamw * network. This flag is irrelevant to device and intermediate drivers. 138da6c28aaSamw * 139da6c28aaSamw * FILE_COMPLETE_IF_OPLOCKED 140da6c28aaSamw * Complete this operation immediately with an alternate success code 141da6c28aaSamw * if the target file is oplocked, rather than blocking the caller's 142da6c28aaSamw * thread. If the file is oplocked, another caller already has access 143da6c28aaSamw * to the file over the network. This flag is irrelevant to device and 144da6c28aaSamw * intermediate drivers. 145da6c28aaSamw * 146da6c28aaSamw * FILE_NO_EA_KNOWLEDGE 147da6c28aaSamw * If the extended attributes on an existing file being opened indicate 148da6c28aaSamw * that the caller must understand EAs to properly interpret the file, 149da6c28aaSamw * fail this request because the caller does not understand how to deal 150da6c28aaSamw * with EAs. Device and intermediate drivers can ignore this flag. 151da6c28aaSamw * 152da6c28aaSamw * FILE_DELETE_ON_CLOSE 153da6c28aaSamw * Delete the file when the last reference to it is passed to close. 154da6c28aaSamw * 155da6c28aaSamw * FILE_OPEN_BY_FILE_ID 156da6c28aaSamw * The file name contains the name of a device and a 64-bit ID to 157da6c28aaSamw * be used to open the file. This flag is irrelevant to device and 158da6c28aaSamw * intermediate drivers. 159da6c28aaSamw * 160da6c28aaSamw * FILE_OPEN_FOR_BACKUP _INTENT 161da6c28aaSamw * The file is being opened for backup intent, hence, the system should 162da6c28aaSamw * check for certain access rights and grant the caller the appropriate 163da6c28aaSamw * accesses to the file before checking the input DesiredAccess against 164da6c28aaSamw * the file's security descriptor. This flag is irrelevant to device 165da6c28aaSamw * and intermediate drivers. 166da6c28aaSamw */ 167da6c28aaSamw #define FILE_DIRECTORY_FILE 0x00000001 168da6c28aaSamw #define FILE_WRITE_THROUGH 0x00000002 169da6c28aaSamw #define FILE_SEQUENTIAL_ONLY 0x00000004 170da6c28aaSamw #define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008 171da6c28aaSamw 172da6c28aaSamw #define FILE_SYNCHRONOUS_IO_ALERT 0x00000010 173da6c28aaSamw #define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020 174da6c28aaSamw #define FILE_NON_DIRECTORY_FILE 0x00000040 175da6c28aaSamw #define FILE_CREATE_TREE_CONNECTION 0x00000080 176da6c28aaSamw 177da6c28aaSamw #define FILE_COMPLETE_IF_OPLOCKED 0x00000100 178da6c28aaSamw #define FILE_NO_EA_KNOWLEDGE 0x00000200 179da6c28aaSamw /* UNUSED 0x00000400 */ 180da6c28aaSamw #define FILE_RANDOM_ACCESS 0x00000800 181da6c28aaSamw 182da6c28aaSamw #define FILE_DELETE_ON_CLOSE 0x00001000 183da6c28aaSamw #define FILE_OPEN_BY_FILE_ID 0x00002000 184da6c28aaSamw #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000 185da6c28aaSamw #define FILE_NO_COMPRESSION 0x00008000 186da6c28aaSamw 187da6c28aaSamw #define FILE_RESERVE_OPFILTER 0x00100000 188da6c28aaSamw #define FILE_RESERVED0 0x00200000 189da6c28aaSamw #define FILE_RESERVED1 0x00400000 190da6c28aaSamw #define FILE_RESERVED2 0x00800000 191da6c28aaSamw 192da6c28aaSamw #define FILE_VALID_OPTION_FLAGS 0x007fffff 193da6c28aaSamw #define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032 194da6c28aaSamw #define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032 195da6c28aaSamw #define FILE_VALID_SET_FLAGS 0x00000036 196da6c28aaSamw 197da6c28aaSamw /* 198da6c28aaSamw * Define the file information class values used by the NT DDK and HAL. 199da6c28aaSamw */ 200da6c28aaSamw typedef enum _FILE_INFORMATION_CLASS { 201da6c28aaSamw FileDirectoryInformation = 1, 202da6c28aaSamw FileFullDirectoryInformation, /* 2 */ 203da6c28aaSamw FileBothDirectoryInformation, /* 3 */ 204da6c28aaSamw FileBasicInformation, /* 4 */ 205da6c28aaSamw FileStandardInformation, /* 5 */ 206da6c28aaSamw FileInternalInformation, /* 6 */ 207da6c28aaSamw FileEaInformation, /* 7 */ 208da6c28aaSamw FileAccessInformation, /* 8 */ 209da6c28aaSamw FileNameInformation, /* 9 */ 210da6c28aaSamw FileRenameInformation, /* 10 */ 211da6c28aaSamw FileLinkInformation, /* 11 */ 212da6c28aaSamw FileNamesInformation, /* 12 */ 213da6c28aaSamw FileDispositionInformation, /* 13 */ 214da6c28aaSamw FilePositionInformation, /* 14 */ 215da6c28aaSamw FileFullEaInformation, /* 15 */ 216da6c28aaSamw FileModeInformation, /* 16 */ 217da6c28aaSamw FileAlignmentInformation, /* 17 */ 218da6c28aaSamw FileAllInformation, /* 18 */ 219da6c28aaSamw FileAllocationInformation, /* 19 */ 220da6c28aaSamw FileEndOfFileInformation, /* 20 */ 221da6c28aaSamw FileAlternateNameInformation, /* 21 */ 222da6c28aaSamw FileStreamInformation, /* 22 */ 223da6c28aaSamw FilePipeInformation, /* 23 */ 224da6c28aaSamw FilePipeLocalInformation, /* 24 */ 225da6c28aaSamw FilePipeRemoteInformation, /* 25 */ 226da6c28aaSamw FileMailslotQueryInformation, /* 26 */ 227da6c28aaSamw FileMailslotSetInformation, /* 27 */ 228da6c28aaSamw FileCompressionInformation, /* 28 */ 229da6c28aaSamw FileObjectIdInformation, /* 29 */ 230da6c28aaSamw FileCompletionInformation, /* 30 */ 231da6c28aaSamw FileMoveClusterInformation, /* 31 */ 232037cac00Sjoyce mcintosh FileQuotaInformation, /* 32 */ 233037cac00Sjoyce mcintosh FileReparsePointInformation, /* 33 */ 234da6c28aaSamw FileNetworkOpenInformation, /* 34 */ 2352c2961f8Sjose borrego FileAttributeTagInformation, /* 35 */ 236037cac00Sjoyce mcintosh FileTrackingInformation, /* 36 */ 237037cac00Sjoyce mcintosh FileIdBothDirectoryInformation, /* 37 */ 238037cac00Sjoyce mcintosh FileIdFullDirectoryInformation, /* 38 */ 239037cac00Sjoyce mcintosh FileValidDataLengthInformation, /* 39 */ 240037cac00Sjoyce mcintosh FileShortNameInformation, /* 40 */ 241037cac00Sjoyce mcintosh FileInformationReserved41, /* 41 */ 242037cac00Sjoyce mcintosh FileInformationReserved42, /* 42 */ 243037cac00Sjoyce mcintosh FileInformationReserved43, /* 43 */ 244037cac00Sjoyce mcintosh FileSfioReserveInformation, /* 44 */ 245037cac00Sjoyce mcintosh FileSfioVolumeInformation, /* 45 */ 246037cac00Sjoyce mcintosh FileHardLinkInformation, /* 46 */ 247037cac00Sjoyce mcintosh FileInformationReserved47, /* 47 */ 248037cac00Sjoyce mcintosh FileNormalizedNameInformation, /* 48 */ 249037cac00Sjoyce mcintosh FileInformationReserved49, /* 49 */ 250037cac00Sjoyce mcintosh FileIdGlobalTxDirectoryInformation, /* 50 */ 251037cac00Sjoyce mcintosh FileInformationReserved51, /* 51 */ 252037cac00Sjoyce mcintosh FileInformationReserved52, /* 52 */ 253037cac00Sjoyce mcintosh FileInformationReserved53, /* 53 */ 254037cac00Sjoyce mcintosh FileStandardLinkInformation, /* 54 */ 255da6c28aaSamw FileMaximumInformation 256da6c28aaSamw } FILE_INFORMATION_CLASS; 257da6c28aaSamw 25829bd2886SAlan Wright /* 259*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Define the file system information class values. 260*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 261*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States typedef enum _FILE_FS_INFORMATION_CLASS { 262*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States FileFsVolumeInformation = 1, 263*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States FileFsLabelInformation, /* 2 */ 264*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States FileFsSizeInformation, /* 3 */ 265*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States FileFsDeviceInformation, /* 4 */ 266*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States FileFsAttributeInformation, /* 5 */ 267*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States FileFsControlInformation, /* 6 */ 268*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States FileFsFullSizeInformation, /* 7 */ 269*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States FileFsObjectIdInformation, /* 8 */ 270*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States FileFsDriverPathInformation /* 9 */ 271*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } FILE_FS_INFORMATION_CLASS; 272*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 273*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 27429bd2886SAlan Wright * Discretionary Access Control List (DACL) 27529bd2886SAlan Wright * 27629bd2886SAlan Wright * A Discretionary Access Control List (DACL), often abbreviated to 27729bd2886SAlan Wright * ACL, is a list of access controls which either allow or deny access 27829bd2886SAlan Wright * for users or groups to a resource. There is a list header followed 27929bd2886SAlan Wright * by a list of access control entries (ACE). Each ACE specifies the 28029bd2886SAlan Wright * access allowed or denied to a single user or group (identified by 28129bd2886SAlan Wright * a SID). 28229bd2886SAlan Wright * 28329bd2886SAlan Wright * There is another access control list object called a System Access 28429bd2886SAlan Wright * Control List (SACL), which is used to control auditing, but no 28529bd2886SAlan Wright * support is provideed for SACLs at this time. 28629bd2886SAlan Wright * 28729bd2886SAlan Wright * ACL header format: 28829bd2886SAlan Wright * 28929bd2886SAlan Wright * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 29029bd2886SAlan Wright * 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 29129bd2886SAlan Wright * +-------------------------------+---------------+---------------+ 29229bd2886SAlan Wright * | AclSize | Sbz1 | AclRevision | 29329bd2886SAlan Wright * +-------------------------------+---------------+---------------+ 29429bd2886SAlan Wright * | Sbz2 | AceCount | 29529bd2886SAlan Wright * +-------------------------------+-------------------------------+ 29629bd2886SAlan Wright * 29729bd2886SAlan Wright * AclRevision specifies the revision level of the ACL. This value should 29829bd2886SAlan Wright * be ACL_REVISION, unless the ACL contains an object-specific ACE, in which 29929bd2886SAlan Wright * case this value must be ACL_REVISION_DS. All ACEs in an ACL must be at the 30029bd2886SAlan Wright * same revision level. 30129bd2886SAlan Wright * 30229bd2886SAlan Wright * ACE header format: 30329bd2886SAlan Wright * 30429bd2886SAlan Wright * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 30529bd2886SAlan Wright * 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 30629bd2886SAlan Wright * +---------------+-------+-------+---------------+---------------+ 30729bd2886SAlan Wright * | AceSize | AceFlags | AceType | 30829bd2886SAlan Wright * +---------------+-------+-------+---------------+---------------+ 30929bd2886SAlan Wright * 31029bd2886SAlan Wright * Access mask format: 31129bd2886SAlan Wright * 31229bd2886SAlan Wright * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 31329bd2886SAlan Wright * 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 31429bd2886SAlan Wright * +---------------+---------------+-------------------------------+ 31529bd2886SAlan Wright * |G|G|G|G|Res'd|A| StandardRights| SpecificRights | 31629bd2886SAlan Wright * |R|W|E|A| |S| | | 31729bd2886SAlan Wright * +-+-------------+---------------+-------------------------------+ 31829bd2886SAlan Wright * 31929bd2886SAlan Wright * typedef struct ACCESS_MASK { 32029bd2886SAlan Wright * WORD SpecificRights; 32129bd2886SAlan Wright * BYTE StandardRights; 32229bd2886SAlan Wright * BYTE AccessSystemAcl : 1; 32329bd2886SAlan Wright * BYTE Reserved : 3; 32429bd2886SAlan Wright * BYTE GenericAll : 1; 32529bd2886SAlan Wright * BYTE GenericExecute : 1; 32629bd2886SAlan Wright * BYTE GenericWrite : 1; 32729bd2886SAlan Wright * BYTE GenericRead : 1; 32829bd2886SAlan Wright * } ACCESS_MASK; 32929bd2886SAlan Wright * 33029bd2886SAlan Wright */ 33129bd2886SAlan Wright 33229bd2886SAlan Wright #define ACL_REVISION1 1 33329bd2886SAlan Wright #define ACL_REVISION2 2 33429bd2886SAlan Wright #define MIN_ACL_REVISION2 ACL_REVISION2 33529bd2886SAlan Wright #define ACL_REVISION3 3 33629bd2886SAlan Wright #define ACL_REVISION4 4 33729bd2886SAlan Wright #define MAX_ACL_REVISION ACL_REVISION4 33829bd2886SAlan Wright 33929bd2886SAlan Wright /* 34029bd2886SAlan Wright * Current ACE and ACL revision Levels 34129bd2886SAlan Wright */ 34229bd2886SAlan Wright #define ACE_REVISION 1 34329bd2886SAlan Wright #define ACL_REVISION ACL_REVISION2 34429bd2886SAlan Wright #define ACL_REVISION_DS ACL_REVISION4 34529bd2886SAlan Wright 34629bd2886SAlan Wright 34729bd2886SAlan Wright #define ACCESS_ALLOWED_ACE_TYPE 0 34829bd2886SAlan Wright #define ACCESS_DENIED_ACE_TYPE 1 34929bd2886SAlan Wright #define SYSTEM_AUDIT_ACE_TYPE 2 35029bd2886SAlan Wright #define SYSTEM_ALARM_ACE_TYPE 3 35129bd2886SAlan Wright 35229bd2886SAlan Wright /* 35329bd2886SAlan Wright * se_flags 35429bd2886SAlan Wright * ---------- 35529bd2886SAlan Wright * Specifies a set of ACE type-specific control flags. This member can be a 35629bd2886SAlan Wright * combination of the following values. 35729bd2886SAlan Wright * 35829bd2886SAlan Wright * CONTAINER_INHERIT_ACE: Child objects that are containers, such as 35929bd2886SAlan Wright * directories, inherit the ACE as an effective ACE. The inherited 36029bd2886SAlan Wright * ACE is inheritable unless the NO_PROPAGATE_INHERIT_ACE bit flag 36129bd2886SAlan Wright * is also set. 36229bd2886SAlan Wright * 36329bd2886SAlan Wright * INHERIT_ONLY_ACE: Indicates an inherit-only ACE which does not control 36429bd2886SAlan Wright * access to the object to which it is attached. 36529bd2886SAlan Wright * If this flag is not set, 36629bd2886SAlan Wright * the ACE is an effective ACE which controls access to the object 36729bd2886SAlan Wright * to which it is attached. 36829bd2886SAlan Wright * Both effective and inherit-only ACEs can be inherited 36929bd2886SAlan Wright * depending on the state of the other inheritance flags. 37029bd2886SAlan Wright * 37129bd2886SAlan Wright * INHERITED_ACE: Windows 2000/XP: Indicates that the ACE was inherited. 37229bd2886SAlan Wright * The system sets this bit when it propagates an 37329bd2886SAlan Wright * inherited ACE to a child object. 37429bd2886SAlan Wright * 37529bd2886SAlan Wright * NO_PROPAGATE_INHERIT_ACE: If the ACE is inherited by a child object, the 37629bd2886SAlan Wright * system clears the OBJECT_INHERIT_ACE and CONTAINER_INHERIT_ACE 37729bd2886SAlan Wright * flags in the inherited ACE. 37829bd2886SAlan Wright * This prevents the ACE from being inherited by 37929bd2886SAlan Wright * subsequent generations of objects. 38029bd2886SAlan Wright * 38129bd2886SAlan Wright * OBJECT_INHERIT_ACE: Noncontainer child objects inherit the ACE as an 38229bd2886SAlan Wright * effective ACE. For child objects that are containers, 38329bd2886SAlan Wright * the ACE is inherited as an inherit-only ACE unless the 38429bd2886SAlan Wright * NO_PROPAGATE_INHERIT_ACE bit flag is also set. 38529bd2886SAlan Wright */ 38629bd2886SAlan Wright #define OBJECT_INHERIT_ACE 0x01 38729bd2886SAlan Wright #define CONTAINER_INHERIT_ACE 0x02 38829bd2886SAlan Wright #define NO_PROPOGATE_INHERIT_ACE 0x04 38929bd2886SAlan Wright #define INHERIT_ONLY_ACE 0x08 39029bd2886SAlan Wright #define INHERITED_ACE 0x10 39129bd2886SAlan Wright #define INHERIT_MASK_ACE 0x1F 39229bd2886SAlan Wright 39329bd2886SAlan Wright 39429bd2886SAlan Wright /* 39529bd2886SAlan Wright * These flags are only used in system audit or alarm ACEs to 39629bd2886SAlan Wright * indicate when an audit message should be generated, i.e. 39729bd2886SAlan Wright * on successful access or on unsuccessful access. 39829bd2886SAlan Wright */ 39929bd2886SAlan Wright #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40 40029bd2886SAlan Wright #define FAILED_ACCESS_ACE_FLAG 0x80 40129bd2886SAlan Wright 40229bd2886SAlan Wright /* 40329bd2886SAlan Wright * se_bsize is the size, in bytes, of ACE as it appears on the wire. 40429bd2886SAlan Wright * se_sln is used to sort the ACL when it's required. 40529bd2886SAlan Wright */ 40629bd2886SAlan Wright typedef struct smb_acehdr { 40729bd2886SAlan Wright uint8_t se_type; 40829bd2886SAlan Wright uint8_t se_flags; 40929bd2886SAlan Wright uint16_t se_bsize; 41029bd2886SAlan Wright } smb_acehdr_t; 41129bd2886SAlan Wright 41229bd2886SAlan Wright typedef struct smb_ace { 41329bd2886SAlan Wright smb_acehdr_t se_hdr; 41429bd2886SAlan Wright uint32_t se_mask; 41529bd2886SAlan Wright list_node_t se_sln; 41629bd2886SAlan Wright smb_sid_t *se_sid; 41729bd2886SAlan Wright } smb_ace_t; 41829bd2886SAlan Wright 41929bd2886SAlan Wright /* 42029bd2886SAlan Wright * sl_bsize is the size of ACL in bytes as it appears on the wire. 42129bd2886SAlan Wright */ 42229bd2886SAlan Wright typedef struct smb_acl { 42329bd2886SAlan Wright uint8_t sl_revision; 42429bd2886SAlan Wright uint16_t sl_bsize; 42529bd2886SAlan Wright uint16_t sl_acecnt; 42629bd2886SAlan Wright smb_ace_t *sl_aces; 42729bd2886SAlan Wright list_t sl_sorted; 42829bd2886SAlan Wright } smb_acl_t; 42929bd2886SAlan Wright 43029bd2886SAlan Wright /* 43129bd2886SAlan Wright * ACE/ACL header size, in byte, as it appears on the wire 43229bd2886SAlan Wright */ 43329bd2886SAlan Wright #define SMB_ACE_HDRSIZE 4 43429bd2886SAlan Wright #define SMB_ACL_HDRSIZE 8 43529bd2886SAlan Wright 43629bd2886SAlan Wright /* 43729bd2886SAlan Wright * Security Descriptor (SD) 43829bd2886SAlan Wright * 43929bd2886SAlan Wright * Security descriptors provide protection for objects, for example 44029bd2886SAlan Wright * files and directories. It identifies the owner and primary group 44129bd2886SAlan Wright * (SIDs) and contains an access control list. When a user tries to 44229bd2886SAlan Wright * access an object his SID is compared to the permissions in the 44329bd2886SAlan Wright * DACL to determine if access should be allowed or denied. Note that 44429bd2886SAlan Wright * this is a simplification because there are other factors, such as 44529bd2886SAlan Wright * default behavior and privileges to be taken into account (see also 44629bd2886SAlan Wright * access tokens). 44729bd2886SAlan Wright * 44829bd2886SAlan Wright * The boolean flags have the following meanings when set: 44929bd2886SAlan Wright * 45029bd2886SAlan Wright * SE_OWNER_DEFAULTED indicates that the SID pointed to by the Owner 45129bd2886SAlan Wright * field was provided by a defaulting mechanism rather than explicitly 45229bd2886SAlan Wright * provided by the original provider of the security descriptor. This 45329bd2886SAlan Wright * may affect the treatment of the SID with respect to inheritance of 45429bd2886SAlan Wright * an owner. 45529bd2886SAlan Wright * 45629bd2886SAlan Wright * SE_GROUP_DEFAULTED indicates that the SID in the Group field was 45729bd2886SAlan Wright * provided by a defaulting mechanism rather than explicitly provided 45829bd2886SAlan Wright * by the original provider of the security descriptor. This may 45929bd2886SAlan Wright * affect the treatment of the SID with respect to inheritance of a 46029bd2886SAlan Wright * primary group. 46129bd2886SAlan Wright * 46229bd2886SAlan Wright * SE_DACL_PRESENT indicates that the security descriptor contains a 46329bd2886SAlan Wright * discretionary ACL. If this flag is set and the Dacl field of the 46429bd2886SAlan Wright * SECURITY_DESCRIPTOR is null, then a null ACL is explicitly being 46529bd2886SAlan Wright * specified. 46629bd2886SAlan Wright * 46729bd2886SAlan Wright * SE_DACL_DEFAULTED indicates that the ACL pointed to by the Dacl 46829bd2886SAlan Wright * field was provided by a defaulting mechanism rather than explicitly 46929bd2886SAlan Wright * provided by the original provider of the security descriptor. This 47029bd2886SAlan Wright * may affect the treatment of the ACL with respect to inheritance of 47129bd2886SAlan Wright * an ACL. This flag is ignored if the DaclPresent flag is not set. 47229bd2886SAlan Wright * 47329bd2886SAlan Wright * SE_SACL_PRESENT indicates that the security descriptor contains a 47429bd2886SAlan Wright * system ACL pointed to by the Sacl field. If this flag is set and 47529bd2886SAlan Wright * the Sacl field of the SECURITY_DESCRIPTOR is null, then an empty 47629bd2886SAlan Wright * (but present) ACL is being specified. 47729bd2886SAlan Wright * 47829bd2886SAlan Wright * SE_SACL_DEFAULTED indicates that the ACL pointed to by the Sacl 47929bd2886SAlan Wright * field was provided by a defaulting mechanism rather than explicitly 48029bd2886SAlan Wright * provided by the original provider of the security descriptor. This 48129bd2886SAlan Wright * may affect the treatment of the ACL with respect to inheritance of 48229bd2886SAlan Wright * an ACL. This flag is ignored if the SaclPresent flag is not set. 48329bd2886SAlan Wright * 48429bd2886SAlan Wright * SE_DACL_PROTECTED Prevents ACEs set on the DACL of the parent container 48529bd2886SAlan Wright * (and any objects above the parent container in the directory hierarchy) 48629bd2886SAlan Wright * from being applied to the object's DACL. 48729bd2886SAlan Wright * 48829bd2886SAlan Wright * SE_SACL_PROTECTED Prevents ACEs set on the SACL of the parent container 48929bd2886SAlan Wright * (and any objects above the parent container in the directory hierarchy) 49029bd2886SAlan Wright * from being applied to the object's SACL. 49129bd2886SAlan Wright * 49229bd2886SAlan Wright * Note that the SE_DACL_PRESENT flag needs to be present to set 49329bd2886SAlan Wright * SE_DACL_PROTECTED and SE_SACL_PRESENT needs to be present to set 49429bd2886SAlan Wright * SE_SACL_PROTECTED. 49529bd2886SAlan Wright * 49629bd2886SAlan Wright * SE_SELF_RELATIVE indicates that the security descriptor is in self- 49729bd2886SAlan Wright * relative form. In this form, all fields of the security descriptor 49829bd2886SAlan Wright * are contiguous in memory and all pointer fields are expressed as 49929bd2886SAlan Wright * offsets from the beginning of the security descriptor. 50029bd2886SAlan Wright * 50129bd2886SAlan Wright * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 50229bd2886SAlan Wright * 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 50329bd2886SAlan Wright * +---------------------------------------------------------------+ 50429bd2886SAlan Wright * | Control |Reserved1 (SBZ)| Revision | 50529bd2886SAlan Wright * +---------------------------------------------------------------+ 50629bd2886SAlan Wright * | Owner | 50729bd2886SAlan Wright * +---------------------------------------------------------------+ 50829bd2886SAlan Wright * | Group | 50929bd2886SAlan Wright * +---------------------------------------------------------------+ 51029bd2886SAlan Wright * | Sacl | 51129bd2886SAlan Wright * +---------------------------------------------------------------+ 51229bd2886SAlan Wright * | Dacl | 51329bd2886SAlan Wright * +---------------------------------------------------------------+ 51429bd2886SAlan Wright * 51529bd2886SAlan Wright */ 51629bd2886SAlan Wright 51729bd2886SAlan Wright #define SMB_OWNER_SECINFO 0x0001 51829bd2886SAlan Wright #define SMB_GROUP_SECINFO 0x0002 51929bd2886SAlan Wright #define SMB_DACL_SECINFO 0x0004 52029bd2886SAlan Wright #define SMB_SACL_SECINFO 0x0008 52129bd2886SAlan Wright #define SMB_ALL_SECINFO 0x000F 52229bd2886SAlan Wright #define SMB_ACL_SECINFO (SMB_DACL_SECINFO | SMB_SACL_SECINFO) 52329bd2886SAlan Wright 52429bd2886SAlan Wright #define SECURITY_DESCRIPTOR_REVISION 1 52529bd2886SAlan Wright 52629bd2886SAlan Wright 52729bd2886SAlan Wright #define SE_OWNER_DEFAULTED 0x0001 52829bd2886SAlan Wright #define SE_GROUP_DEFAULTED 0x0002 52929bd2886SAlan Wright #define SE_DACL_PRESENT 0x0004 53029bd2886SAlan Wright #define SE_DACL_DEFAULTED 0x0008 53129bd2886SAlan Wright #define SE_SACL_PRESENT 0x0010 53229bd2886SAlan Wright #define SE_SACL_DEFAULTED 0x0020 53329bd2886SAlan Wright #define SE_DACL_AUTO_INHERIT_REQ 0x0100 53429bd2886SAlan Wright #define SE_SACL_AUTO_INHERIT_REQ 0x0200 53529bd2886SAlan Wright #define SE_DACL_AUTO_INHERITED 0x0400 53629bd2886SAlan Wright #define SE_SACL_AUTO_INHERITED 0x0800 53729bd2886SAlan Wright #define SE_DACL_PROTECTED 0x1000 53829bd2886SAlan Wright #define SE_SACL_PROTECTED 0x2000 53929bd2886SAlan Wright #define SE_SELF_RELATIVE 0x8000 54029bd2886SAlan Wright 54129bd2886SAlan Wright #define SE_DACL_INHERITANCE_MASK 0x1500 54229bd2886SAlan Wright #define SE_SACL_INHERITANCE_MASK 0x2A00 54329bd2886SAlan Wright 54429bd2886SAlan Wright /* 54529bd2886SAlan Wright * Security descriptor structures: 54629bd2886SAlan Wright * 54729bd2886SAlan Wright * smb_sd_t SD in SMB pointer form 54829bd2886SAlan Wright * smb_fssd_t SD in filesystem form 54929bd2886SAlan Wright * 55029bd2886SAlan Wright * Filesystems (e.g. ZFS/UFS) don't have something equivalent 55129bd2886SAlan Wright * to SD. The items comprising a SMB SD are kept separately in 55229bd2886SAlan Wright * filesystem. smb_fssd_t is introduced as a helper to provide 55329bd2886SAlan Wright * the required abstraction for CIFS code. 55429bd2886SAlan Wright */ 55529bd2886SAlan Wright 55629bd2886SAlan Wright typedef struct smb_sd { 55729bd2886SAlan Wright uint8_t sd_revision; 55829bd2886SAlan Wright uint16_t sd_control; 55929bd2886SAlan Wright smb_sid_t *sd_owner; /* SID file owner */ 56029bd2886SAlan Wright smb_sid_t *sd_group; /* SID group (for POSIX) */ 56129bd2886SAlan Wright smb_acl_t *sd_sacl; /* ACL System (audits) */ 56229bd2886SAlan Wright smb_acl_t *sd_dacl; /* ACL Discretionary (perm) */ 56329bd2886SAlan Wright } smb_sd_t; 56429bd2886SAlan Wright 56529bd2886SAlan Wright /* 56629bd2886SAlan Wright * SD header size as it appears on the wire 56729bd2886SAlan Wright */ 56829bd2886SAlan Wright #define SMB_SD_HDRSIZE 20 56929bd2886SAlan Wright 57029bd2886SAlan Wright /* 57129bd2886SAlan Wright * values for smb_fssd.sd_flags 57229bd2886SAlan Wright */ 57329bd2886SAlan Wright #define SMB_FSSD_FLAGS_DIR 0x01 57429bd2886SAlan Wright 57529bd2886SAlan Wright typedef struct smb_fssd { 57629bd2886SAlan Wright uint32_t sd_secinfo; 57729bd2886SAlan Wright uint32_t sd_flags; 57829bd2886SAlan Wright uid_t sd_uid; 57929bd2886SAlan Wright gid_t sd_gid; 58029bd2886SAlan Wright acl_t *sd_zdacl; 58129bd2886SAlan Wright acl_t *sd_zsacl; 58229bd2886SAlan Wright } smb_fssd_t; 58329bd2886SAlan Wright 58429bd2886SAlan Wright void smb_sd_init(smb_sd_t *, uint8_t); 58529bd2886SAlan Wright void smb_sd_term(smb_sd_t *); 58629bd2886SAlan Wright uint32_t smb_sd_get_secinfo(smb_sd_t *); 58729bd2886SAlan Wright uint32_t smb_sd_len(smb_sd_t *, uint32_t); 58829bd2886SAlan Wright uint32_t smb_sd_tofs(smb_sd_t *, smb_fssd_t *); 58929bd2886SAlan Wright 59029bd2886SAlan Wright void smb_fssd_init(smb_fssd_t *, uint32_t, uint32_t); 59129bd2886SAlan Wright void smb_fssd_term(smb_fssd_t *); 59229bd2886SAlan Wright 59329bd2886SAlan Wright void smb_acl_sort(smb_acl_t *); 59429bd2886SAlan Wright void smb_acl_free(smb_acl_t *); 59529bd2886SAlan Wright smb_acl_t *smb_acl_alloc(uint8_t, uint16_t, uint16_t); 596f96bd5c8SAlan Wright smb_acl_t *smb_acl_from_zfs(acl_t *); 59729bd2886SAlan Wright uint32_t smb_acl_to_zfs(smb_acl_t *, uint32_t, int, acl_t **); 59829bd2886SAlan Wright uint16_t smb_acl_len(smb_acl_t *); 59929bd2886SAlan Wright boolean_t smb_acl_isvalid(smb_acl_t *, int); 60029bd2886SAlan Wright 60129bd2886SAlan Wright void smb_fsacl_free(acl_t *); 60229bd2886SAlan Wright acl_t *smb_fsacl_alloc(int, int); 60329bd2886SAlan Wright 604da6c28aaSamw #ifdef __cplusplus 605da6c28aaSamw } 606da6c28aaSamw #endif 607da6c28aaSamw 608da6c28aaSamw #endif /* _SMBSRV_NTIFS_H */ 609