From 3c7c6e909d9093a5c2461060294c713053c8b000 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Thu, 22 Nov 2001 02:37:32 +0000 Subject: [PATCH] Added some security/access functions. svn path=/trunk/; revision=2389 --- reactos/lib/advapi32/advapi32.edf | 20 +++--- reactos/lib/advapi32/makefile | 7 +- reactos/lib/advapi32/sec/misc.c | 111 ++++++++++++++++++++++++++++++ reactos/lib/advapi32/sec/sid.c | 89 ++++++++++++++---------- 4 files changed, 179 insertions(+), 48 deletions(-) create mode 100644 reactos/lib/advapi32/sec/misc.c diff --git a/reactos/lib/advapi32/advapi32.edf b/reactos/lib/advapi32/advapi32.edf index 5e66d6c4291..059cbd6fc75 100644 --- a/reactos/lib/advapi32/advapi32.edf +++ b/reactos/lib/advapi32/advapi32.edf @@ -1,4 +1,4 @@ -; $Id: advapi32.edf,v 1.14 2001/09/01 19:39:23 rex Exp $ +; $Id: advapi32.edf,v 1.15 2001/11/22 02:37:05 ekohl Exp $ ; ; advapi32.def ; @@ -21,8 +21,8 @@ AdjustTokenGroups=AdjustTokenGroups@24 AdjustTokenPrivileges=AdjustTokenPrivileges@24 AllocateAndInitializeSid=AllocateAndInitializeSid@44 AllocateLocallyUniqueId=AllocateLocallyUniqueId@4 -;AreAllAccessesGranted=AreAllAccessesGranted@8 -;AreAnyAccessesGranted=AreAnyAccessesGranted@8 +AreAllAccessesGranted=AreAllAccessesGranted@8 +AreAnyAccessesGranted=AreAnyAccessesGranted@8 ;BackupEventLogA=BackupEventLogA@8 ;BackupEventLogW=BackupEventLogW@8 ;BuildAccessRequestA=BuildAccessRequestA@12 @@ -135,7 +135,7 @@ GetAclInformation=GetAclInformation@16 ;GetExplicitEntriesFromAclW=GetExplicitEntriesFromAclW@12 ;GetFileSecurityA=GetFileSecurityA@20 ;GetFileSecurityW=GetFileSecurityW@20 -;GetKernelObjectSecurity=GetKernelObjectSecurity@20 +GetKernelObjectSecurity=GetKernelObjectSecurity@20 GetLengthSid=GetLengthSid@4 ;GetMultipleTrusteeA=GetMultipleTrusteeA@4 ;GetMultipleTrusteeOperationA=GetMultipleTrusteeOperationA@4 @@ -176,7 +176,7 @@ GetUserNameW=GetUserNameW@8 ;I_ScSetServiceBitsW=I_ScSetServiceBitsW@20 ;ImpersonateLoggedOnUser=ImpersonateLoggedOnUser@4 ;ImpersonateNamedPipeClient=ImpersonateNamedPipeClient@4 -;ImpersonateSelf=ImpersonateSelf@4 +ImpersonateSelf=ImpersonateSelf@4 InitializeAcl=InitializeAcl@12 InitializeSecurityDescriptor=InitializeSecurityDescriptor@8 InitializeSid=InitializeSid@12 @@ -191,8 +191,8 @@ IsValidSid=IsValidSid@4 LockServiceDatabase=LockServiceDatabase@4 ;LogonUserA=LogonUserA@24 ;LogonUserW=LogonUserW@24 -;LookupAccountNameA=LookupAccountNameA@28 -;LookupAccountNameW=LookupAccountNameW@28 +LookupAccountNameA=LookupAccountNameA@28 +LookupAccountNameW=LookupAccountNameW@28 LookupAccountSidA=LookupAccountSidA@28 LookupAccountSidW=LookupAccountSidW@28 LookupPrivilegeDisplayNameA=LookupPrivilegeDisplayNameA@20 @@ -252,7 +252,7 @@ LookupPrivilegeValueW=LookupPrivilegeValueW@12 ;LsaStorePrivateData=LsaStorePrivateData@12 MakeAbsoluteSD=MakeAbsoluteSD@44 MakeSelfRelativeSD=MakeSelfRelativeSD@12 -;MapGenericMask=MapGenericMask@8 +MapGenericMask=MapGenericMask@8 ;NTAccessMaskToProvAccessRights=NTAccessMaskToProvAccessRights@12 ;NotifyBootConfigStatus=NotifyBootConfigStatus@4 ;NotifyChangeEventLog=NotifyChangeEventLog@8 @@ -342,7 +342,7 @@ RegisterServiceCtrlHandlerW=RegisterServiceCtrlHandlerW@8 ;ReplaceAllAccessRightsW ;ReportEventA=ReportEventA@36 ;ReportEventW=ReportEventW@36 -;RevertToSelf=RevertToSelf@0 +RevertToSelf=RevertToSelf@0 ;RevokeExplicitAccessRightsA=RevokeExplicitAccessRightsA@16 ;RevokeExplicitAccessRightsW=RevokeExplicitAccessRightsW@16 ;SetAccessRightsA=SetAccessRightsA@16 @@ -352,7 +352,7 @@ SetAclInformation=SetAclInformation@16 ;SetEntriesInAclW=SetEntriesInAclW@16 ;SetFileSecurityA=SetFileSecurityA@12 ;SetFileSecurityW=SetFileSecurityW@12 -;SetKernelObjectSecurity=SetKernelObjectSecurity@12 +SetKernelObjectSecurity=SetKernelObjectSecurity@12 ;SetNamedSecurityInfoA=SetNamedSecurityInfoA@28 ;SetNamedSecurityInfoW=SetNamedSecurityInfoW@28 ;SetPrivateObjectSecurity=SetPrivateObjectSecurity@20 diff --git a/reactos/lib/advapi32/makefile b/reactos/lib/advapi32/makefile index 726079c898b..55e2c775a8c 100644 --- a/reactos/lib/advapi32/makefile +++ b/reactos/lib/advapi32/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.20 2001/10/21 19:06:42 chorns Exp $ +# $Id: makefile,v 1.21 2001/11/22 02:37:06 ekohl Exp $ PATH_TO_TOP = ../.. @@ -21,9 +21,10 @@ REGISTRY_OBJECTS=\ reg/reg.o SECURITY_OBJECTS=\ - sec/lsa.o \ - sec/sec.o \ sec/ac.o \ + sec/lsa.o \ + sec/misc.o \ + sec/sec.o \ sec/sid.o SERVICE_OBJECTS=\ diff --git a/reactos/lib/advapi32/sec/misc.c b/reactos/lib/advapi32/sec/misc.c new file mode 100644 index 00000000000..7b33d92b2be --- /dev/null +++ b/reactos/lib/advapi32/sec/misc.c @@ -0,0 +1,111 @@ +/* + */ + +#include +#include +#include + + +WINBOOL STDCALL +AreAllAccessesGranted(DWORD GrantedAccess, + DWORD DesiredAccess) +{ + return((BOOL)RtlAreAllAccessesGranted(GrantedAccess, + DesiredAccess)); +} + + +WINBOOL STDCALL +AreAnyAccessesGranted(DWORD GrantedAccess, + DWORD DesiredAccess) +{ + return((BOOL)RtlAreAnyAccessesGranted(GrantedAccess, + DesiredAccess)); +} + + +WINBOOL STDCALL +GetKernelObjectSecurity(HANDLE Handle, + SECURITY_INFORMATION RequestedInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor, + DWORD nLength, + LPDWORD lpnLengthNeeded) +{ + NTSTATUS Status; + + Status = NtQuerySecurityObject(Handle, + RequestedInformation, + pSecurityDescriptor, + nLength, + lpnLengthNeeded); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return(FALSE); + } + return(TRUE); +} + + +BOOL STDCALL +SetKernelObjectSecurity(HANDLE Handle, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR SecurityDescriptor) +{ + NTSTATUS Status; + + Status = NtSetSecurityObject(Handle, + SecurityInformation, + SecurityDescriptor); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return(FALSE); + } + return(TRUE); +} + + +VOID STDCALL +MapGenericMask(PDWORD AccessMask, + PGENERIC_MAPPING GenericMapping) +{ + RtlMapGenericMask(AccessMask, + GenericMapping); +} + + +BOOL STDCALL +ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel) +{ + NTSTATUS Status; + + Status = RtlImpersonateSelf(ImpersonationLevel); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return(FALSE); + } + return(TRUE); +} + + +BOOL STDCALL +RevertToSelf(VOID) +{ + NTSTATUS Status; + HANDLE Token = NULL; + + Status = NtSetInformationThread(NtCurrentThread(), + ThreadImpersonationToken, + &Token, + sizeof(HANDLE)); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return(FALSE); + } + return(TRUE); +} + +/* EOF */ \ No newline at end of file diff --git a/reactos/lib/advapi32/sec/sid.c b/reactos/lib/advapi32/sec/sid.c index 9fc51aacb21..4b8a847a322 100644 --- a/reactos/lib/advapi32/sec/sid.c +++ b/reactos/lib/advapi32/sec/sid.c @@ -1,4 +1,4 @@ -/* $Id: sid.c,v 1.3 2001/06/17 20:19:45 ekohl Exp $ +/* $Id: sid.c,v 1.4 2001/11/22 02:37:32 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -181,44 +181,63 @@ InitializeSid ( return TRUE; } -WINBOOL -STDCALL -IsValidSid ( - PSID pSid - ) + +WINBOOL STDCALL +IsValidSid(PSID pSid) { - return (WINBOOL)RtlValidSid (pSid); + return((WINBOOL)RtlValidSid(pSid)); } -WINBOOL -STDCALL -LookupAccountSidA ( - LPCSTR lpSystemName, - PSID Sid, - LPSTR Name, - LPDWORD cbName, - LPSTR ReferencedDomainName, - LPDWORD cbReferencedDomainName, - PSID_NAME_USE peUse - ) -{ - return (FALSE); -} - -WINBOOL -STDCALL -LookupAccountSidW ( - LPCWSTR lpSystemName, - PSID Sid, - LPWSTR Name, - LPDWORD cbName, - LPWSTR ReferencedDomainName, - LPDWORD cbReferencedDomainName, - PSID_NAME_USE peUse - ) +WINBOOL STDCALL +LookupAccountNameA(LPCSTR lpSystemName, + LPCSTR lpAccountName, + PSID Sid, + LPDWORD cbSid, + LPSTR DomainName, + LPDWORD cbDomainName, + PSID_NAME_USE peUse) { - return (FALSE); + return(FALSE); } - + + +WINBOOL STDCALL +LookupAccountNameW(LPCWSTR lpSystemName, + LPCWSTR lpAccountName, + PSID Sid, + LPDWORD cbSid, + LPWSTR DomainName, + LPDWORD cbDomainName, + PSID_NAME_USE peUse) +{ + return(FALSE); +} + + +WINBOOL STDCALL +LookupAccountSidA(LPCSTR lpSystemName, + PSID Sid, + LPSTR Name, + LPDWORD cbName, + LPSTR ReferencedDomainName, + LPDWORD cbReferencedDomainName, + PSID_NAME_USE peUse) +{ + return(FALSE); +} + + +WINBOOL STDCALL +LookupAccountSidW(LPCWSTR lpSystemName, + PSID Sid, + LPWSTR Name, + LPDWORD cbName, + LPWSTR ReferencedDomainName, + LPDWORD cbReferencedDomainName, + PSID_NAME_USE peUse) +{ + return(FALSE); +} + /* EOF */