source: trunk/src/NTDLL/sec.cpp@ 7983

Last change on this file since 7983 was 7983, checked in by sandervl, 24 years ago

update

File size: 23.3 KB
Line 
1/* $Id: sec.cpp,v 1.9 2002-02-21 22:52:43 sandervl 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 <odin.h>
16#include <odinwrap.h>
17#include <os2sel.h>
18
19#include <stdlib.h>
20#include <string.h>
21#include <time.h>
22#include <ctype.h>
23#include <math.h>
24
25#include <os2win.h>
26#include "ntdll.h"
27
28#include <debugtools.h>
29
30ODINDEBUGCHANNEL(NTDLL-SEC)
31
32/*
33 * SID FUNCTIONS
34 */
35
36/******************************************************************************
37 * RtlAllocateAndInitializeSid [NTDLL.265]
38 *
39 */
40BOOLEAN WINAPI RtlAllocateAndInitializeSid ( PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
41 BYTE nSubAuthorityCount,
42 DWORD nSubAuthority0,
43 DWORD nSubAuthority1,
44 DWORD nSubAuthority2,
45 DWORD nSubAuthority3,
46 DWORD nSubAuthority4,
47 DWORD nSubAuthority5,
48 DWORD nSubAuthority6,
49 DWORD nSubAuthority7,
50 PSID *pSid)
51{
52 dprintf(("NTDLL: RtlAllocateAndInitializeSid(%08xh,%08xh,%08xh,"
53 "%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)",
54 pIdentifierAuthority,
55 nSubAuthorityCount,
56 nSubAuthority0,
57 nSubAuthority1,
58 nSubAuthority2,
59 nSubAuthority3,
60 nSubAuthority4,
61 nSubAuthority5,
62 nSubAuthority6,
63 nSubAuthority7,
64 pSid));
65
66 *pSid = (PSID)Heap_Alloc(sizeof(SID)+nSubAuthorityCount*sizeof(DWORD));
67 if(*pSid == NULL) {
68 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
69 return FALSE;
70 }
71 (*pSid)->Revision = SID_REVISION;
72 (*pSid)->SubAuthorityCount = nSubAuthorityCount;
73
74 if (nSubAuthorityCount > 0)
75 (*pSid)->SubAuthority[0] = nSubAuthority0;
76 if (nSubAuthorityCount > 1)
77 (*pSid)->SubAuthority[1] = nSubAuthority1;
78 if (nSubAuthorityCount > 2)
79 (*pSid)->SubAuthority[2] = nSubAuthority2;
80 if (nSubAuthorityCount > 3)
81 (*pSid)->SubAuthority[3] = nSubAuthority3;
82 if (nSubAuthorityCount > 4)
83 (*pSid)->SubAuthority[4] = nSubAuthority4;
84 if (nSubAuthorityCount > 5)
85 (*pSid)->SubAuthority[5] = nSubAuthority5;
86 if (nSubAuthorityCount > 6)
87 (*pSid)->SubAuthority[6] = nSubAuthority6;
88 if (nSubAuthorityCount > 7)
89 (*pSid)->SubAuthority[7] = nSubAuthority7;
90
91 if(pIdentifierAuthority)
92 memcpy((PVOID)&(*pSid)->IdentifierAuthority, (PVOID)pIdentifierAuthority, sizeof(SID_IDENTIFIER_AUTHORITY));
93 return TRUE;
94}
95
96
97/******************************************************************************
98 * RtlEqualSid [NTDLL.352]
99 *
100 */
101BOOL WINAPI RtlEqualSid(PSID pSid1, PSID pSid2)
102{
103 dprintf(("NTDLL: RtlEqualSid(%08x, %08x)",
104 pSid1,
105 pSid2));
106
107 if (!RtlValidSid(pSid1) || !RtlValidSid(pSid2))
108 return FALSE;
109
110 if (*RtlSubAuthorityCountSid(pSid1) != *RtlSubAuthorityCountSid(pSid2))
111 return FALSE;
112
113 if (memcmp(pSid1, pSid2, RtlLengthSid(pSid1)) != 0)
114 return FALSE;
115
116 return TRUE;
117}
118
119
120/******************************************************************************
121 * RtlEqualPrefixSid [NTDLL.351]
122 */
123BOOL WINAPI RtlEqualPrefixSid (PSID pSid1, PSID pSid2)
124{
125 if (!RtlValidSid(pSid1) || !RtlValidSid(pSid2))
126 return FALSE;
127
128 if (*RtlSubAuthorityCountSid(pSid1) != *RtlSubAuthorityCountSid(pSid2))
129 return FALSE;
130
131 if (memcmp(pSid1, pSid2, RtlLengthRequiredSid(pSid1->SubAuthorityCount - 1)) != 0)
132 return FALSE;
133
134 return TRUE;
135}
136
137/******************************************************************************
138 * RtlFreeSid [NTDLL.376]
139 */
140VOID* WINAPI RtlFreeSid(PSID pSid)
141{
142 dprintf(("NTDLL: RtlFreeSid(%08xh)", pSid));
143
144 Heap_Free(pSid);
145 return NULL;
146}
147
148
149/**************************************************************************
150 * RtlLengthRequiredSid [NTDLL.427]
151 */
152DWORD WINAPI RtlLengthRequiredSid(DWORD nrofsubauths)
153{
154 dprintf (("NTDLL: RtlLengthRequiredSid(%08xh)\n",
155 nrofsubauths));
156
157 return sizeof(DWORD)*nrofsubauths+sizeof(SID);
158}
159
160
161/**************************************************************************
162 * RtlLengthSid [NTDLL.429]
163 */
164DWORD WINAPI RtlLengthSid(PSID sid)
165{
166 dprintf(("NTDLL: RtlLengthSid(%08xh)\n",
167 sid));
168
169 if (!sid)
170 return FALSE;
171
172 return sizeof(DWORD)*sid->SubAuthorityCount+sizeof(SID);
173}
174
175
176/**************************************************************************
177 * RtlInitializeSid [NTDLL.410]
178 */
179ODINFUNCTION3(DWORD, RtlInitializeSid,
180 PSID, psid,
181 PSID_IDENTIFIER_AUTHORITY, psidauth,
182 DWORD, c)
183{
184 BYTE a = c & 0xff;
185
186 if (a>=SID_MAX_SUB_AUTHORITIES)
187 return a;
188
189 psid->SubAuthorityCount = a;
190 psid->Revision = SID_REVISION;
191 memcpy(&(psid->IdentifierAuthority),
192 psidauth,
193 sizeof(SID_IDENTIFIER_AUTHORITY));
194
195 return STATUS_SUCCESS;
196}
197
198
199/******************************************************************************
200 * RtlIdentifierAuthoritySid [NTDLL.395]
201 *
202 * PARAMS
203 * pSid []
204 */
205PSID_IDENTIFIER_AUTHORITY WINAPI RtlIdentifierAuthoritySid( PSID pSid )
206{
207 return &pSid->IdentifierAuthority;
208}
209
210/**************************************************************************
211 * RtlSubAuthoritySid [NTDLL.497]
212 */
213ODINFUNCTION2(LPDWORD, RtlSubAuthoritySid,
214 PSID, psid,
215 DWORD, nr)
216{
217 return &(psid->SubAuthority[nr]);
218}
219
220
221/**************************************************************************
222 * RtlSubAuthorityCountSid [NTDLL.496]
223 */
224
225LPBYTE WINAPI RtlSubAuthorityCountSid(PSID psid)
226{
227 dprintf2(("NTDLL: RtlSubAUthorityCountSid(%08xh)\n",
228 psid));
229
230 return ((LPBYTE)psid)+1;
231}
232
233
234/**************************************************************************
235 * RtlCopySid [NTDLL.302]
236 */
237DWORD WINAPI RtlCopySid(DWORD nDestinationSidLength,
238 PSID pDestinationSid,
239 PSID pSourceSid)
240{
241 dprintf(("NTDLL: RtlCopySid(%08xh,%08xh,%08xh)\n",
242 nDestinationSidLength,
243 pDestinationSid,
244 pSourceSid));
245
246 if (!RtlValidSid(pSourceSid))
247 return STATUS_INVALID_PARAMETER;
248
249 if (nDestinationSidLength < RtlLengthSid(pSourceSid))
250 return STATUS_BUFFER_TOO_SMALL;
251
252 memcpy(pDestinationSid, pSourceSid, RtlLengthSid(pSourceSid));
253
254 return STATUS_SUCCESS;
255}
256
257
258/******************************************************************************
259 * RtlValidSid [NTDLL.523]
260 *
261 * PARAMS
262 * pSid []
263 */
264BOOL WINAPI RtlValidSid( PSID pSid )
265{
266 if (IsBadReadPtr(pSid, 4))
267 {
268 return FALSE;
269 }
270
271 if (pSid->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES)
272 return FALSE;
273
274 if (!pSid || pSid->Revision != SID_REVISION)
275 return FALSE;
276
277 return TRUE;
278}
279
280/*
281 * security descriptor functions
282 */
283
284/**************************************************************************
285 * RtlCreateSecurityDescriptor [NTDLL.313]
286 *
287 * RETURNS:
288 * 0 success,
289 * STATUS_INVALID_OWNER, STATUS_PRIVILEGE_NOT_HELD, STATUS_NO_INHERITANCE,
290 * STATUS_NO_MEMORY
291 */
292NTSTATUS WINAPI RtlCreateSecurityDescriptor(PSECURITY_DESCRIPTOR lpsd,
293 DWORD rev)
294{
295 dprintf(("NTDLL: RtlCreateSecurityDescriptor(%08xh,%08xh)\n",
296 lpsd,
297 rev));
298
299 if (rev!=SECURITY_DESCRIPTOR_REVISION)
300 return STATUS_UNKNOWN_REVISION;
301
302 memset(lpsd,
303 '\0',
304 sizeof(*lpsd));
305
306 lpsd->Revision = SECURITY_DESCRIPTOR_REVISION;
307
308 return STATUS_SUCCESS;
309}
310
311
312/**************************************************************************
313 * RtlValidSecurityDescriptor [NTDLL.313]
314 *
315 */
316NTSTATUS WINAPI RtlValidSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor)
317{
318 dprintf(("NTDLL: RtlValidSecurityDescriptor(%08xh)\n",
319 SecurityDescriptor));
320
321 if ( ! SecurityDescriptor )
322 return STATUS_INVALID_SECURITY_DESCR;
323
324 if ( SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION )
325 return STATUS_UNKNOWN_REVISION;
326
327 return STATUS_SUCCESS;
328}
329
330
331/**************************************************************************
332 * RtlLengthSecurityDescriptor [NTDLL]
333 */
334ULONG WINAPI RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor)
335{
336 ULONG Size;
337
338 dprintf(("NTDLL: RtlLengthSecurityDescriptor(%08xh)\n",
339 SecurityDescriptor));
340
341 Size = SECURITY_DESCRIPTOR_MIN_LENGTH;
342 if ( SecurityDescriptor == NULL )
343 return 0;
344
345 if ( SecurityDescriptor->Owner != NULL )
346 Size += SecurityDescriptor->Owner->SubAuthorityCount;
347 if ( SecurityDescriptor->Group != NULL )
348 Size += SecurityDescriptor->Group->SubAuthorityCount;
349
350
351 if ( SecurityDescriptor->Sacl != NULL )
352 Size += SecurityDescriptor->Sacl->AclSize;
353 if ( SecurityDescriptor->Dacl != NULL )
354 Size += SecurityDescriptor->Dacl->AclSize;
355
356 return Size;
357}
358
359/******************************************************************************
360 * RtlGetDaclSecurityDescriptor [NTDLL]
361 *
362 */
363NTSTATUS WINAPI RtlGetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor,
364 PBOOLEAN lpbDaclPresent,
365 PACL *pDacl,
366 PBOOLEAN lpbDaclDefaulted)
367{
368 dprintf(("NTDLL: RtlGetDaclSecurityDescriptor(%08xh,%08xh,%08xh,%08xh)\n",
369 pSecurityDescriptor,
370 lpbDaclPresent,
371 pDacl,
372 lpbDaclDefaulted));
373
374 if (pSecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION)
375 return STATUS_UNKNOWN_REVISION ;
376
377 *lpbDaclPresent = (SE_DACL_PRESENT & pSecurityDescriptor->Control);
378 if (*lpbDaclPresent ? 1 : 0)
379 {
380 if ( SE_SELF_RELATIVE & pSecurityDescriptor->Control)
381 {
382 *pDacl = (PACL) ((LPBYTE)pSecurityDescriptor + (DWORD)pSecurityDescriptor->Dacl);
383 }
384 else
385 {
386 *pDacl = pSecurityDescriptor->Dacl;
387 }
388 }
389
390 *lpbDaclDefaulted = (( SE_DACL_DEFAULTED & pSecurityDescriptor->Control ) ? 1 : 0);
391
392 return STATUS_SUCCESS;
393}
394
395
396/**************************************************************************
397 * RtlSetDaclSecurityDescriptor [NTDLL.483]
398 */
399NTSTATUS WINAPI RtlSetDaclSecurityDescriptor (PSECURITY_DESCRIPTOR lpsd,
400 BOOLEAN daclpresent,
401 PACL dacl,
402 BOOLEAN dacldefaulted)
403{
404 dprintf(("NTDLL: RtlSetDaclSecurityDescriptor(%08xh,%08xh,%08xh,%08xh)\n",
405 lpsd,
406 daclpresent,
407 dacl,
408 dacldefaulted));
409
410 if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
411 return STATUS_UNKNOWN_REVISION;
412 if (lpsd->Control & SE_SELF_RELATIVE)
413 return STATUS_INVALID_SECURITY_DESCR;
414
415 if (!daclpresent)
416 {
417 lpsd->Control &= ~SE_DACL_PRESENT;
418 return TRUE;
419 }
420
421 lpsd->Control |= SE_DACL_PRESENT;
422 lpsd->Dacl = dacl;
423
424 if (dacldefaulted)
425 lpsd->Control |= SE_DACL_DEFAULTED;
426 else
427 lpsd->Control &= ~SE_DACL_DEFAULTED;
428
429 return STATUS_SUCCESS;
430}
431
432
433/******************************************************************************
434 * RtlGetSaclSecurityDescriptor [NTDLL]
435 *
436 */
437NTSTATUS WINAPI RtlGetSaclSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor,
438 PBOOLEAN lpbSaclPresent,
439 PACL *pSacl,
440 PBOOLEAN lpbSaclDefaulted)
441{
442 dprintf(("NTDLL: RtlGetSaclSecurityDescriptor(%08xh,%08xh,%08xh,%08xh)\n",
443 pSecurityDescriptor,
444 lpbSaclPresent,
445 pSacl,
446 lpbSaclDefaulted));
447
448 if (pSecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION)
449 return STATUS_UNKNOWN_REVISION ;
450
451 *lpbSaclPresent = (SE_SACL_PRESENT & pSecurityDescriptor->Control);
452 if (*lpbSaclPresent ? 1 : 0)
453 {
454 if ( SE_SELF_RELATIVE & pSecurityDescriptor->Control)
455 {
456 *pSacl = (PACL) ((LPBYTE)pSecurityDescriptor + (DWORD)pSecurityDescriptor->Sacl);
457 }
458 else
459 {
460 *pSacl = pSecurityDescriptor->Sacl;
461 }
462 }
463
464 *lpbSaclDefaulted = (( SE_SACL_DEFAULTED & pSecurityDescriptor->Control ) ? 1 : 0);
465
466 return STATUS_SUCCESS;
467}
468
469
470/**************************************************************************
471 * RtlSetSaclSecurityDescriptor [NTDLL.488]
472 */
473NTSTATUS WINAPI RtlSetSaclSecurityDescriptor (PSECURITY_DESCRIPTOR lpsd,
474 BOOLEAN saclpresent,
475 PACL sacl,
476 BOOLEAN sacldefaulted)
477{
478 dprintf(("NTDLL: RtlSetSaclSecurityDescriptor(%08xh,%08xh,%08xh,%08xh)\n",
479 lpsd,
480 saclpresent,
481 sacl,
482 sacldefaulted));
483
484 if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
485 return STATUS_UNKNOWN_REVISION;
486
487 if (lpsd->Control & SE_SELF_RELATIVE)
488 return STATUS_INVALID_SECURITY_DESCR;
489
490 if (!saclpresent)
491 {
492 lpsd->Control &= ~SE_SACL_PRESENT;
493 return 0;
494 }
495
496 lpsd->Control |= SE_SACL_PRESENT;
497 lpsd->Sacl = sacl;
498
499 if (sacldefaulted)
500 lpsd->Control |= SE_SACL_DEFAULTED;
501 else
502 lpsd->Control &= ~SE_SACL_DEFAULTED;
503
504 return STATUS_SUCCESS;
505}
506
507
508/**************************************************************************
509 * RtlGetOwnerSecurityDescriptor [NTDLL.488]
510 */
511NTSTATUS WINAPI RtlGetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
512 PSID *Owner,
513 PBOOLEAN OwnerDefaulted)
514{
515 dprintf(("NTDLL: RtlGetOwnerSecurityDescriptor(%08xh,%08xh,%08xh)\n",
516 SecurityDescriptor,
517 Owner,
518 OwnerDefaulted));
519
520 if ( !SecurityDescriptor || !Owner || !OwnerDefaulted )
521 return STATUS_INVALID_PARAMETER;
522
523 *Owner = SecurityDescriptor->Owner;
524 if ( *Owner != NULL )
525 {
526 if ( SecurityDescriptor->Control & SE_OWNER_DEFAULTED )
527 *OwnerDefaulted = TRUE;
528 else
529 *OwnerDefaulted = FALSE;
530 }
531
532 return STATUS_SUCCESS;
533}
534
535
536/**************************************************************************
537 * RtlSetOwnerSecurityDescriptor [NTDLL.487]
538 */
539NTSTATUS WINAPI RtlSetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR lpsd,
540 PSID owner,
541 BOOLEAN ownerdefaulted)
542{
543 dprintf(("NTDLL: RtlSetOwnerSecurityDescriptor(%08x,%08xh,%08xh)\n",
544 lpsd,
545 owner,
546 ownerdefaulted));
547
548 if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
549 return STATUS_UNKNOWN_REVISION;
550 if (lpsd->Control & SE_SELF_RELATIVE)
551 return STATUS_INVALID_SECURITY_DESCR;
552
553 lpsd->Owner = owner;
554 if (ownerdefaulted)
555 lpsd->Control |= SE_OWNER_DEFAULTED;
556 else
557 lpsd->Control &= ~SE_OWNER_DEFAULTED;
558
559 return STATUS_SUCCESS;
560}
561
562
563/**************************************************************************
564 * RtlSetGroupSecurityDescriptor [NTDLL.485]
565 */
566NTSTATUS WINAPI RtlSetGroupSecurityDescriptor (PSECURITY_DESCRIPTOR lpsd,
567 PSID group,
568 BOOLEAN groupdefaulted)
569{
570 dprintf(("NTDLL: RtlSetGroupSecurityDescriptor(%08xh,%08xh,%08xh)\n",
571 lpsd,
572 group,
573 groupdefaulted));
574
575 if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
576 return STATUS_UNKNOWN_REVISION;
577 if (lpsd->Control & SE_SELF_RELATIVE)
578 return STATUS_INVALID_SECURITY_DESCR;
579
580 lpsd->Group = group;
581 if (groupdefaulted)
582 lpsd->Control |= SE_GROUP_DEFAULTED;
583 else
584 lpsd->Control &= ~SE_GROUP_DEFAULTED;
585
586 return STATUS_SUCCESS;
587}
588
589
590/**************************************************************************
591 * RtlGetGroupSecurityDescriptor [NTDLL]
592 */
593NTSTATUS WINAPI RtlGetGroupSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
594 PSID *Group,
595 PBOOLEAN GroupDefaulted)
596{
597 dprintf(("NTDLL: RtlGetGroupSecurityDescriptor(%08xh,%08xh,%08xh)\n",
598 SecurityDescriptor,
599 Group,
600 GroupDefaulted));
601
602 if ( !SecurityDescriptor || !Group || !GroupDefaulted )
603 return STATUS_INVALID_PARAMETER;
604
605 *Group = SecurityDescriptor->Group;
606 if ( *Group != NULL )
607 {
608 if ( SecurityDescriptor->Control & SE_GROUP_DEFAULTED )
609 *GroupDefaulted = TRUE;
610 else
611 *GroupDefaulted = FALSE;
612 }
613
614 return STATUS_SUCCESS;
615}
616
617
618/*
619 * access control list's
620 */
621
622/**************************************************************************
623 * RtlCreateAcl [NTDLL.306]
624 *
625 * NOTES
626 * This should return NTSTATUS
627 */
628DWORD WINAPI RtlCreateAcl(PACL acl,
629 DWORD size,
630 DWORD rev)
631{
632 dprintf(("NTDLL: RtlCreateAcl(%08xh,%08xh,%08xh)\n",
633 acl,
634 size,
635 rev));
636
637 if (rev!=ACL_REVISION)
638 return STATUS_INVALID_PARAMETER;
639 if (size<sizeof(ACL))
640 return STATUS_BUFFER_TOO_SMALL;
641 if (size>0xFFFF)
642 return STATUS_INVALID_PARAMETER;
643
644 memset(acl,'\0',sizeof(ACL));
645 acl->AclRevision = rev;
646 acl->AclSize = size;
647 acl->AceCount = 0;
648
649 return 0;
650}
651
652
653/**************************************************************************
654 * RtlFirstFreeAce [NTDLL.370]
655 * looks for the AceCount+1 ACE, and if it is still within the alloced
656 * ACL, return a pointer to it
657 */
658BOOLEAN WINAPI RtlFirstFreeAce(PACL acl,
659 PACE_HEADER *x)
660{
661 PACE_HEADER ace;
662 int i;
663
664 dprintf(("NTDLL: RtlFirstFreeAct(%08xh,%08xh)\n",
665 acl,
666 x));
667
668 *x = 0;
669 ace = (PACE_HEADER)(acl+1);
670 for (i=0;
671 i<acl->AceCount;
672 i++)
673 {
674 if ((DWORD)ace>=(((DWORD)acl)+acl->AclSize))
675 return 0;
676
677 ace = (PACE_HEADER)(((BYTE*)ace)+ace->AceSize);
678 }
679
680 if ((DWORD)ace>=(((DWORD)acl)+acl->AclSize))
681 return 0;
682
683 *x = ace;
684 return 1;
685}
686
687
688/**************************************************************************
689 * RtlAddAce [NTDLL.260]
690 */
691NTSTATUS WINAPI RtlAddAce(PACL acl,
692 DWORD rev,
693 DWORD xnrofaces,
694 PACE_HEADER acestart,
695 DWORD acelen)
696{
697 PACE_HEADER ace,targetace;
698 int nrofaces;
699
700 dprintf(("NTDLL: RtlAddAce(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
701 acl,
702 rev,
703 xnrofaces,
704 acestart,
705 acelen));
706
707 if (acl->AclRevision != ACL_REVISION)
708 return STATUS_INVALID_PARAMETER;
709
710 if (!RtlFirstFreeAce(acl,&targetace))
711 return STATUS_INVALID_PARAMETER;
712
713 nrofaces=0;
714 ace=acestart;
715
716 while (((DWORD)ace-(DWORD)acestart)<acelen)
717 {
718 nrofaces++;
719 ace = (PACE_HEADER)(((BYTE*)ace)+ace->AceSize);
720 }
721
722 if ((DWORD)targetace+acelen>(DWORD)acl+acl->AclSize) /* too much aces */
723 return STATUS_INVALID_PARAMETER;
724
725 memcpy((LPBYTE)targetace,acestart,acelen);
726 acl->AceCount+=nrofaces;
727
728 return STATUS_SUCCESS;
729}
730
731
732/******************************************************************************
733 * RtlAddAccessAllowedAce [NTDLL]
734 */
735NTSTATUS WINAPI RtlAddAccessAllowedAce(IN OUT PACL pAcl, IN DWORD dwAceRevision,
736 IN DWORD AccessMask, IN PSID pSid)
737{
738 dprintf(("NTDLL: RtlAddAccessAllowedAce(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
739 pAcl,
740 dwAceRevision,
741 AccessMask,
742 pSid));
743
744 return 0;
745}
746
747
748/******************************************************************************
749 * RtlGetAce [NTDLL]
750 */
751NTSTATUS WINAPI RtlGetAce(PACL pAcl,
752 DWORD dwAceIndex,
753 LPVOID *pAce )
754{
755 PACE_HEADER ace;
756 int i;
757
758 dprintf(("NTDLL: RtlGetAce(%08x,%08x,%08x) test implementation",
759 pAcl,
760 dwAceIndex,
761 pAce));
762
763
764 *pAce = 0;
765 if(dwAceIndex > pAcl->AceCount) {
766 dprintf(("index out of range"));
767 return STATUS_INVALID_PARAMETER;
768 }
769 ace = (PACE_HEADER)(pAcl+1);
770
771 for (i=0;
772 i<dwAceIndex;
773 i++)
774 {
775 if ((DWORD)ace>=(((DWORD)pAcl)+pAcl->AclSize))
776 return STATUS_BUFFER_OVERFLOW;
777
778 ace = (PACE_HEADER)(((BYTE*)ace)+ace->AceSize);
779 }
780
781 if ((DWORD)ace>=(((DWORD)pAcl)+pAcl->AclSize))
782 return STATUS_BUFFER_OVERFLOW;
783
784 *pAce = ace;
785 return STATUS_SUCCESS;
786}
787
788
789/*
790 * misc
791 */
792
793/******************************************************************************
794 * RtlAdjustPrivilege [NTDLL]
795 */
796DWORD WINAPI RtlAdjustPrivilege(DWORD x1,
797 DWORD x2,
798 DWORD x3,
799 DWORD x4)
800{
801 dprintf(("NTDLL: RtlAdjustPrivilege(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
802 x1,
803 x2,
804 x3,
805 x4));
806
807 return 0;
808}
809
810
811/******************************************************************************
812 * RtlImpersonateSelf [NTDLL.@]
813 */
814BOOL WINAPI
815RtlImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
816{
817 FIXME("(%08x), stub\n", ImpersonationLevel);
818 return TRUE;
819}
820
821/******************************************************************************
822 * NtAccessCheck [NTDLL.@]
823 */
824NTSTATUS WINAPI
825NtAccessCheck(
826 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
827 IN HANDLE ClientToken,
828 IN ACCESS_MASK DesiredAccess,
829 IN PGENERIC_MAPPING GenericMapping,
830 OUT PPRIVILEGE_SET PrivilegeSet,
831 OUT PULONG ReturnLength,
832 OUT PULONG GrantedAccess,
833 OUT PBOOLEAN AccessStatus)
834{
835 FIXME("(%p, %04x, %08lx, %p, %p, %p, %p, %p), stub\n",
836 SecurityDescriptor, ClientToken, DesiredAccess, GenericMapping,
837 PrivilegeSet, ReturnLength, GrantedAccess, AccessStatus);
838 *AccessStatus = TRUE;
839 return STATUS_SUCCESS;
840}
841
842/******************************************************************************
843 * NtSetSecurityObject [NTDLL.@]
844 */
845NTSTATUS WINAPI
846NtSetSecurityObject(
847 IN HANDLE Handle,
848 IN SECURITY_INFORMATION SecurityInformation,
849 IN PSECURITY_DESCRIPTOR SecurityDescriptor)
850{
851 FIXME("0x%08x 0x%08lx %p\n", Handle, SecurityInformation, SecurityDescriptor);
852 return STATUS_SUCCESS;
853}
854
855/******************************************************************************
856 * RtlGetControlSecurityDescriptor (NTDLL.@)
857 */
858
859NTSTATUS WINAPI RtlGetControlSecurityDescriptor(
860 PSECURITY_DESCRIPTOR pSecurityDescriptor,
861 PSECURITY_DESCRIPTOR_CONTROL pControl,
862 LPDWORD lpdwRevision)
863{
864 FIXME("(%p,%p,%p),stub!\n",pSecurityDescriptor,pControl,lpdwRevision);
865 return STATUS_SUCCESS;
866}
867
868/**************************************************************************
869 * RtlMakeSelfRelativeSD [NTDLL.@]
870 */
871NTSTATUS WINAPI RtlMakeSelfRelativeSD(
872 IN PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
873 IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
874 IN OUT LPDWORD lpdwBufferLength)
875{
876 FIXME("(%p,%p,%p(%lu))\n", pAbsoluteSecurityDescriptor,
877 pSelfRelativeSecurityDescriptor, lpdwBufferLength,*lpdwBufferLength);
878 return STATUS_SUCCESS;
879}
Note: See TracBrowser for help on using the repository browser.