Merge branch 'master' of git://git.samba.org/samba
[amitay/samba.git] / source3 / include / rpc_secdes.h
1 /* 
2    Unix SMB/CIFS implementation.
3    SMB parameters and setup
4    Copyright (C) Andrew Tridgell              1992-2000
5    Copyright (C) Luke Kenneth Casson Leighton 1996-2000
6    
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef _RPC_SECDES_H /* _RPC_SECDES_H */
22 #define _RPC_SECDES_H 
23
24 /* for ADS */
25 #define SEC_RIGHTS_LIST_CONTENTS        0x4
26 #define SEC_RIGHTS_LIST_OBJECT          0x80
27 #define SEC_RIGHTS_READ_ALL_PROP        0x10
28 #define SEC_RIGHTS_READ_PERMS           0x20000
29 #define SEC_RIGHTS_WRITE_ALL_VALID      0x8
30 #define SEC_RIGHTS_WRITE_ALL_PROP       0x20     
31 #define SEC_RIGHTS_MODIFY_OWNER         0x80000
32 #define SEC_RIGHTS_MODIFY_PERMS         0x40000
33 #define SEC_RIGHTS_CREATE_CHILD         0x1
34 #define SEC_RIGHTS_DELETE_CHILD         0x2
35 #define SEC_RIGHTS_DELETE_SUBTREE       0x40
36 #define SEC_RIGHTS_DELETE               0x10000 /* advanced/special/object/delete */
37 #define SEC_RIGHTS_EXTENDED             0x100 /* change/reset password, receive/send as*/
38 #define SEC_RIGHTS_CHANGE_PASSWD        SEC_RIGHTS_EXTENDED
39 #define SEC_RIGHTS_RESET_PASSWD         SEC_RIGHTS_EXTENDED
40 #define SEC_RIGHTS_FULL_CTRL            0xf01ff
41
42 #define SEC_ACE_OBJECT_PRESENT           0x00000001 /* thanks for Jim McDonough <jmcd@us.ibm.com> */
43 #define SEC_ACE_OBJECT_INHERITED_PRESENT 0x00000002
44
45 /*
46  * New Windows 2000 bits.
47  */
48 #define SE_DESC_DACL_AUTO_INHERIT_REQ   0x0100
49 #define SE_DESC_SACL_AUTO_INHERIT_REQ   0x0200
50 #define SE_DESC_DACL_AUTO_INHERITED     0x0400
51 #define SE_DESC_SACL_AUTO_INHERITED     0x0800
52 #define SE_DESC_DACL_PROTECTED          0x1000
53 #define SE_DESC_SACL_PROTECTED          0x2000
54
55 /* security information */
56 #define OWNER_SECURITY_INFORMATION      0x00000001
57 #define GROUP_SECURITY_INFORMATION      0x00000002
58 #define DACL_SECURITY_INFORMATION       0x00000004
59 #define SACL_SECURITY_INFORMATION       0x00000008
60 /* Extra W2K flags. */
61 #define UNPROTECTED_SACL_SECURITY_INFORMATION   0x10000000
62 #define UNPROTECTED_DACL_SECURITY_INFORMATION   0x20000000
63 #define PROTECTED_SACL_SECURITY_INFORMATION     0x40000000
64 #define PROTECTED_DACL_SECURITY_INFORMATION     0x80000000
65
66 #define ALL_SECURITY_INFORMATION (OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|\
67                                         DACL_SECURITY_INFORMATION|SACL_SECURITY_INFORMATION|\
68                                         UNPROTECTED_SACL_SECURITY_INFORMATION|\
69                                         UNPROTECTED_DACL_SECURITY_INFORMATION|\
70                                         PROTECTED_SACL_SECURITY_INFORMATION|\
71                                         PROTECTED_DACL_SECURITY_INFORMATION)
72
73 /* SEC_ACE */
74 typedef struct security_ace SEC_ACE;
75 #define  SEC_ACE_HEADER_SIZE (2 * sizeof(uint8) + sizeof(uint16) + sizeof(uint32))
76
77 #ifndef ACL_REVISION
78 #define ACL_REVISION 0x3
79 #endif
80
81 #ifndef _SEC_ACL
82 /* SEC_ACL */
83 typedef struct security_acl SEC_ACL;
84 #define  SEC_ACL_HEADER_SIZE (2 * sizeof(uint16) + sizeof(uint32))
85 #define _SEC_ACL
86 #endif
87
88 #ifndef SEC_DESC_REVISION
89 #define SEC_DESC_REVISION 0x1
90 #endif
91
92 #ifndef _SEC_DESC
93 /* SEC_DESC */
94 typedef struct security_descriptor SEC_DESC;
95 #define  SEC_DESC_HEADER_SIZE (2 * sizeof(uint16) + 4 * sizeof(uint32))
96 #define _SEC_DESC
97 #endif
98
99 #ifndef _SEC_DESC_BUF
100 /* SEC_DESC_BUF */
101 typedef struct sec_desc_buf SEC_DESC_BUF;
102 #define _SEC_DESC_BUF
103 #endif
104
105 /* A type to describe the mapping of generic access rights to object
106    specific access rights. */
107
108 struct generic_mapping {
109         uint32 generic_read;
110         uint32 generic_write;
111         uint32 generic_execute;
112         uint32 generic_all;
113 };
114
115 struct standard_mapping {
116         uint32 std_read;
117         uint32 std_write;
118         uint32 std_execute;
119         uint32 std_all;
120 };
121
122
123 /* Security Access Masks Rights */
124
125 #define SPECIFIC_RIGHTS_MASK    0x0000FFFF
126 #define STANDARD_RIGHTS_MASK    0x00FF0000
127 #define GENERIC_RIGHTS_MASK     0xF0000000
128
129 #define SEC_RIGHT_SYSTEM_SECURITY       0x01000000
130 #define SEC_RIGHT_MAXIMUM_ALLOWED       0x02000000
131
132 /* Generic access rights */
133
134 #define GENERIC_RIGHT_ALL_ACCESS        0x10000000
135 #define GENERIC_RIGHT_EXECUTE_ACCESS    0x20000000
136 #define GENERIC_RIGHT_WRITE_ACCESS      0x40000000
137 #define GENERIC_RIGHT_READ_ACCESS       0x80000000
138
139 /* Standard access rights. */
140
141 #define STD_RIGHT_DELETE_ACCESS         0x00010000
142 #define STD_RIGHT_READ_CONTROL_ACCESS   0x00020000
143 #define STD_RIGHT_WRITE_DAC_ACCESS      0x00040000
144 #define STD_RIGHT_WRITE_OWNER_ACCESS    0x00080000
145 #define STD_RIGHT_SYNCHRONIZE_ACCESS    0x00100000
146
147 #define STD_RIGHT_ALL_ACCESS            0x001F0000
148
149 /* Combinations of standard masks. */
150 #define STANDARD_RIGHTS_ALL_ACCESS      STD_RIGHT_ALL_ACCESS /* 0x001f0000 */
151 #define STANDARD_RIGHTS_MODIFY_ACCESS   STD_RIGHT_READ_CONTROL_ACCESS /* 0x00020000 */
152 #define STANDARD_RIGHTS_EXECUTE_ACCESS  STD_RIGHT_READ_CONTROL_ACCESS /* 0x00020000 */
153 #define STANDARD_RIGHTS_READ_ACCESS     STD_RIGHT_READ_CONTROL_ACCESS /* 0x00020000 */
154 #define STANDARD_RIGHTS_WRITE_ACCESS \
155                 (STD_RIGHT_WRITE_OWNER_ACCESS   | \
156                  STD_RIGHT_WRITE_DAC_ACCESS     | \
157                  STD_RIGHT_DELETE_ACCESS)       /* 0x000d0000 */
158 #define STANDARD_RIGHTS_REQUIRED_ACCESS \
159                 (STD_RIGHT_DELETE_ACCESS        | \
160                 STD_RIGHT_READ_CONTROL_ACCESS   | \
161                 STD_RIGHT_WRITE_DAC_ACCESS      | \
162                 STD_RIGHT_WRITE_OWNER_ACCESS)   /* 0x000f0000 */
163
164 /* File Object specific access rights */
165
166 #define SA_RIGHT_FILE_READ_DATA         0x00000001
167 #define SA_RIGHT_FILE_WRITE_DATA        0x00000002
168 #define SA_RIGHT_FILE_APPEND_DATA       0x00000004
169 #define SA_RIGHT_FILE_READ_EA           0x00000008
170 #define SA_RIGHT_FILE_WRITE_EA          0x00000010
171 #define SA_RIGHT_FILE_EXECUTE           0x00000020
172 #define SA_RIGHT_FILE_DELETE_CHILD      0x00000040
173 #define SA_RIGHT_FILE_READ_ATTRIBUTES   0x00000080
174 #define SA_RIGHT_FILE_WRITE_ATTRIBUTES  0x00000100
175
176 #define SA_RIGHT_FILE_ALL_ACCESS        0x000001FF
177
178 #define GENERIC_RIGHTS_FILE_ALL_ACCESS \
179                 (STANDARD_RIGHTS_REQUIRED_ACCESS| \
180                 STD_RIGHT_SYNCHRONIZE_ACCESS    | \
181                 SA_RIGHT_FILE_ALL_ACCESS)
182
183 #define GENERIC_RIGHTS_FILE_READ        \
184                 (STANDARD_RIGHTS_READ_ACCESS    | \
185                 STD_RIGHT_SYNCHRONIZE_ACCESS    | \
186                 SA_RIGHT_FILE_READ_DATA         | \
187                 SA_RIGHT_FILE_READ_ATTRIBUTES   | \
188                 SA_RIGHT_FILE_READ_EA)
189
190 #define GENERIC_RIGHTS_FILE_WRITE \
191                 (STANDARD_RIGHTS_WRITE_ACCESS   | \
192                 STD_RIGHT_SYNCHRONIZE_ACCESS    | \
193                 SA_RIGHT_FILE_WRITE_DATA        | \
194                 SA_RIGHT_FILE_WRITE_ATTRIBUTES  | \
195                 SA_RIGHT_FILE_WRITE_EA          | \
196                 SA_RIGHT_FILE_APPEND_DATA)
197
198 #define GENERIC_RIGHTS_FILE_EXECUTE \
199                 (STANDARD_RIGHTS_EXECUTE_ACCESS | \
200                 STD_RIGHT_SYNCHRONIZE_ACCESS    | \
201                 SA_RIGHT_FILE_READ_ATTRIBUTES   | \
202                 SA_RIGHT_FILE_EXECUTE)            
203
204 #define GENERIC_RIGHTS_FILE_MODIFY \
205                 (STANDARD_RIGHTS_MODIFY_ACCESS  | \
206                 STD_RIGHT_SYNCHRONIZE_ACCESS    | \
207                 STD_RIGHT_DELETE_ACCESS         | \
208                 SA_RIGHT_FILE_WRITE_ATTRIBUTES  | \
209                 SA_RIGHT_FILE_READ_ATTRIBUTES   | \
210                 SA_RIGHT_FILE_EXECUTE           | \
211                 SA_RIGHT_FILE_WRITE_EA          | \
212                 SA_RIGHT_FILE_READ_EA           | \
213                 SA_RIGHT_FILE_APPEND_DATA       | \
214                 SA_RIGHT_FILE_WRITE_DATA        | \
215                 SA_RIGHT_FILE_READ_DATA)
216
217 /* SAM server specific access rights */
218
219 #define SA_RIGHT_SAM_CONNECT_SERVER     0x00000001
220 #define SA_RIGHT_SAM_SHUTDOWN_SERVER    0x00000002
221 #define SA_RIGHT_SAM_INITIALISE_SERVER  0x00000004
222 #define SA_RIGHT_SAM_CREATE_DOMAIN      0x00000008
223 #define SA_RIGHT_SAM_ENUM_DOMAINS       0x00000010
224 #define SA_RIGHT_SAM_OPEN_DOMAIN        0x00000020
225
226 #define SA_RIGHT_SAM_ALL_ACCESS         0x0000003F
227
228 #define GENERIC_RIGHTS_SAM_ALL_ACCESS \
229                 (STANDARD_RIGHTS_REQUIRED_ACCESS| \
230                 SA_RIGHT_SAM_ALL_ACCESS)
231
232 #define GENERIC_RIGHTS_SAM_READ \
233                 (STANDARD_RIGHTS_READ_ACCESS    | \
234                 SA_RIGHT_SAM_ENUM_DOMAINS)
235
236 #define GENERIC_RIGHTS_SAM_WRITE \
237                 (STANDARD_RIGHTS_WRITE_ACCESS   | \
238                 SA_RIGHT_SAM_CREATE_DOMAIN      | \
239                 SA_RIGHT_SAM_INITIALISE_SERVER  | \
240                 SA_RIGHT_SAM_SHUTDOWN_SERVER)
241
242 #define GENERIC_RIGHTS_SAM_EXECUTE \
243                 (STANDARD_RIGHTS_EXECUTE_ACCESS | \
244                 SA_RIGHT_SAM_OPEN_DOMAIN        | \
245                 SA_RIGHT_SAM_CONNECT_SERVER)            
246
247
248 /* Domain Object specific access rights */
249
250 #define SA_RIGHT_DOMAIN_LOOKUP_INFO_1           0x00000001
251 #define SA_RIGHT_DOMAIN_SET_INFO_1              0x00000002
252 #define SA_RIGHT_DOMAIN_LOOKUP_INFO_2           0x00000004
253 #define SA_RIGHT_DOMAIN_SET_INFO_2              0x00000008
254 #define SA_RIGHT_DOMAIN_CREATE_USER             0x00000010
255 #define SA_RIGHT_DOMAIN_CREATE_GROUP            0x00000020
256 #define SA_RIGHT_DOMAIN_CREATE_ALIAS            0x00000040
257 #define SA_RIGHT_DOMAIN_LOOKUP_ALIAS_BY_MEM     0x00000080
258 #define SA_RIGHT_DOMAIN_ENUM_ACCOUNTS           0x00000100
259 #define SA_RIGHT_DOMAIN_OPEN_ACCOUNT            0x00000200
260 #define SA_RIGHT_DOMAIN_SET_INFO_3              0x00000400
261
262 #define SA_RIGHT_DOMAIN_ALL_ACCESS              0x000007FF
263
264 #define GENERIC_RIGHTS_DOMAIN_ALL_ACCESS \
265                 (STANDARD_RIGHTS_REQUIRED_ACCESS| \
266                 SA_RIGHT_DOMAIN_ALL_ACCESS)
267
268 #define GENERIC_RIGHTS_DOMAIN_READ \
269                 (STANDARD_RIGHTS_READ_ACCESS            | \
270                 SA_RIGHT_DOMAIN_LOOKUP_ALIAS_BY_MEM     | \
271                 SA_RIGHT_DOMAIN_LOOKUP_INFO_2)
272
273 #define GENERIC_RIGHTS_DOMAIN_WRITE \
274                 (STANDARD_RIGHTS_WRITE_ACCESS   | \
275                 SA_RIGHT_DOMAIN_SET_INFO_3      | \
276                 SA_RIGHT_DOMAIN_CREATE_ALIAS    | \
277                 SA_RIGHT_DOMAIN_CREATE_GROUP    | \
278                 SA_RIGHT_DOMAIN_CREATE_USER     | \
279                 SA_RIGHT_DOMAIN_SET_INFO_2      | \
280                 SA_RIGHT_DOMAIN_SET_INFO_1)
281
282 #define GENERIC_RIGHTS_DOMAIN_EXECUTE \
283                 (STANDARD_RIGHTS_EXECUTE_ACCESS | \
284                 SA_RIGHT_DOMAIN_OPEN_ACCOUNT    | \
285                 SA_RIGHT_DOMAIN_ENUM_ACCOUNTS   | \
286                 SA_RIGHT_DOMAIN_LOOKUP_INFO_1)            
287
288
289 /* User Object specific access rights */
290
291 #define SA_RIGHT_USER_GET_NAME_ETC      0x00000001
292 #define SA_RIGHT_USER_GET_LOCALE        0x00000002
293 #define SA_RIGHT_USER_SET_LOC_COM       0x00000004
294 #define SA_RIGHT_USER_GET_LOGONINFO     0x00000008
295 #define SA_RIGHT_USER_ACCT_FLAGS_EXPIRY 0x00000010
296 #define SA_RIGHT_USER_SET_ATTRIBUTES    0x00000020
297 #define SA_RIGHT_USER_CHANGE_PASSWORD   0x00000040
298 #define SA_RIGHT_USER_SET_PASSWORD      0x00000080
299 #define SA_RIGHT_USER_GET_GROUPS        0x00000100
300 #define SA_RIGHT_USER_READ_GROUP_MEM    0x00000200
301 #define SA_RIGHT_USER_CHANGE_GROUP_MEM  0x00000400
302
303 #define SA_RIGHT_USER_ALL_ACCESS        0x000007FF
304
305 #define GENERIC_RIGHTS_USER_ALL_ACCESS \
306                 (STANDARD_RIGHTS_REQUIRED_ACCESS| \
307                 SA_RIGHT_USER_ALL_ACCESS)       /* 0x000f07ff */
308
309 #define GENERIC_RIGHTS_USER_READ \
310                 (STANDARD_RIGHTS_READ_ACCESS    | \
311                 SA_RIGHT_USER_READ_GROUP_MEM    | \
312                 SA_RIGHT_USER_GET_GROUPS        | \
313                 SA_RIGHT_USER_ACCT_FLAGS_EXPIRY | \
314                 SA_RIGHT_USER_GET_LOGONINFO     | \
315                 SA_RIGHT_USER_GET_LOCALE)       /* 0x0002031a */
316
317 #define GENERIC_RIGHTS_USER_WRITE \
318                 (STANDARD_RIGHTS_WRITE_ACCESS   | \
319                 SA_RIGHT_USER_CHANGE_PASSWORD   | \
320                 SA_RIGHT_USER_SET_LOC_COM       | \
321                 SA_RIGHT_USER_SET_ATTRIBUTES    | \
322                 SA_RIGHT_USER_SET_PASSWORD      | \
323                 SA_RIGHT_USER_CHANGE_GROUP_MEM) /* 0x000204e4 */
324
325 #define GENERIC_RIGHTS_USER_EXECUTE \
326                 (STANDARD_RIGHTS_EXECUTE_ACCESS | \
327                 SA_RIGHT_USER_CHANGE_PASSWORD   | \
328                 SA_RIGHT_USER_GET_NAME_ETC )    /* 0x00020041 */
329
330
331 /* Group Object specific access rights */
332
333 #define SA_RIGHT_GROUP_LOOKUP_INFO      0x00000001
334 #define SA_RIGHT_GROUP_SET_INFO         0x00000002
335 #define SA_RIGHT_GROUP_ADD_MEMBER       0x00000004
336 #define SA_RIGHT_GROUP_REMOVE_MEMBER    0x00000008
337 #define SA_RIGHT_GROUP_GET_MEMBERS      0x00000010
338
339 #define SA_RIGHT_GROUP_ALL_ACCESS       0x0000001F
340
341 #define GENERIC_RIGHTS_GROUP_ALL_ACCESS \
342                 (STANDARD_RIGHTS_REQUIRED_ACCESS| \
343                 SA_RIGHT_GROUP_ALL_ACCESS)      /* 0x000f001f */
344
345 #define GENERIC_RIGHTS_GROUP_READ \
346                 (STANDARD_RIGHTS_READ_ACCESS    | \
347                 SA_RIGHT_GROUP_GET_MEMBERS)     /* 0x00020010 */
348
349 #define GENERIC_RIGHTS_GROUP_WRITE \
350                 (STANDARD_RIGHTS_WRITE_ACCESS   | \
351                 SA_RIGHT_GROUP_REMOVE_MEMBER    | \
352                 SA_RIGHT_GROUP_ADD_MEMBER       | \
353                 SA_RIGHT_GROUP_SET_INFO )       /* 0x0002000e */
354
355 #define GENERIC_RIGHTS_GROUP_EXECUTE \
356                 (STANDARD_RIGHTS_EXECUTE_ACCESS | \
357                 SA_RIGHT_GROUP_LOOKUP_INFO)     /* 0x00020001 */
358
359
360 /* Alias Object specific access rights */
361
362 #define SA_RIGHT_ALIAS_ADD_MEMBER       0x00000001
363 #define SA_RIGHT_ALIAS_REMOVE_MEMBER    0x00000002
364 #define SA_RIGHT_ALIAS_GET_MEMBERS      0x00000004
365 #define SA_RIGHT_ALIAS_LOOKUP_INFO      0x00000008
366 #define SA_RIGHT_ALIAS_SET_INFO         0x00000010
367
368 #define SA_RIGHT_ALIAS_ALL_ACCESS       0x0000001F
369
370 #define GENERIC_RIGHTS_ALIAS_ALL_ACCESS \
371                 (STANDARD_RIGHTS_REQUIRED_ACCESS| \
372                 SA_RIGHT_ALIAS_ALL_ACCESS)      /* 0x000f001f */
373
374 #define GENERIC_RIGHTS_ALIAS_READ \
375                 (STANDARD_RIGHTS_READ_ACCESS    | \
376                 SA_RIGHT_ALIAS_GET_MEMBERS )    /* 0x00020004 */
377
378 #define GENERIC_RIGHTS_ALIAS_WRITE \
379                 (STANDARD_RIGHTS_WRITE_ACCESS   | \
380                 SA_RIGHT_ALIAS_REMOVE_MEMBER    | \
381                 SA_RIGHT_ALIAS_ADD_MEMBER       | \
382                 SA_RIGHT_ALIAS_SET_INFO )       /* 0x00020013 */
383
384 #define GENERIC_RIGHTS_ALIAS_EXECUTE \
385                 (STANDARD_RIGHTS_EXECUTE_ACCESS | \
386                 SA_RIGHT_ALIAS_LOOKUP_INFO )    /* 0x00020008 */
387
388 /*
389  * Access Bits for registry ACLS
390  */
391
392 /* used by registry ACLs */
393
394 #define SEC_RIGHTS_QUERY_VALUE          0x00000001
395 #define SEC_RIGHTS_SET_VALUE            0x00000002
396 #define SEC_RIGHTS_CREATE_SUBKEY        0x00000004
397 #define SEC_RIGHTS_ENUM_SUBKEYS         0x00000008
398 #define SEC_RIGHTS_NOTIFY               0x00000010
399 #define SEC_RIGHTS_CREATE_LINK          0x00000020
400 #define SEC_RIGHTS_MAXIMUM_ALLOWED      0x02000000
401
402
403 #define REG_KEY_READ \
404         ( STANDARD_RIGHTS_READ_ACCESS           |\
405           SEC_RIGHTS_QUERY_VALUE                |\
406           SEC_RIGHTS_ENUM_SUBKEYS               |\
407           SEC_RIGHTS_NOTIFY )
408           
409 #define REG_KEY_EXECUTE REG_KEY_READ
410
411 #define REG_KEY_WRITE \
412         ( STANDARD_RIGHTS_WRITE_ACCESS          |\
413           SEC_RIGHTS_SET_VALUE                  |\
414           SEC_RIGHTS_CREATE_SUBKEY )
415
416 #define REG_KEY_ALL \
417         ( STANDARD_RIGHTS_REQUIRED_ACCESS       |\
418           REG_KEY_READ                          |\
419           REG_KEY_WRITE                         |\
420           SEC_RIGHTS_CREATE_LINK )
421
422
423 #endif /* _RPC_SECDES_H */