]> wimlib.net Git - wimlib/blob - include/wimlib/security_descriptor.h
ff789e2c8397e703cceaaf6e3efb2a1f6d3d798f
[wimlib] / include / wimlib / security_descriptor.h
1 /*
2  * security_descriptor.h
3  *
4  * The author dedicates this file to the public domain.
5  * You can do whatever you want with this file.
6  */
7
8 #ifndef _WIMLIB_SECURITY_DESCRIPTOR_H
9 #define _WIMLIB_SECURITY_DESCRIPTOR_H
10
11 #include "wimlib/compiler.h"
12 #include "wimlib/types.h"
13
14 /* Note: the data types in this header are prefixed with wimlib_ to avoid
15  * conflicts with the same types being defined in the libntfs-3g headers.  */
16
17 /* Windows NT security descriptor, in self-relative format  */
18 typedef struct {
19         /* Security descriptor revision; should be 1  */
20         u8 revision;
21
22         /* Padding  */
23         u8 sbz1;
24
25         /* Bitwise OR of flags defined below, such as SE_DACL_PRESENT  */
26         le16 control;
27
28         /* Offset of owenr SID structure in the security descriptor  */
29         le32 owner_offset;
30
31         /* Offset of group SID structure in the security descriptor  */
32         le32 group_offset;
33
34         /* Offset of System Access Control List (SACL) in security descriptor,
35          * or 0 if no SACL is present  */
36         le32 sacl_offset;
37
38         /* Offset of Discretionary Access Control List (DACL) in security
39          * descriptor, or 0 if no DACL is present  */
40         le32 dacl_offset;
41 } _packed_attribute wimlib_SECURITY_DESCRIPTOR_RELATIVE;
42
43 #define wimlib_SE_OWNER_DEFAULTED               0x0001
44 #define wimlib_SE_GROUP_DEFAULTED               0x0002
45 #define wimlib_SE_DACL_PRESENT                  0x0004
46 #define wimlib_SE_DACL_DEFAULTED                0x0008
47 #define wimlib_SE_SACL_PRESENT                  0x0010
48 #define wimlib_SE_SACL_DEFAULTED                0x0020
49 #define wimlib_SE_DACL_AUTO_INHERIT_REQ         0x0100
50 #define wimlib_SE_SACL_AUTO_INHERIT_REQ         0x0200
51 #define wimlib_SE_DACL_AUTO_INHERITED           0x0400
52 #define wimlib_SE_SACL_AUTO_INHERITED           0x0800
53 #define wimlib_SE_DACL_PROTECTED                0x1000
54 #define wimlib_SE_SACL_PROTECTED                0x2000
55 #define wimlib_SE_RM_CONTROL_VALID              0x4000
56 #define wimlib_SE_SELF_RELATIVE                 0x8000
57
58 /* Windows NT security identifier (user or group)  */
59 typedef struct {
60
61         u8  revision;
62         u8  sub_authority_count;
63
64         /* Identifies the authority that issued the SID  */
65         u8  identifier_authority[6];
66
67         le32 sub_authority[];
68 } _packed_attribute wimlib_SID;
69
70 /* Header of a Windows NT access control list  */
71 typedef struct {
72         /* ACL_REVISION or ACL_REVISION_DS */
73         u8 revision;
74
75         /* padding  */
76         u8 sbz1;
77
78         /* Total size of the ACL, including all access control entries  */
79         le16 acl_size;
80
81         /* Number of access control entry structures that follow the ACL
82          * structure  */
83         le16 ace_count;
84
85         /* padding  */
86         le16 sbz2;
87 } _packed_attribute wimlib_ACL;
88
89 #define wimlib_ACCESS_ALLOWED_ACE_TYPE          0
90 #define wimlib_ACCESS_DENIED_ACE_TYPE           1
91 #define wimlib_SYSTEM_AUDIT_ACE_TYPE            2
92
93 /* Header of a Windows NT access control entry  */
94 typedef struct {
95         /* Type of ACE  */
96         u8 type;
97
98         /* Bitwise OR of inherit ACE flags  */
99         u8 flags;
100
101         /* Size of the access control entry, including this header  */
102         le16 size;
103 } _packed_attribute wimlib_ACE_HEADER;
104
105 /* Windows NT access control entry to grant rights to a user or group  */
106 typedef struct {
107         wimlib_ACE_HEADER hdr;
108         le32 mask;
109         wimlib_SID sid;
110 } _packed_attribute wimlib_ACCESS_ALLOWED_ACE;
111
112 /* Windows NT access control entry to deny rights to a user or group  */
113 typedef struct {
114         wimlib_ACE_HEADER hdr;
115         le32 mask;
116         wimlib_SID sid;
117 } _packed_attribute wimlib_ACCESS_DENIED_ACE;
118
119 /* Windows NT access control entry to audit access to the object  */
120 typedef struct {
121         wimlib_ACE_HEADER hdr;
122         le32 mask;
123         wimlib_SID sid;
124 } _packed_attribute wimlib_SYSTEM_AUDIT_ACE;
125
126
127 #endif