source: trunk/src/NTDLL/sec.c@ 9684

Last change on this file since 9684 was 9684, checked in by sandervl, 23 years ago

PF: Changes for building dll with GCC

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