]> wimlib.net Git - wimlib/blob - include/wimlib/security_descriptor.h
bt_matchfinder: remove unnecessary max_len parameter to skip routine
[wimlib] / include / wimlib / security_descriptor.h
1 /*
2  * security_descriptor.h - declarations for Windows security descriptor format
3  *
4  * The following copying information applies to this specific source code file:
5  *
6  * Written in 2013-2015 by Eric Biggers <ebiggers3@gmail.com>
7  *
8  * To the extent possible under law, the author(s) have dedicated all copyright
9  * and related and neighboring rights to this software to the public domain
10  * worldwide via the Creative Commons Zero 1.0 Universal Public Domain
11  * Dedication (the "CC0").
12  *
13  * This software is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the CC0 for more details.
16  *
17  * You should have received a copy of the CC0 along with this software; if not
18  * see <http://creativecommons.org/publicdomain/zero/1.0/>.
19  */
20
21 #ifndef _WIMLIB_SECURITY_DESCRIPTOR_H
22 #define _WIMLIB_SECURITY_DESCRIPTOR_H
23
24 #include "wimlib/compiler.h"
25 #include "wimlib/types.h"
26
27 /* Note: the data types in this header are prefixed with wimlib_ to avoid
28  * conflicts with the same types being defined in the libntfs-3g headers.  */
29
30 /* Windows NT security descriptor, in self-relative format  */
31 typedef struct {
32         /* Security descriptor revision; should be 1  */
33         u8 revision;
34
35         /* Padding  */
36         u8 sbz1;
37
38         /* Bitwise OR of flags defined below, such as SE_DACL_PRESENT  */
39         le16 control;
40
41         /* Offset of owenr SID structure in the security descriptor  */
42         le32 owner_offset;
43
44         /* Offset of group SID structure in the security descriptor  */
45         le32 group_offset;
46
47         /* Offset of System Access Control List (SACL) in security descriptor,
48          * or 0 if no SACL is present  */
49         le32 sacl_offset;
50
51         /* Offset of Discretionary Access Control List (DACL) in security
52          * descriptor, or 0 if no DACL is present  */
53         le32 dacl_offset;
54 } _packed_attribute wimlib_SECURITY_DESCRIPTOR_RELATIVE;
55
56 #define wimlib_SE_OWNER_DEFAULTED               0x0001
57 #define wimlib_SE_GROUP_DEFAULTED               0x0002
58 #define wimlib_SE_DACL_PRESENT                  0x0004
59 #define wimlib_SE_DACL_DEFAULTED                0x0008
60 #define wimlib_SE_SACL_PRESENT                  0x0010
61 #define wimlib_SE_SACL_DEFAULTED                0x0020
62 #define wimlib_SE_DACL_AUTO_INHERIT_REQ         0x0100
63 #define wimlib_SE_SACL_AUTO_INHERIT_REQ         0x0200
64 #define wimlib_SE_DACL_AUTO_INHERITED           0x0400
65 #define wimlib_SE_SACL_AUTO_INHERITED           0x0800
66 #define wimlib_SE_DACL_PROTECTED                0x1000
67 #define wimlib_SE_SACL_PROTECTED                0x2000
68 #define wimlib_SE_RM_CONTROL_VALID              0x4000
69 #define wimlib_SE_SELF_RELATIVE                 0x8000
70
71 /* Windows NT security identifier (user or group)  */
72 typedef struct {
73
74         u8  revision;
75         u8  sub_authority_count;
76
77         /* Identifies the authority that issued the SID  */
78         u8  identifier_authority[6];
79
80         le32 sub_authority[];
81 } _packed_attribute wimlib_SID;
82
83 /* Header of a Windows NT access control list  */
84 typedef struct {
85         /* ACL_REVISION or ACL_REVISION_DS */
86         u8 revision;
87
88         /* padding  */
89         u8 sbz1;
90
91         /* Total size of the ACL, including all access control entries  */
92         le16 acl_size;
93
94         /* Number of access control entry structures that follow the ACL
95          * structure  */
96         le16 ace_count;
97
98         /* padding  */
99         le16 sbz2;
100 } _packed_attribute wimlib_ACL;
101
102 #define wimlib_ACCESS_ALLOWED_ACE_TYPE          0
103 #define wimlib_ACCESS_DENIED_ACE_TYPE           1
104 #define wimlib_SYSTEM_AUDIT_ACE_TYPE            2
105
106 /* Header of a Windows NT access control entry  */
107 typedef struct {
108         /* Type of ACE  */
109         u8 type;
110
111         /* Bitwise OR of inherit ACE flags  */
112         u8 flags;
113
114         /* Size of the access control entry, including this header  */
115         le16 size;
116 } _packed_attribute wimlib_ACE_HEADER;
117
118 /* Windows NT access control entry to grant rights to a user or group  */
119 typedef struct {
120         wimlib_ACE_HEADER hdr;
121         le32 mask;
122         wimlib_SID sid;
123 } _packed_attribute wimlib_ACCESS_ALLOWED_ACE;
124
125 /* Windows NT access control entry to deny rights to a user or group  */
126 typedef struct {
127         wimlib_ACE_HEADER hdr;
128         le32 mask;
129         wimlib_SID sid;
130 } _packed_attribute wimlib_ACCESS_DENIED_ACE;
131
132 /* Windows NT access control entry to audit access to the object  */
133 typedef struct {
134         wimlib_ACE_HEADER hdr;
135         le32 mask;
136         wimlib_SID sid;
137 } _packed_attribute wimlib_SYSTEM_AUDIT_ACE;
138
139 #endif /* _WIMLIB_SECURITY_DESCRIPTOR_H */