1 /* $Id: sid.c,v 1.3 2000/01/05 21:57:00 dwelch Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * PURPOSE: Security manager
6 * FILE: kernel/se/sid.c
7 * PROGRAMER: David Welch <welch@cwcom.net>
9 * 26/07/98: Added stubs for security functions
12 /* INCLUDES *****************************************************************/
14 #include <ddk/ntddk.h>
16 #include <internal/debug.h>
18 /* FUNCTIONS ***************************************************************/
20 BOOLEAN STDCALL
RtlValidSid (PSID Sid
)
22 if ((Sid
->Revision
& 0xf) != 1)
26 if (Sid
->SubAuthorityCount
> 15)
33 ULONG STDCALL
RtlLengthRequiredSid (UCHAR SubAuthorityCount
)
35 return(sizeof(SID
) + (SubAuthorityCount
- 1) * sizeof(ULONG
));
38 NTSTATUS STDCALL
RtlInitializeSid (PSID Sid
,
39 PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
40 UCHAR SubAuthorityCount
)
43 Sid
->SubAuthorityCount
= SubAuthorityCount
;
44 memcpy(&Sid
->IdentifierAuthority
, IdentifierAuthority
,
45 sizeof(SID_IDENTIFIER_AUTHORITY
));
46 return(STATUS_SUCCESS
);
49 PULONG STDCALL
RtlSubAuthoritySid (PSID Sid
, ULONG SubAuthority
)
51 return(&Sid
->SubAuthority
[SubAuthority
]);
54 PUCHAR STDCALL
RtlSubAuthorityCountSid (PSID Sid
)
56 return(&Sid
->SubAuthorityCount
);
59 BOOLEAN STDCALL
RtlEqualSid (PSID Sid1
, PSID Sid2
)
61 if (Sid1
->Revision
!= Sid2
->Revision
)
65 if ((*RtlSubAuthorityCountSid(Sid1
)) !=
66 (*RtlSubAuthorityCountSid(Sid2
)))
70 if (memcmp(Sid1
, Sid2
, RtlLengthSid(Sid1
) != 0))
77 ULONG STDCALL
RtlLengthSid (PSID Sid
)
79 return(sizeof(SID
) + (Sid
->SubAuthorityCount
-1)*4);
82 NTSTATUS STDCALL
RtlCopySid (ULONG BufferLength
, PSID Dest
, PSID Src
)
84 if (BufferLength
< RtlLengthSid(Src
))
86 return(STATUS_UNSUCCESSFUL
);
88 memmove(Dest
, Src
, RtlLengthSid(Src
));
89 return(STATUS_SUCCESS
);