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