MSVC compatibility fixes.
[wine/gsoc_dplay.git] / dlls / ntdll / sec.c
blob614768a89354d7b99afbfc530d8203726d2eb6a3
1 /*
2 * Security functions
4 * Copyright 1996-1998 Marcus Meissner
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
23 #include <stdlib.h>
24 #include <string.h>
25 #include <time.h>
26 #include <ctype.h>
27 #include <math.h>
28 #ifdef HAVE_PWD_H
29 # include <pwd.h>
30 #endif
31 #ifdef HAVE_UNISTD_H
32 # include <unistd.h>
33 #endif
35 #include "windef.h"
36 #include "winbase.h"
37 #include "wine/exception.h"
38 #include "file.h"
39 #include "winnls.h"
40 #include "wine/debug.h"
41 #include "winerror.h"
42 #include "stackframe.h"
44 #include "ntddk.h"
45 #include "winreg.h"
46 #include "ntdll_misc.h"
47 #include "msvcrt/excpt.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
51 #define NT_SUCCESS(status) (status == STATUS_SUCCESS)
53 /* filter for page-fault exceptions */
54 static WINE_EXCEPTION_FILTER(page_fault)
56 if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
57 return EXCEPTION_EXECUTE_HANDLER;
58 return EXCEPTION_CONTINUE_SEARCH;
62 * SID FUNCTIONS
65 /******************************************************************************
66 * RtlAllocateAndInitializeSid [NTDLL.@]
69 BOOLEAN WINAPI RtlAllocateAndInitializeSid (
70 PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
71 BYTE nSubAuthorityCount,
72 DWORD nSubAuthority0, DWORD nSubAuthority1,
73 DWORD nSubAuthority2, DWORD nSubAuthority3,
74 DWORD nSubAuthority4, DWORD nSubAuthority5,
75 DWORD nSubAuthority6, DWORD nSubAuthority7,
76 PSID *pSid )
78 TRACE("(%p, 0x%04x,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,%p)\n",
79 pIdentifierAuthority,nSubAuthorityCount,
80 nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3,
81 nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7, pSid);
83 if (!(*pSid = RtlAllocateHeap( GetProcessHeap(), 0, RtlLengthRequiredSid(nSubAuthorityCount))))
84 return FALSE;
86 (*pSid)->Revision = SID_REVISION;
88 if (pIdentifierAuthority)
89 memcpy(&(*pSid)->IdentifierAuthority, pIdentifierAuthority, sizeof (SID_IDENTIFIER_AUTHORITY));
90 *RtlSubAuthorityCountSid(*pSid) = nSubAuthorityCount;
92 if (nSubAuthorityCount > 0)
93 *RtlSubAuthoritySid(*pSid, 0) = nSubAuthority0;
94 if (nSubAuthorityCount > 1)
95 *RtlSubAuthoritySid(*pSid, 1) = nSubAuthority1;
96 if (nSubAuthorityCount > 2)
97 *RtlSubAuthoritySid(*pSid, 2) = nSubAuthority2;
98 if (nSubAuthorityCount > 3)
99 *RtlSubAuthoritySid(*pSid, 3) = nSubAuthority3;
100 if (nSubAuthorityCount > 4)
101 *RtlSubAuthoritySid(*pSid, 4) = nSubAuthority4;
102 if (nSubAuthorityCount > 5)
103 *RtlSubAuthoritySid(*pSid, 5) = nSubAuthority5;
104 if (nSubAuthorityCount > 6)
105 *RtlSubAuthoritySid(*pSid, 6) = nSubAuthority6;
106 if (nSubAuthorityCount > 7)
107 *RtlSubAuthoritySid(*pSid, 7) = nSubAuthority7;
109 return STATUS_SUCCESS;
111 /******************************************************************************
112 * RtlEqualSid [NTDLL.@]
115 BOOL WINAPI RtlEqualSid( PSID pSid1, PSID pSid2 )
117 if (!RtlValidSid(pSid1) || !RtlValidSid(pSid2))
118 return FALSE;
120 if (*RtlSubAuthorityCountSid(pSid1) != *RtlSubAuthorityCountSid(pSid2))
121 return FALSE;
123 if (memcmp(pSid1, pSid2, RtlLengthSid(pSid1)) != 0)
124 return FALSE;
126 return TRUE;
129 /******************************************************************************
130 * RtlEqualPrefixSid [NTDLL.@]
132 BOOL WINAPI RtlEqualPrefixSid (PSID pSid1, PSID pSid2)
134 if (!RtlValidSid(pSid1) || !RtlValidSid(pSid2))
135 return FALSE;
137 if (*RtlSubAuthorityCountSid(pSid1) != *RtlSubAuthorityCountSid(pSid2))
138 return FALSE;
140 if (memcmp(pSid1, pSid2, RtlLengthRequiredSid(pSid1->SubAuthorityCount - 1)) != 0)
141 return FALSE;
143 return TRUE;
147 /******************************************************************************
148 * RtlFreeSid [NTDLL.@]
150 DWORD WINAPI RtlFreeSid(PSID pSid)
152 TRACE("(%p)\n", pSid);
153 RtlFreeHeap( GetProcessHeap(), 0, pSid );
154 return STATUS_SUCCESS;
157 /**************************************************************************
158 * RtlLengthRequiredSid [NTDLL.@]
160 * PARAMS
161 * nSubAuthorityCount []
163 DWORD WINAPI RtlLengthRequiredSid(DWORD nrofsubauths)
165 return (nrofsubauths-1)*sizeof(DWORD) + sizeof(SID);
168 /**************************************************************************
169 * RtlLengthSid [NTDLL.@]
171 DWORD WINAPI RtlLengthSid(PSID pSid)
173 TRACE("sid=%p\n",pSid);
174 if (!pSid) return 0;
175 return RtlLengthRequiredSid(*RtlSubAuthorityCountSid(pSid));
178 /**************************************************************************
179 * RtlInitializeSid [NTDLL.@]
181 BOOL WINAPI RtlInitializeSid(
182 PSID pSid,
183 PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
184 BYTE nSubAuthorityCount)
186 int i;
187 if (nSubAuthorityCount >= SID_MAX_SUB_AUTHORITIES)
188 return FALSE;
190 pSid->Revision = SID_REVISION;
191 pSid->SubAuthorityCount = nSubAuthorityCount;
192 if (pIdentifierAuthority)
193 memcpy(&pSid->IdentifierAuthority, pIdentifierAuthority, sizeof (SID_IDENTIFIER_AUTHORITY));
195 for (i = 0; i < nSubAuthorityCount; i++)
196 *RtlSubAuthoritySid(pSid, i) = 0;
198 return TRUE;
201 /**************************************************************************
202 * RtlSubAuthoritySid [NTDLL.@]
204 * PARAMS
205 * pSid []
206 * nSubAuthority []
208 LPDWORD WINAPI RtlSubAuthoritySid( PSID pSid, DWORD nSubAuthority )
210 return &(pSid->SubAuthority[nSubAuthority]);
213 /**************************************************************************
214 * RtlIdentifierAuthoritySid [NTDLL.@]
216 * PARAMS
217 * pSid []
219 PSID_IDENTIFIER_AUTHORITY WINAPI RtlIdentifierAuthoritySid( PSID pSid )
221 return &(pSid->IdentifierAuthority);
224 /**************************************************************************
225 * RtlSubAuthorityCountSid [NTDLL.@]
227 * PARAMS
228 * pSid []
229 * nSubAuthority []
231 LPBYTE WINAPI RtlSubAuthorityCountSid(PSID pSid)
233 return &(pSid->SubAuthorityCount);
236 /**************************************************************************
237 * RtlCopySid [NTDLL.@]
239 DWORD WINAPI RtlCopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid )
241 if (!pSourceSid || !RtlValidSid(pSourceSid) ||
242 (nDestinationSidLength < RtlLengthSid(pSourceSid)))
243 return FALSE;
245 if (nDestinationSidLength < (pSourceSid->SubAuthorityCount*4+8))
246 return FALSE;
248 memmove(pDestinationSid, pSourceSid, pSourceSid->SubAuthorityCount*4+8);
249 return TRUE;
251 /******************************************************************************
252 * RtlValidSid [NTDLL.@]
254 * PARAMS
255 * pSid []
257 BOOL WINAPI
258 RtlValidSid( PSID pSid )
260 BOOL ret;
261 __TRY
263 ret = TRUE;
264 if (!pSid || pSid->Revision != SID_REVISION ||
265 pSid->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES)
267 ret = FALSE;
270 __EXCEPT(page_fault)
272 WARN("(%p): invalid pointer!\n", pSid);
273 return FALSE;
275 __ENDTRY
276 return ret;
281 * security descriptor functions
284 /**************************************************************************
285 * RtlCreateSecurityDescriptor [NTDLL.@]
287 * RETURNS:
288 * 0 success,
289 * STATUS_INVALID_OWNER, STATUS_PRIVILEGE_NOT_HELD, STATUS_NO_INHERITANCE,
290 * STATUS_NO_MEMORY
292 NTSTATUS WINAPI RtlCreateSecurityDescriptor(
293 PSECURITY_DESCRIPTOR lpsd,
294 DWORD rev)
296 if (rev!=SECURITY_DESCRIPTOR_REVISION)
297 return STATUS_UNKNOWN_REVISION;
298 memset(lpsd,'\0',sizeof(*lpsd));
299 lpsd->Revision = SECURITY_DESCRIPTOR_REVISION;
300 return STATUS_SUCCESS;
302 /**************************************************************************
303 * RtlValidSecurityDescriptor [NTDLL.@]
306 NTSTATUS WINAPI RtlValidSecurityDescriptor(
307 PSECURITY_DESCRIPTOR SecurityDescriptor)
309 if ( ! SecurityDescriptor )
310 return STATUS_INVALID_SECURITY_DESCR;
311 if ( SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION )
312 return STATUS_UNKNOWN_REVISION;
314 return STATUS_SUCCESS;
317 /**************************************************************************
318 * RtlLengthSecurityDescriptor [NTDLL.@]
320 ULONG WINAPI RtlLengthSecurityDescriptor(
321 PSECURITY_DESCRIPTOR SecurityDescriptor)
323 ULONG Size;
324 Size = SECURITY_DESCRIPTOR_MIN_LENGTH;
325 if ( SecurityDescriptor == NULL )
326 return 0;
328 if ( SecurityDescriptor->Owner != NULL )
329 Size += SecurityDescriptor->Owner->SubAuthorityCount;
330 if ( SecurityDescriptor->Group != NULL )
331 Size += SecurityDescriptor->Group->SubAuthorityCount;
334 if ( SecurityDescriptor->Sacl != NULL )
335 Size += SecurityDescriptor->Sacl->AclSize;
336 if ( SecurityDescriptor->Dacl != NULL )
337 Size += SecurityDescriptor->Dacl->AclSize;
339 return Size;
342 /******************************************************************************
343 * RtlGetDaclSecurityDescriptor [NTDLL.@]
346 NTSTATUS WINAPI RtlGetDaclSecurityDescriptor(
347 IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
348 OUT PBOOLEAN lpbDaclPresent,
349 OUT PACL *pDacl,
350 OUT PBOOLEAN lpbDaclDefaulted)
352 TRACE("(%p,%p,%p,%p)\n",
353 pSecurityDescriptor, lpbDaclPresent, *pDacl, lpbDaclDefaulted);
355 if (pSecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION)
356 return STATUS_UNKNOWN_REVISION ;
358 if ( (*lpbDaclPresent = (SE_DACL_PRESENT & pSecurityDescriptor->Control) ? 1 : 0) )
360 if ( SE_SELF_RELATIVE & pSecurityDescriptor->Control)
361 { *pDacl = (PACL) ((LPBYTE)pSecurityDescriptor + (DWORD)pSecurityDescriptor->Dacl);
363 else
364 { *pDacl = pSecurityDescriptor->Dacl;
368 *lpbDaclDefaulted = (( SE_DACL_DEFAULTED & pSecurityDescriptor->Control ) ? 1 : 0);
370 return STATUS_SUCCESS;
373 /**************************************************************************
374 * RtlSetDaclSecurityDescriptor [NTDLL.@]
376 NTSTATUS WINAPI RtlSetDaclSecurityDescriptor (
377 PSECURITY_DESCRIPTOR lpsd,
378 BOOLEAN daclpresent,
379 PACL dacl,
380 BOOLEAN dacldefaulted )
382 if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
383 return STATUS_UNKNOWN_REVISION;
384 if (lpsd->Control & SE_SELF_RELATIVE)
385 return STATUS_INVALID_SECURITY_DESCR;
387 if (!daclpresent)
388 { lpsd->Control &= ~SE_DACL_PRESENT;
389 return TRUE;
392 lpsd->Control |= SE_DACL_PRESENT;
393 lpsd->Dacl = dacl;
395 if (dacldefaulted)
396 lpsd->Control |= SE_DACL_DEFAULTED;
397 else
398 lpsd->Control &= ~SE_DACL_DEFAULTED;
400 return STATUS_SUCCESS;
403 /******************************************************************************
404 * RtlGetSaclSecurityDescriptor [NTDLL.@]
407 NTSTATUS WINAPI RtlGetSaclSecurityDescriptor(
408 IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
409 OUT PBOOLEAN lpbSaclPresent,
410 OUT PACL *pSacl,
411 OUT PBOOLEAN lpbSaclDefaulted)
413 TRACE("(%p,%p,%p,%p)\n",
414 pSecurityDescriptor, lpbSaclPresent, *pSacl, lpbSaclDefaulted);
416 if (pSecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION)
417 return STATUS_UNKNOWN_REVISION ;
419 if ( (*lpbSaclPresent = (SE_SACL_PRESENT & pSecurityDescriptor->Control) ? 1 : 0) )
421 if ( SE_SELF_RELATIVE & pSecurityDescriptor->Control)
422 { *pSacl = (PACL) ((LPBYTE)pSecurityDescriptor + (DWORD)pSecurityDescriptor->Sacl);
424 else
425 { *pSacl = pSecurityDescriptor->Sacl;
429 *lpbSaclDefaulted = (( SE_SACL_DEFAULTED & pSecurityDescriptor->Control ) ? 1 : 0);
431 return STATUS_SUCCESS;
434 /**************************************************************************
435 * RtlSetSaclSecurityDescriptor [NTDLL.@]
437 NTSTATUS WINAPI RtlSetSaclSecurityDescriptor (
438 PSECURITY_DESCRIPTOR lpsd,
439 BOOLEAN saclpresent,
440 PACL sacl,
441 BOOLEAN sacldefaulted)
443 if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
444 return STATUS_UNKNOWN_REVISION;
445 if (lpsd->Control & SE_SELF_RELATIVE)
446 return STATUS_INVALID_SECURITY_DESCR;
447 if (!saclpresent) {
448 lpsd->Control &= ~SE_SACL_PRESENT;
449 return 0;
451 lpsd->Control |= SE_SACL_PRESENT;
452 lpsd->Sacl = sacl;
453 if (sacldefaulted)
454 lpsd->Control |= SE_SACL_DEFAULTED;
455 else
456 lpsd->Control &= ~SE_SACL_DEFAULTED;
457 return STATUS_SUCCESS;
460 /**************************************************************************
461 * RtlGetOwnerSecurityDescriptor [NTDLL.@]
463 NTSTATUS WINAPI RtlGetOwnerSecurityDescriptor(
464 PSECURITY_DESCRIPTOR SecurityDescriptor,
465 PSID *Owner,
466 PBOOLEAN OwnerDefaulted)
468 if ( !SecurityDescriptor || !Owner || !OwnerDefaulted )
469 return STATUS_INVALID_PARAMETER;
471 *Owner = SecurityDescriptor->Owner;
472 if ( *Owner != NULL ) {
473 if ( SecurityDescriptor->Control & SE_OWNER_DEFAULTED )
474 *OwnerDefaulted = TRUE;
475 else
476 *OwnerDefaulted = FALSE;
478 return STATUS_SUCCESS;
481 /**************************************************************************
482 * RtlSetOwnerSecurityDescriptor [NTDLL.@]
484 NTSTATUS WINAPI RtlSetOwnerSecurityDescriptor(
485 PSECURITY_DESCRIPTOR lpsd,
486 PSID owner,
487 BOOLEAN ownerdefaulted)
489 if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
490 return STATUS_UNKNOWN_REVISION;
491 if (lpsd->Control & SE_SELF_RELATIVE)
492 return STATUS_INVALID_SECURITY_DESCR;
494 lpsd->Owner = owner;
495 if (ownerdefaulted)
496 lpsd->Control |= SE_OWNER_DEFAULTED;
497 else
498 lpsd->Control &= ~SE_OWNER_DEFAULTED;
499 return STATUS_SUCCESS;
502 /**************************************************************************
503 * RtlSetGroupSecurityDescriptor [NTDLL.@]
505 NTSTATUS WINAPI RtlSetGroupSecurityDescriptor (
506 PSECURITY_DESCRIPTOR lpsd,
507 PSID group,
508 BOOLEAN groupdefaulted)
510 if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
511 return STATUS_UNKNOWN_REVISION;
512 if (lpsd->Control & SE_SELF_RELATIVE)
513 return STATUS_INVALID_SECURITY_DESCR;
515 lpsd->Group = group;
516 if (groupdefaulted)
517 lpsd->Control |= SE_GROUP_DEFAULTED;
518 else
519 lpsd->Control &= ~SE_GROUP_DEFAULTED;
520 return STATUS_SUCCESS;
522 /**************************************************************************
523 * RtlGetGroupSecurityDescriptor [NTDLL.@]
525 NTSTATUS WINAPI RtlGetGroupSecurityDescriptor(
526 PSECURITY_DESCRIPTOR SecurityDescriptor,
527 PSID *Group,
528 PBOOLEAN GroupDefaulted)
530 if ( !SecurityDescriptor || !Group || !GroupDefaulted )
531 return STATUS_INVALID_PARAMETER;
533 *Group = SecurityDescriptor->Group;
534 if ( *Group != NULL ) {
535 if ( SecurityDescriptor->Control & SE_GROUP_DEFAULTED )
536 *GroupDefaulted = TRUE;
537 else
538 *GroupDefaulted = FALSE;
540 return STATUS_SUCCESS;
543 /**************************************************************************
544 * RtlMakeSelfRelativeSD [NTDLL.@]
546 NTSTATUS WINAPI RtlMakeSelfRelativeSD(
547 IN PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
548 IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
549 IN OUT LPDWORD lpdwBufferLength)
551 FIXME("(%p,%p,%p(%lu))\n", pAbsoluteSecurityDescriptor,
552 pSelfRelativeSecurityDescriptor, lpdwBufferLength,*lpdwBufferLength);
553 return STATUS_SUCCESS;
557 * access control list's
560 /**************************************************************************
561 * RtlCreateAcl [NTDLL.@]
563 * NOTES
564 * This should return NTSTATUS
566 NTSTATUS WINAPI RtlCreateAcl(PACL acl,DWORD size,DWORD rev)
568 TRACE("%p 0x%08lx 0x%08lx\n", acl, size, rev);
570 if (rev!=ACL_REVISION)
571 return STATUS_INVALID_PARAMETER;
572 if (size<sizeof(ACL))
573 return STATUS_BUFFER_TOO_SMALL;
574 if (size>0xFFFF)
575 return STATUS_INVALID_PARAMETER;
577 memset(acl,'\0',sizeof(ACL));
578 acl->AclRevision = rev;
579 acl->AclSize = size;
580 acl->AceCount = 0;
581 return 0;
584 /**************************************************************************
585 * RtlFirstFreeAce [NTDLL.@]
586 * looks for the AceCount+1 ACE, and if it is still within the alloced
587 * ACL, return a pointer to it
589 BOOLEAN WINAPI RtlFirstFreeAce(
590 PACL acl,
591 PACE_HEADER *x)
593 PACE_HEADER ace;
594 int i;
596 *x = 0;
597 ace = (PACE_HEADER)(acl+1);
598 for (i=0;i<acl->AceCount;i++) {
599 if ((DWORD)ace>=(((DWORD)acl)+acl->AclSize))
600 return 0;
601 ace = (PACE_HEADER)(((BYTE*)ace)+ace->AceSize);
603 if ((DWORD)ace>=(((DWORD)acl)+acl->AclSize))
604 return 0;
605 *x = ace;
606 return 1;
609 /**************************************************************************
610 * RtlAddAce [NTDLL.@]
612 NTSTATUS WINAPI RtlAddAce(
613 PACL acl,
614 DWORD rev,
615 DWORD xnrofaces,
616 PACE_HEADER acestart,
617 DWORD acelen)
619 PACE_HEADER ace,targetace;
620 int nrofaces;
622 if (acl->AclRevision != ACL_REVISION)
623 return STATUS_INVALID_PARAMETER;
624 if (!RtlFirstFreeAce(acl,&targetace))
625 return STATUS_INVALID_PARAMETER;
626 nrofaces=0;ace=acestart;
627 while (((DWORD)ace-(DWORD)acestart)<acelen) {
628 nrofaces++;
629 ace = (PACE_HEADER)(((BYTE*)ace)+ace->AceSize);
631 if ((DWORD)targetace+acelen>(DWORD)acl+acl->AclSize) /* too much aces */
632 return STATUS_INVALID_PARAMETER;
633 memcpy((LPBYTE)targetace,acestart,acelen);
634 acl->AceCount+=nrofaces;
635 return STATUS_SUCCESS;
638 /******************************************************************************
639 * RtlAddAccessAllowedAce [NTDLL.@]
641 BOOL WINAPI RtlAddAccessAllowedAce(
642 IN OUT PACL pAcl,
643 IN DWORD dwAceRevision,
644 IN DWORD AccessMask,
645 IN PSID pSid)
647 FIXME("(%p,0x%08lx,0x%08lx,%p),stub!\n",
648 pAcl, dwAceRevision, AccessMask, pSid);
649 return TRUE;
652 /******************************************************************************
653 * RtlGetAce [NTDLL.@]
655 DWORD WINAPI RtlGetAce(PACL pAcl,DWORD dwAceIndex,LPVOID *pAce )
657 FIXME("(%p,%ld,%p),stub!\n",pAcl,dwAceIndex,pAce);
658 return 0;
662 * misc
665 /******************************************************************************
666 * RtlAdjustPrivilege [NTDLL.@]
668 DWORD WINAPI RtlAdjustPrivilege(DWORD x1,DWORD x2,DWORD x3,DWORD x4)
670 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4);
671 return 0;
674 /******************************************************************************
675 * RtlImpersonateSelf [NTDLL.@]
677 BOOL WINAPI
678 RtlImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
680 FIXME("(%08x), stub\n", ImpersonationLevel);
681 return TRUE;
684 /******************************************************************************
685 * NtAccessCheck [NTDLL.@]
687 NTSTATUS WINAPI
688 NtAccessCheck(
689 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
690 IN HANDLE ClientToken,
691 IN ACCESS_MASK DesiredAccess,
692 IN PGENERIC_MAPPING GenericMapping,
693 OUT PPRIVILEGE_SET PrivilegeSet,
694 OUT PULONG ReturnLength,
695 OUT PULONG GrantedAccess,
696 OUT PBOOLEAN AccessStatus)
698 FIXME("(%p, %04x, %08lx, %p, %p, %p, %p, %p), stub\n",
699 SecurityDescriptor, ClientToken, DesiredAccess, GenericMapping,
700 PrivilegeSet, ReturnLength, GrantedAccess, AccessStatus);
701 *AccessStatus = TRUE;
702 return STATUS_SUCCESS;
705 /******************************************************************************
706 * NtSetSecurityObject [NTDLL.@]
708 NTSTATUS WINAPI
709 NtSetSecurityObject(
710 IN HANDLE Handle,
711 IN SECURITY_INFORMATION SecurityInformation,
712 IN PSECURITY_DESCRIPTOR SecurityDescriptor)
714 FIXME("0x%08x 0x%08lx %p\n", Handle, SecurityInformation, SecurityDescriptor);
715 return STATUS_SUCCESS;
718 /******************************************************************************
719 * RtlGetControlSecurityDescriptor (NTDLL.@)
722 NTSTATUS WINAPI RtlGetControlSecurityDescriptor(
723 PSECURITY_DESCRIPTOR pSecurityDescriptor,
724 PSECURITY_DESCRIPTOR_CONTROL pControl,
725 LPDWORD lpdwRevision)
727 FIXME("(%p,%p,%p),stub!\n",pSecurityDescriptor,pControl,lpdwRevision);
728 return STATUS_SUCCESS;
731 /******************************************************************************
732 * RtlConvertSidToUnicodeString (NTDLL.@)
734 * The returned SID is used to access the USER registry hive usually
736 * the native function returns something like
737 * "S-1-5-21-0000000000-000000000-0000000000-500";
739 NTSTATUS WINAPI RtlConvertSidToUnicodeString(
740 PUNICODE_STRING String,
741 PSID Sid,
742 BOOLEAN AllocateString)
744 const char *p;
745 NTSTATUS status;
746 ANSI_STRING AnsiStr;
748 #ifdef HAVE_GETPWUID
749 struct passwd *pwd = getpwuid( getuid() );
750 p = pwd ? pwd->pw_name : NULL;
751 #else
752 p = getenv("USER");
753 #endif
754 p = p ? p : ".Default";
756 FIXME("(%p %p %u)\n", String, Sid, AllocateString);
758 RtlInitAnsiString(&AnsiStr, p);
759 status = RtlAnsiStringToUnicodeString(String, &AnsiStr, AllocateString);
761 TRACE("%s (%u %u)\n",debugstr_w(String->Buffer),String->Length,String->MaximumLength);
762 return status;