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