1 | /* $Id: sec.cpp,v 1.2 1999-06-10 17:06:46 phaller Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
5 | * Win32 NT Runtime / NTDLL for OS/2
|
---|
6 | *
|
---|
7 | * Copyright 1998 original WINE Author
|
---|
8 | * Copyright 1998, 1999 Patrick Haller (phaller@gmx.net)
|
---|
9 | *
|
---|
10 | * Security functions
|
---|
11 | *
|
---|
12 | * Copyright 1996-1998 Marcus Meissner
|
---|
13 | */
|
---|
14 |
|
---|
15 | #include <stdlib.h>
|
---|
16 | #include <string.h>
|
---|
17 | #include <time.h>
|
---|
18 | #include <ctype.h>
|
---|
19 | #include <math.h>
|
---|
20 |
|
---|
21 | #include <os2win.h>
|
---|
22 | #include "ntdll.h"
|
---|
23 |
|
---|
24 | /*
|
---|
25 | #include "windef.h"
|
---|
26 | #include "winbase.h"
|
---|
27 | #include "winuser.h"
|
---|
28 | #include "wine/winestring.h"
|
---|
29 | #include "heap.h"
|
---|
30 | #include "winnls.h"
|
---|
31 | #include "winuser.h"
|
---|
32 | #include "winerror.h"
|
---|
33 | #include "stackframe.h"
|
---|
34 |
|
---|
35 | #include "winreg.h"
|
---|
36 | */
|
---|
37 |
|
---|
38 | /*
|
---|
39 | * SID FUNCTIONS
|
---|
40 | */
|
---|
41 |
|
---|
42 | /******************************************************************************
|
---|
43 | * RtlAllocateAndInitializeSid [NTDLL.265]
|
---|
44 | *
|
---|
45 | */
|
---|
46 | BOOLEAN WINAPI RtlAllocateAndInitializeSid (PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
|
---|
47 | DWORD nSubAuthorityCount,
|
---|
48 | DWORD x3,
|
---|
49 | DWORD x4,
|
---|
50 | DWORD x5,
|
---|
51 | DWORD x6,
|
---|
52 | DWORD x7,
|
---|
53 | DWORD x8,
|
---|
54 | DWORD x9,
|
---|
55 | DWORD x10,
|
---|
56 | PSID pSid)
|
---|
57 | {
|
---|
58 | dprintf(("NTDLL: RtlAllocateAndInitializeSid(%08xh,%08xh,%08xh,"
|
---|
59 | "%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
---|
60 | pIdentifierAuthority,
|
---|
61 | nSubAuthorityCount,
|
---|
62 | x3,
|
---|
63 | x4,
|
---|
64 | x5,
|
---|
65 | x6,
|
---|
66 | x7,
|
---|
67 | x8,
|
---|
68 | x9,
|
---|
69 | x10,
|
---|
70 | pSid));
|
---|
71 |
|
---|
72 | return 0;
|
---|
73 | }
|
---|
74 |
|
---|
75 |
|
---|
76 | /******************************************************************************
|
---|
77 | * RtlEqualSid [NTDLL.352]
|
---|
78 | *
|
---|
79 | */
|
---|
80 | DWORD WINAPI RtlEqualSid(DWORD x1,
|
---|
81 | DWORD x2)
|
---|
82 | {
|
---|
83 | dprintf(("NTDLL: RtlEqualSid(%08x, %08x) not implemented.\n",
|
---|
84 | x1,
|
---|
85 | x2));
|
---|
86 |
|
---|
87 | return TRUE;
|
---|
88 | }
|
---|
89 |
|
---|
90 |
|
---|
91 | /******************************************************************************
|
---|
92 | * RtlFreeSid [NTDLL.376]
|
---|
93 | */
|
---|
94 | DWORD WINAPI RtlFreeSid(DWORD x1)
|
---|
95 | {
|
---|
96 | dprintf(("NTDLL: RtlFreeSid(%08xh) not implemented.\n",
|
---|
97 | x1));
|
---|
98 |
|
---|
99 | return TRUE;
|
---|
100 | }
|
---|
101 |
|
---|
102 |
|
---|
103 | /**************************************************************************
|
---|
104 | * RtlLengthRequiredSid [NTDLL.427]
|
---|
105 | */
|
---|
106 | DWORD WINAPI RtlLengthRequiredSid(DWORD nrofsubauths)
|
---|
107 | {
|
---|
108 | dprintf (("NTDLL: RtlLengthRequiredSid(%08xh)\n",
|
---|
109 | nrofsubauths));
|
---|
110 |
|
---|
111 | return sizeof(DWORD)*nrofsubauths+sizeof(SID);
|
---|
112 | }
|
---|
113 |
|
---|
114 |
|
---|
115 | /**************************************************************************
|
---|
116 | * RtlLengthSid [NTDLL.429]
|
---|
117 | */
|
---|
118 | DWORD WINAPI RtlLengthSid(PSID sid)
|
---|
119 | {
|
---|
120 | dprintf(("NTDLL: RtlLengthSid(%08xh)\n",
|
---|
121 | sid));
|
---|
122 |
|
---|
123 | if (!sid)
|
---|
124 | return FALSE;
|
---|
125 |
|
---|
126 | return sizeof(DWORD)*sid->SubAuthorityCount+sizeof(SID);
|
---|
127 | }
|
---|
128 |
|
---|
129 |
|
---|
130 | /**************************************************************************
|
---|
131 | * RtlInitializeSid [NTDLL.410]
|
---|
132 | */
|
---|
133 | DWORD WINAPI RtlInitializeSid(PSID psid,
|
---|
134 | PSID_IDENTIFIER_AUTHORITY psidauth,
|
---|
135 | DWORD c)
|
---|
136 | {
|
---|
137 | BYTE a = c & 0xff;
|
---|
138 |
|
---|
139 | dprintf(("NTDLL: RtlInitializeSid(%08xh,%08xh,%08xh)\n",
|
---|
140 | psid,
|
---|
141 | psidauth,
|
---|
142 | c));
|
---|
143 |
|
---|
144 | if (a>=SID_MAX_SUB_AUTHORITIES)
|
---|
145 | return a;
|
---|
146 |
|
---|
147 | psid->SubAuthorityCount = a;
|
---|
148 | psid->Revision = SID_REVISION;
|
---|
149 | memcpy(&(psid->IdentifierAuthority),
|
---|
150 | psidauth,
|
---|
151 | sizeof(SID_IDENTIFIER_AUTHORITY));
|
---|
152 |
|
---|
153 | return STATUS_SUCCESS;
|
---|
154 | }
|
---|
155 |
|
---|
156 |
|
---|
157 | /**************************************************************************
|
---|
158 | * RtlSubAuthoritySid [NTDLL.497]
|
---|
159 | */
|
---|
160 | LPDWORD WINAPI RtlSubAuthoritySid(PSID psid,
|
---|
161 | DWORD nr)
|
---|
162 | {
|
---|
163 | dprintf(("NTDLL: RtlSubAuthoritySid(%08xh,%08xh)\n",
|
---|
164 | psid,
|
---|
165 | nr));
|
---|
166 |
|
---|
167 | return &(psid->SubAuthority[nr]);
|
---|
168 | }
|
---|
169 |
|
---|
170 |
|
---|
171 | /**************************************************************************
|
---|
172 | * RtlSubAuthorityCountSid [NTDLL.496]
|
---|
173 | */
|
---|
174 |
|
---|
175 | LPBYTE WINAPI RtlSubAuthorityCountSid(PSID psid)
|
---|
176 | {
|
---|
177 | dprintf(("NTDLL: RtlSubAUthorityCountSid(%08xh)\n",
|
---|
178 | psid));
|
---|
179 |
|
---|
180 | return ((LPBYTE)psid)+1;
|
---|
181 | }
|
---|
182 |
|
---|
183 |
|
---|
184 | /**************************************************************************
|
---|
185 | * RtlCopySid [NTDLL.302]
|
---|
186 | */
|
---|
187 | DWORD WINAPI RtlCopySid(DWORD len,
|
---|
188 | PSID to,
|
---|
189 | PSID from)
|
---|
190 | {
|
---|
191 | dprintf(("NTDLL: RtlCopySid(%08xh,%08xh,%08xh)\n",
|
---|
192 | len,
|
---|
193 | to,
|
---|
194 | from));
|
---|
195 |
|
---|
196 | if (!from)
|
---|
197 | return 0;
|
---|
198 |
|
---|
199 | if (len<(from->SubAuthorityCount*4+8))
|
---|
200 | return STATUS_BUFFER_TOO_SMALL;
|
---|
201 |
|
---|
202 | memmove(to,
|
---|
203 | from,
|
---|
204 | from->SubAuthorityCount*4+8);
|
---|
205 |
|
---|
206 | return STATUS_SUCCESS;
|
---|
207 | }
|
---|
208 |
|
---|
209 |
|
---|
210 | /*
|
---|
211 | * security descriptor functions
|
---|
212 | */
|
---|
213 |
|
---|
214 | /**************************************************************************
|
---|
215 | * RtlCreateSecurityDescriptor [NTDLL.313]
|
---|
216 | *
|
---|
217 | * RETURNS:
|
---|
218 | * 0 success,
|
---|
219 | * STATUS_INVALID_OWNER, STATUS_PRIVILEGE_NOT_HELD, STATUS_NO_INHERITANCE,
|
---|
220 | * STATUS_NO_MEMORY
|
---|
221 | */
|
---|
222 | NTSTATUS WINAPI RtlCreateSecurityDescriptor(PSECURITY_DESCRIPTOR lpsd,
|
---|
223 | DWORD rev)
|
---|
224 | {
|
---|
225 | dprintf(("NTDLL: RtlCreateSecurityDescriptor(%08xh,%08xh)\n",
|
---|
226 | lpsd,
|
---|
227 | rev));
|
---|
228 |
|
---|
229 | if (rev!=SECURITY_DESCRIPTOR_REVISION)
|
---|
230 | return STATUS_UNKNOWN_REVISION;
|
---|
231 |
|
---|
232 | memset(lpsd,
|
---|
233 | '\0',
|
---|
234 | sizeof(*lpsd));
|
---|
235 |
|
---|
236 | lpsd->Revision = SECURITY_DESCRIPTOR_REVISION;
|
---|
237 |
|
---|
238 | return STATUS_SUCCESS;
|
---|
239 | }
|
---|
240 |
|
---|
241 |
|
---|
242 | /**************************************************************************
|
---|
243 | * RtlValidSecurityDescriptor [NTDLL.313]
|
---|
244 | *
|
---|
245 | */
|
---|
246 | NTSTATUS WINAPI RtlValidSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor)
|
---|
247 | {
|
---|
248 | dprintf(("NTDLL: RtlValidSecurityDescriptor(%08xh)\n",
|
---|
249 | SecurityDescriptor));
|
---|
250 |
|
---|
251 | if ( ! SecurityDescriptor )
|
---|
252 | return STATUS_INVALID_SECURITY_DESCR;
|
---|
253 |
|
---|
254 | if ( SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION )
|
---|
255 | return STATUS_UNKNOWN_REVISION;
|
---|
256 |
|
---|
257 | return STATUS_SUCCESS;
|
---|
258 | }
|
---|
259 |
|
---|
260 |
|
---|
261 | /**************************************************************************
|
---|
262 | * RtlLengthSecurityDescriptor [NTDLL]
|
---|
263 | */
|
---|
264 | ULONG WINAPI RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor)
|
---|
265 | {
|
---|
266 | ULONG Size;
|
---|
267 |
|
---|
268 | dprintf(("NTDLL: RtlLengthSecurityDescriptor(%08xh)\n",
|
---|
269 | SecurityDescriptor));
|
---|
270 |
|
---|
271 | Size = SECURITY_DESCRIPTOR_MIN_LENGTH;
|
---|
272 | if ( SecurityDescriptor == NULL )
|
---|
273 | return 0;
|
---|
274 |
|
---|
275 | if ( SecurityDescriptor->Owner != NULL )
|
---|
276 | Size += SecurityDescriptor->Owner->SubAuthorityCount;
|
---|
277 | if ( SecurityDescriptor->Group != NULL )
|
---|
278 | Size += SecurityDescriptor->Group->SubAuthorityCount;
|
---|
279 |
|
---|
280 |
|
---|
281 | if ( SecurityDescriptor->Sacl != NULL )
|
---|
282 | Size += SecurityDescriptor->Sacl->AclSize;
|
---|
283 | if ( SecurityDescriptor->Dacl != NULL )
|
---|
284 | Size += SecurityDescriptor->Dacl->AclSize;
|
---|
285 |
|
---|
286 | return Size;
|
---|
287 | }
|
---|
288 |
|
---|
289 | /******************************************************************************
|
---|
290 | * RtlGetDaclSecurityDescriptor [NTDLL]
|
---|
291 | *
|
---|
292 | */
|
---|
293 | NTSTATUS WINAPI RtlGetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
---|
294 | PBOOLEAN lpbDaclPresent,
|
---|
295 | PACL *pDacl,
|
---|
296 | PBOOLEAN lpbDaclDefaulted)
|
---|
297 | {
|
---|
298 | dprintf(("NTDLL: RtlGetDaclSecurityDescriptor(%08xh,%08xh,%08xh,%08xh)\n",
|
---|
299 | pSecurityDescriptor,
|
---|
300 | lpbDaclPresent,
|
---|
301 | pDacl,
|
---|
302 | lpbDaclDefaulted));
|
---|
303 |
|
---|
304 | if (pSecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION)
|
---|
305 | return STATUS_UNKNOWN_REVISION ;
|
---|
306 |
|
---|
307 | if ( (*lpbDaclPresent = (SE_DACL_PRESENT & pSecurityDescriptor->Control) ? 1 : 0) )
|
---|
308 | {
|
---|
309 | if ( SE_SELF_RELATIVE & pSecurityDescriptor->Control)
|
---|
310 | {
|
---|
311 | *pDacl = (PACL) ((LPBYTE)pSecurityDescriptor + (DWORD)pSecurityDescriptor->Dacl);
|
---|
312 | }
|
---|
313 | else
|
---|
314 | {
|
---|
315 | *pDacl = pSecurityDescriptor->Dacl;
|
---|
316 | }
|
---|
317 | }
|
---|
318 |
|
---|
319 | *lpbDaclDefaulted = (( SE_DACL_DEFAULTED & pSecurityDescriptor->Control ) ? 1 : 0);
|
---|
320 |
|
---|
321 | return STATUS_SUCCESS;
|
---|
322 | }
|
---|
323 |
|
---|
324 |
|
---|
325 | /**************************************************************************
|
---|
326 | * RtlSetDaclSecurityDescriptor [NTDLL.483]
|
---|
327 | */
|
---|
328 | NTSTATUS WINAPI RtlSetDaclSecurityDescriptor (PSECURITY_DESCRIPTOR lpsd,
|
---|
329 | BOOLEAN daclpresent,
|
---|
330 | PACL dacl,
|
---|
331 | BOOLEAN dacldefaulted)
|
---|
332 | {
|
---|
333 | dprintf(("NTDLL: RtlSetDaclSecurityDescriptor(%08xh,%08xh,%08xh,%08xh)\n",
|
---|
334 | lpsd,
|
---|
335 | daclpresent,
|
---|
336 | dacl,
|
---|
337 | dacldefaulted));
|
---|
338 |
|
---|
339 | if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
|
---|
340 | return STATUS_UNKNOWN_REVISION;
|
---|
341 | if (lpsd->Control & SE_SELF_RELATIVE)
|
---|
342 | return STATUS_INVALID_SECURITY_DESCR;
|
---|
343 |
|
---|
344 | if (!daclpresent)
|
---|
345 | {
|
---|
346 | lpsd->Control &= ~SE_DACL_PRESENT;
|
---|
347 | return TRUE;
|
---|
348 | }
|
---|
349 |
|
---|
350 | lpsd->Control |= SE_DACL_PRESENT;
|
---|
351 | lpsd->Dacl = dacl;
|
---|
352 |
|
---|
353 | if (dacldefaulted)
|
---|
354 | lpsd->Control |= SE_DACL_DEFAULTED;
|
---|
355 | else
|
---|
356 | lpsd->Control &= ~SE_DACL_DEFAULTED;
|
---|
357 |
|
---|
358 | return STATUS_SUCCESS;
|
---|
359 | }
|
---|
360 |
|
---|
361 |
|
---|
362 | /******************************************************************************
|
---|
363 | * RtlGetSaclSecurityDescriptor [NTDLL]
|
---|
364 | *
|
---|
365 | */
|
---|
366 | NTSTATUS WINAPI RtlGetSaclSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
---|
367 | PBOOLEAN lpbSaclPresent,
|
---|
368 | PACL *pSacl,
|
---|
369 | PBOOLEAN lpbSaclDefaulted)
|
---|
370 | {
|
---|
371 | dprintf(("NTDLL: RtlGetSaclSecurityDescriptor(%08xh,%08xh,%08xh,%08xh)\n",
|
---|
372 | pSecurityDescriptor,
|
---|
373 | lpbSaclPresent,
|
---|
374 | pSacl,
|
---|
375 | lpbSaclDefaulted));
|
---|
376 |
|
---|
377 | if (pSecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION)
|
---|
378 | return STATUS_UNKNOWN_REVISION ;
|
---|
379 |
|
---|
380 | if ( (*lpbSaclPresent = (SE_SACL_PRESENT & pSecurityDescriptor->Control) ? 1 : 0) )
|
---|
381 | {
|
---|
382 | if ( SE_SELF_RELATIVE & pSecurityDescriptor->Control)
|
---|
383 | {
|
---|
384 | *pSacl = (PACL) ((LPBYTE)pSecurityDescriptor + (DWORD)pSecurityDescriptor->Sacl);
|
---|
385 | }
|
---|
386 | else
|
---|
387 | {
|
---|
388 | *pSacl = pSecurityDescriptor->Sacl;
|
---|
389 | }
|
---|
390 | }
|
---|
391 |
|
---|
392 | *lpbSaclDefaulted = (( SE_SACL_DEFAULTED & pSecurityDescriptor->Control ) ? 1 : 0);
|
---|
393 |
|
---|
394 | return STATUS_SUCCESS;
|
---|
395 | }
|
---|
396 |
|
---|
397 |
|
---|
398 | /**************************************************************************
|
---|
399 | * RtlSetSaclSecurityDescriptor [NTDLL.488]
|
---|
400 | */
|
---|
401 | NTSTATUS WINAPI RtlSetSaclSecurityDescriptor (PSECURITY_DESCRIPTOR lpsd,
|
---|
402 | BOOLEAN saclpresent,
|
---|
403 | PACL sacl,
|
---|
404 | BOOLEAN sacldefaulted)
|
---|
405 | {
|
---|
406 | dprintf(("NTDLL: RtlSetSaclSecurityDescriptor(%08xh,%08xh,%08xh,%08xh)\n",
|
---|
407 | lpsd,
|
---|
408 | saclpresent,
|
---|
409 | sacl,
|
---|
410 | sacldefaulted));
|
---|
411 |
|
---|
412 | if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
|
---|
413 | return STATUS_UNKNOWN_REVISION;
|
---|
414 |
|
---|
415 | if (lpsd->Control & SE_SELF_RELATIVE)
|
---|
416 | return STATUS_INVALID_SECURITY_DESCR;
|
---|
417 |
|
---|
418 | if (!saclpresent)
|
---|
419 | {
|
---|
420 | lpsd->Control &= ~SE_SACL_PRESENT;
|
---|
421 | return 0;
|
---|
422 | }
|
---|
423 |
|
---|
424 | lpsd->Control |= SE_SACL_PRESENT;
|
---|
425 | lpsd->Sacl = sacl;
|
---|
426 |
|
---|
427 | if (sacldefaulted)
|
---|
428 | lpsd->Control |= SE_SACL_DEFAULTED;
|
---|
429 | else
|
---|
430 | lpsd->Control &= ~SE_SACL_DEFAULTED;
|
---|
431 |
|
---|
432 | return STATUS_SUCCESS;
|
---|
433 | }
|
---|
434 |
|
---|
435 |
|
---|
436 | /**************************************************************************
|
---|
437 | * RtlGetOwnerSecurityDescriptor [NTDLL.488]
|
---|
438 | */
|
---|
439 | NTSTATUS WINAPI RtlGetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
|
---|
440 | PSID *Owner,
|
---|
441 | PBOOLEAN OwnerDefaulted)
|
---|
442 | {
|
---|
443 | dprintf(("NTDLL: RtlGetOwnerSecurityDescriptor(%08xh,%08xh,%08xh)\n",
|
---|
444 | SecurityDescriptor,
|
---|
445 | Owner,
|
---|
446 | OwnerDefaulted));
|
---|
447 |
|
---|
448 | if ( !SecurityDescriptor || !Owner || !OwnerDefaulted )
|
---|
449 | return STATUS_INVALID_PARAMETER;
|
---|
450 |
|
---|
451 | *Owner = SecurityDescriptor->Owner;
|
---|
452 | if ( *Owner != NULL )
|
---|
453 | {
|
---|
454 | if ( SecurityDescriptor->Control & SE_OWNER_DEFAULTED )
|
---|
455 | *OwnerDefaulted = TRUE;
|
---|
456 | else
|
---|
457 | *OwnerDefaulted = FALSE;
|
---|
458 | }
|
---|
459 |
|
---|
460 | return STATUS_SUCCESS;
|
---|
461 | }
|
---|
462 |
|
---|
463 |
|
---|
464 | /**************************************************************************
|
---|
465 | * RtlSetOwnerSecurityDescriptor [NTDLL.487]
|
---|
466 | */
|
---|
467 | NTSTATUS WINAPI RtlSetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR lpsd,
|
---|
468 | PSID owner,
|
---|
469 | BOOLEAN ownerdefaulted)
|
---|
470 | {
|
---|
471 | dprintf(("NTDLL: RtlSetOwnerSecurityDescriptor(%08x,%08xh,%08xh)\n",
|
---|
472 | lpsd,
|
---|
473 | owner,
|
---|
474 | ownerdefaulted));
|
---|
475 |
|
---|
476 | if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
|
---|
477 | return STATUS_UNKNOWN_REVISION;
|
---|
478 | if (lpsd->Control & SE_SELF_RELATIVE)
|
---|
479 | return STATUS_INVALID_SECURITY_DESCR;
|
---|
480 |
|
---|
481 | lpsd->Owner = owner;
|
---|
482 | if (ownerdefaulted)
|
---|
483 | lpsd->Control |= SE_OWNER_DEFAULTED;
|
---|
484 | else
|
---|
485 | lpsd->Control &= ~SE_OWNER_DEFAULTED;
|
---|
486 |
|
---|
487 | return STATUS_SUCCESS;
|
---|
488 | }
|
---|
489 |
|
---|
490 |
|
---|
491 | /**************************************************************************
|
---|
492 | * RtlSetGroupSecurityDescriptor [NTDLL.485]
|
---|
493 | */
|
---|
494 | NTSTATUS WINAPI RtlSetGroupSecurityDescriptor (PSECURITY_DESCRIPTOR lpsd,
|
---|
495 | PSID group,
|
---|
496 | BOOLEAN groupdefaulted)
|
---|
497 | {
|
---|
498 | dprintf(("NTDLL: RtlSetGroupSecurityDescriptor(%08xh,%08xh,%08xh)\n",
|
---|
499 | lpsd,
|
---|
500 | group,
|
---|
501 | groupdefaulted));
|
---|
502 |
|
---|
503 | if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
|
---|
504 | return STATUS_UNKNOWN_REVISION;
|
---|
505 | if (lpsd->Control & SE_SELF_RELATIVE)
|
---|
506 | return STATUS_INVALID_SECURITY_DESCR;
|
---|
507 |
|
---|
508 | lpsd->Group = group;
|
---|
509 | if (groupdefaulted)
|
---|
510 | lpsd->Control |= SE_GROUP_DEFAULTED;
|
---|
511 | else
|
---|
512 | lpsd->Control &= ~SE_GROUP_DEFAULTED;
|
---|
513 |
|
---|
514 | return STATUS_SUCCESS;
|
---|
515 | }
|
---|
516 |
|
---|
517 |
|
---|
518 | /**************************************************************************
|
---|
519 | * RtlGetGroupSecurityDescriptor [NTDLL]
|
---|
520 | */
|
---|
521 | NTSTATUS WINAPI RtlGetGroupSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
|
---|
522 | PSID *Group,
|
---|
523 | PBOOLEAN GroupDefaulted)
|
---|
524 | {
|
---|
525 | dprintf(("NTDLL: RtlGetGroupSecurityDescriptor(%08xh,%08xh,%08xh)\n",
|
---|
526 | SecurityDescriptor,
|
---|
527 | Group,
|
---|
528 | GroupDefaulted));
|
---|
529 |
|
---|
530 | if ( !SecurityDescriptor || !Group || !GroupDefaulted )
|
---|
531 | return STATUS_INVALID_PARAMETER;
|
---|
532 |
|
---|
533 | *Group = SecurityDescriptor->Group;
|
---|
534 | if ( *Group != NULL )
|
---|
535 | {
|
---|
536 | if ( SecurityDescriptor->Control & SE_GROUP_DEFAULTED )
|
---|
537 | *GroupDefaulted = TRUE;
|
---|
538 | else
|
---|
539 | *GroupDefaulted = FALSE;
|
---|
540 | }
|
---|
541 |
|
---|
542 | return STATUS_SUCCESS;
|
---|
543 | }
|
---|
544 |
|
---|
545 |
|
---|
546 | /*
|
---|
547 | * access control list's
|
---|
548 | */
|
---|
549 |
|
---|
550 | /**************************************************************************
|
---|
551 | * RtlCreateAcl [NTDLL.306]
|
---|
552 | *
|
---|
553 | * NOTES
|
---|
554 | * This should return NTSTATUS
|
---|
555 | */
|
---|
556 | DWORD WINAPI RtlCreateAcl(PACL acl,
|
---|
557 | DWORD size,
|
---|
558 | DWORD rev)
|
---|
559 | {
|
---|
560 | dprintf(("NTDLL: RtlCreateAcl(%08xh,%08xh,%08xh)\n",
|
---|
561 | acl,
|
---|
562 | size,
|
---|
563 | rev));
|
---|
564 |
|
---|
565 | if (rev!=ACL_REVISION)
|
---|
566 | return STATUS_INVALID_PARAMETER;
|
---|
567 | if (size<sizeof(ACL))
|
---|
568 | return STATUS_BUFFER_TOO_SMALL;
|
---|
569 | if (size>0xFFFF)
|
---|
570 | return STATUS_INVALID_PARAMETER;
|
---|
571 |
|
---|
572 | memset(acl,'\0',sizeof(ACL));
|
---|
573 | acl->AclRevision = rev;
|
---|
574 | acl->AclSize = size;
|
---|
575 | acl->AceCount = 0;
|
---|
576 |
|
---|
577 | return 0;
|
---|
578 | }
|
---|
579 |
|
---|
580 |
|
---|
581 | /**************************************************************************
|
---|
582 | * RtlFirstFreeAce [NTDLL.370]
|
---|
583 | * looks for the AceCount+1 ACE, and if it is still within the alloced
|
---|
584 | * ACL, return a pointer to it
|
---|
585 | */
|
---|
586 | BOOLEAN WINAPI RtlFirstFreeAce(PACL acl,
|
---|
587 | PACE_HEADER *x)
|
---|
588 | {
|
---|
589 | PACE_HEADER ace;
|
---|
590 | int i;
|
---|
591 |
|
---|
592 | dprintf(("NTDLL: RtlFirstFreeAct(%08xh,%08xh)\n",
|
---|
593 | acl,
|
---|
594 | x));
|
---|
595 |
|
---|
596 | *x = 0;
|
---|
597 | ace = (PACE_HEADER)(acl+1);
|
---|
598 | for (i=0;
|
---|
599 | i<acl->AceCount;
|
---|
600 | i++)
|
---|
601 | {
|
---|
602 | if ((DWORD)ace>=(((DWORD)acl)+acl->AclSize))
|
---|
603 | return 0;
|
---|
604 |
|
---|
605 | ace = (PACE_HEADER)(((BYTE*)ace)+ace->AceSize);
|
---|
606 | }
|
---|
607 |
|
---|
608 | if ((DWORD)ace>=(((DWORD)acl)+acl->AclSize))
|
---|
609 | return 0;
|
---|
610 |
|
---|
611 | *x = ace;
|
---|
612 | return 1;
|
---|
613 | }
|
---|
614 |
|
---|
615 |
|
---|
616 | /**************************************************************************
|
---|
617 | * RtlAddAce [NTDLL.260]
|
---|
618 | */
|
---|
619 | NTSTATUS WINAPI RtlAddAce(PACL acl,
|
---|
620 | DWORD rev,
|
---|
621 | DWORD xnrofaces,
|
---|
622 | PACE_HEADER acestart,
|
---|
623 | DWORD acelen)
|
---|
624 | {
|
---|
625 | PACE_HEADER ace,targetace;
|
---|
626 | int nrofaces;
|
---|
627 |
|
---|
628 | dprintf(("NTDLL: RtlAddAce(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
|
---|
629 | acl,
|
---|
630 | rev,
|
---|
631 | xnrofaces,
|
---|
632 | acestart,
|
---|
633 | acelen));
|
---|
634 |
|
---|
635 | if (acl->AclRevision != ACL_REVISION)
|
---|
636 | return STATUS_INVALID_PARAMETER;
|
---|
637 |
|
---|
638 | if (!RtlFirstFreeAce(acl,&targetace))
|
---|
639 | return STATUS_INVALID_PARAMETER;
|
---|
640 |
|
---|
641 | nrofaces=0;
|
---|
642 | ace=acestart;
|
---|
643 |
|
---|
644 | while (((DWORD)ace-(DWORD)acestart)<acelen)
|
---|
645 | {
|
---|
646 | nrofaces++;
|
---|
647 | ace = (PACE_HEADER)(((BYTE*)ace)+ace->AceSize);
|
---|
648 | }
|
---|
649 |
|
---|
650 | if ((DWORD)targetace+acelen>(DWORD)acl+acl->AclSize) /* too much aces */
|
---|
651 | return STATUS_INVALID_PARAMETER;
|
---|
652 |
|
---|
653 | memcpy((LPBYTE)targetace,acestart,acelen);
|
---|
654 | acl->AceCount+=nrofaces;
|
---|
655 |
|
---|
656 | return STATUS_SUCCESS;
|
---|
657 | }
|
---|
658 |
|
---|
659 |
|
---|
660 | /******************************************************************************
|
---|
661 | * RtlAddAccessAllowedAce [NTDLL]
|
---|
662 | */
|
---|
663 | DWORD WINAPI RtlAddAccessAllowedAce(DWORD x1,
|
---|
664 | DWORD x2,
|
---|
665 | DWORD x3,
|
---|
666 | DWORD x4)
|
---|
667 | {
|
---|
668 | dprintf(("NTDLL: RtlAddAccessAllowedAce(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
---|
669 | x1,
|
---|
670 | x2,
|
---|
671 | x3,
|
---|
672 | x4));
|
---|
673 |
|
---|
674 | return 0;
|
---|
675 | }
|
---|
676 |
|
---|
677 |
|
---|
678 | /******************************************************************************
|
---|
679 | * RtlGetAce [NTDLL]
|
---|
680 | */
|
---|
681 | DWORD WINAPI RtlGetAce(PACL pAcl,
|
---|
682 | DWORD dwAceIndex,
|
---|
683 | LPVOID *pAce )
|
---|
684 | {
|
---|
685 | dprintf(("NTDLL: RtlGetAce(%08x,%08x,%08x) not implemented.\n",
|
---|
686 | pAcl,
|
---|
687 | dwAceIndex,
|
---|
688 | pAce));
|
---|
689 |
|
---|
690 | return 0;
|
---|
691 | }
|
---|
692 |
|
---|
693 |
|
---|
694 | /*
|
---|
695 | * misc
|
---|
696 | */
|
---|
697 |
|
---|
698 | /******************************************************************************
|
---|
699 | * RtlAdjustPrivilege [NTDLL]
|
---|
700 | */
|
---|
701 | DWORD WINAPI RtlAdjustPrivilege(DWORD x1,
|
---|
702 | DWORD x2,
|
---|
703 | DWORD x3,
|
---|
704 | DWORD x4)
|
---|
705 | {
|
---|
706 | dprintf(("NTDLL: RtlAdjustPrivilege(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
---|
707 | x1,
|
---|
708 | x2,
|
---|
709 | x3,
|
---|
710 | x4));
|
---|
711 |
|
---|
712 | return 0;
|
---|
713 | }
|
---|
714 |
|
---|