mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 00:16:40 +00:00
- Port LookupAccountNameA/W from Wine. This fixes VMWare Tools crash in NTDLL introduced by msiexec sync.
svn path=/trunk/; revision=32186
This commit is contained in:
parent
d7e3b6a80d
commit
9a3b43aa45
1 changed files with 212 additions and 21 deletions
|
@ -2,7 +2,7 @@
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
* FILE: lib/advapi32/sec/misc.c
|
* FILE: lib/advapi32/sec/misc.c
|
||||||
* PURPOSE: Miscellaneous security functions
|
* PURPOSE: Miscellaneous security functions (some ported from Wine)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <advapi32.h>
|
#include <advapi32.h>
|
||||||
|
@ -10,6 +10,122 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
/* Needed for LookupAccountNameW implementation from Wine */
|
||||||
|
|
||||||
|
typedef struct _AccountSid {
|
||||||
|
WELL_KNOWN_SID_TYPE type;
|
||||||
|
LPCWSTR account;
|
||||||
|
LPCWSTR domain;
|
||||||
|
SID_NAME_USE name_use;
|
||||||
|
} AccountSid;
|
||||||
|
|
||||||
|
static const WCHAR Account_Operators[] = { 'A','c','c','o','u','n','t',' ','O','p','e','r','a','t','o','r','s',0 };
|
||||||
|
static const WCHAR Administrator[] = {'A','d','m','i','n','i','s','t','r','a','t','o','r',0 };
|
||||||
|
static const WCHAR Administrators[] = { 'A','d','m','i','n','i','s','t','r','a','t','o','r','s',0 };
|
||||||
|
static const WCHAR ANONYMOUS_LOGON[] = { 'A','N','O','N','Y','M','O','U','S',' ','L','O','G','O','N',0 };
|
||||||
|
static const WCHAR Authenticated_Users[] = { 'A','u','t','h','e','n','t','i','c','a','t','e','d',' ','U','s','e','r','s',0 };
|
||||||
|
static const WCHAR Backup_Operators[] = { 'B','a','c','k','u','p',' ','O','p','e','r','a','t','o','r','s',0 };
|
||||||
|
static const WCHAR BATCH[] = { 'B','A','T','C','H',0 };
|
||||||
|
static const WCHAR Blank[] = { 0 };
|
||||||
|
static const WCHAR BUILTIN[] = { 'B','U','I','L','T','I','N',0 };
|
||||||
|
static const WCHAR Cert_Publishers[] = { 'C','e','r','t',' ','P','u','b','l','i','s','h','e','r','s',0 };
|
||||||
|
static const WCHAR CREATOR_GROUP[] = { 'C','R','E','A','T','O','R',' ','G','R','O','U','P',0 };
|
||||||
|
static const WCHAR CREATOR_GROUP_SERVER[] = { 'C','R','E','A','T','O','R',' ','G','R','O','U','P',' ','S','E','R','V','E','R',0 };
|
||||||
|
static const WCHAR CREATOR_OWNER[] = { 'C','R','E','A','T','O','R',' ','O','W','N','E','R',0 };
|
||||||
|
static const WCHAR CREATOR_OWNER_SERVER[] = { 'C','R','E','A','T','O','R',' ','O','W','N','E','R',' ','S','E','R','V','E','R',0 };
|
||||||
|
static const WCHAR DIALUP[] = { 'D','I','A','L','U','P',0 };
|
||||||
|
static const WCHAR Digest_Authentication[] = { 'D','i','g','e','s','t',' ','A','u','t','h','e','n','t','i','c','a','t','i','o','n',0 };
|
||||||
|
static const WCHAR DOMAIN[] = {'D','O','M','A','I','N',0};
|
||||||
|
static const WCHAR Domain_Admins[] = { 'D','o','m','a','i','n',' ','A','d','m','i','n','s',0 };
|
||||||
|
static const WCHAR Domain_Computers[] = { 'D','o','m','a','i','n',' ','C','o','m','p','u','t','e','r','s',0 };
|
||||||
|
static const WCHAR Domain_Controllers[] = { 'D','o','m','a','i','n',' ','C','o','n','t','r','o','l','l','e','r','s',0 };
|
||||||
|
static const WCHAR Domain_Guests[] = { 'D','o','m','a','i','n',' ','G','u','e','s','t','s',0 };
|
||||||
|
static const WCHAR Domain_Users[] = { 'D','o','m','a','i','n',' ','U','s','e','r','s',0 };
|
||||||
|
static const WCHAR Enterprise_Admins[] = { 'E','n','t','e','r','p','r','i','s','e',' ','A','d','m','i','n','s',0 };
|
||||||
|
static const WCHAR ENTERPRISE_DOMAIN_CONTROLLERS[] = { 'E','N','T','E','R','P','R','I','S','E',' ','D','O','M','A','I','N',' ','C','O','N','T','R','O','L','L','E','R','S',0 };
|
||||||
|
static const WCHAR Everyone[] = { 'E','v','e','r','y','o','n','e',0 };
|
||||||
|
static const WCHAR Group_Policy_Creator_Owners[] = { 'G','r','o','u','p',' ','P','o','l','i','c','y',' ','C','r','e','a','t','o','r',' ','O','w','n','e','r','s',0 };
|
||||||
|
static const WCHAR Guest[] = { 'G','u','e','s','t',0 };
|
||||||
|
static const WCHAR Guests[] = { 'G','u','e','s','t','s',0 };
|
||||||
|
static const WCHAR INTERACTIVE[] = { 'I','N','T','E','R','A','C','T','I','V','E',0 };
|
||||||
|
static const WCHAR LOCAL[] = { 'L','O','C','A','L',0 };
|
||||||
|
static const WCHAR LOCAL_SERVICE[] = { 'L','O','C','A','L',' ','S','E','R','V','I','C','E',0 };
|
||||||
|
static const WCHAR NETWORK[] = { 'N','E','T','W','O','R','K',0 };
|
||||||
|
static const WCHAR Network_Configuration_Operators[] = { 'N','e','t','w','o','r','k',' ','C','o','n','f','i','g','u','r','a','t','i','o','n',' ','O','p','e','r','a','t','o','r','s',0 };
|
||||||
|
static const WCHAR NETWORK_SERVICE[] = { 'N','E','T','W','O','R','K',' ','S','E','R','V','I','C','E',0 };
|
||||||
|
static const WCHAR NT_AUTHORITY[] = { 'N','T',' ','A','U','T','H','O','R','I','T','Y',0 };
|
||||||
|
static const WCHAR NT_Pseudo_Domain[] = { 'N','T',' ','P','s','e','u','d','o',' ','D','o','m','a','i','n',0 };
|
||||||
|
static const WCHAR NTML_Authentication[] = { 'N','T','M','L',' ','A','u','t','h','e','n','t','i','c','a','t','i','o','n',0 };
|
||||||
|
static const WCHAR NULL_SID[] = { 'N','U','L','L',' ','S','I','D',0 };
|
||||||
|
static const WCHAR Other_Organization[] = { 'O','t','h','e','r',' ','O','r','g','a','n','i','z','a','t','i','o','n',0 };
|
||||||
|
static const WCHAR Performance_Log_Users[] = { 'P','e','r','f','o','r','m','a','n','c','e',' ','L','o','g',' ','U','s','e','r','s',0 };
|
||||||
|
static const WCHAR Performance_Monitor_Users[] = { 'P','e','r','f','o','r','m','a','n','c','e',' ','M','o','n','i','t','o','r',' ','U','s','e','r','s',0 };
|
||||||
|
static const WCHAR Power_Users[] = { 'P','o','w','e','r',' ','U','s','e','r','s',0 };
|
||||||
|
static const WCHAR Pre_Windows_2000_Compatible_Access[] = { 'P','r','e','-','W','i','n','d','o','w','s',' ','2','0','0','0',' ','C','o','m','p','a','t','i','b','l','e',' ','A','c','c','e','s','s',0 };
|
||||||
|
static const WCHAR Print_Operators[] = { 'P','r','i','n','t',' ','O','p','e','r','a','t','o','r','s',0 };
|
||||||
|
static const WCHAR PROXY[] = { 'P','R','O','X','Y',0 };
|
||||||
|
static const WCHAR RAS_and_IAS_Servers[] = { 'R','A','S',' ','a','n','d',' ','I','A','S',' ','S','e','r','v','e','r','s',0 };
|
||||||
|
static const WCHAR Remote_Desktop_Users[] = { 'R','e','m','o','t','e',' ','D','e','s','k','t','o','p',' ','U','s','e','r','s',0 };
|
||||||
|
static const WCHAR REMOTE_INTERACTIVE_LOGON[] = { 'R','E','M','O','T','E',' ','I','N','T','E','R','A','C','T','I','V','E',' ','L','O','G','O','N',0 };
|
||||||
|
static const WCHAR Replicators[] = { 'R','e','p','l','i','c','a','t','o','r','s',0 };
|
||||||
|
static const WCHAR RESTRICTED[] = { 'R','E','S','T','R','I','C','T','E','D',0 };
|
||||||
|
static const WCHAR SChannel_Authentication[] = { 'S','C','h','a','n','n','e','l',' ','A','u','t','h','e','n','t','i','c','a','t','i','o','n',0 };
|
||||||
|
static const WCHAR Schema_Admins[] = { 'S','c','h','e','m','a',' ','A','d','m','i','n','s',0 };
|
||||||
|
static const WCHAR SELF[] = { 'S','E','L','F',0 };
|
||||||
|
static const WCHAR Server_Operators[] = { 'S','e','r','v','e','r',' ','O','p','e','r','a','t','o','r','s',0 };
|
||||||
|
static const WCHAR SERVICE[] = { 'S','E','R','V','I','C','E',0 };
|
||||||
|
static const WCHAR SYSTEM[] = { 'S','Y','S','T','E','M',0 };
|
||||||
|
static const WCHAR TERMINAL_SERVER_USER[] = { 'T','E','R','M','I','N','A','L',' ','S','E','R','V','E','R',' ','U','S','E','R',0 };
|
||||||
|
static const WCHAR This_Organization[] = { 'T','h','i','s',' ','O','r','g','a','n','i','z','a','t','i','o','n',0 };
|
||||||
|
static const WCHAR Users[] = { 'U','s','e','r','s',0 };
|
||||||
|
|
||||||
|
static const AccountSid ACCOUNT_SIDS[] = {
|
||||||
|
{ WinNullSid, NULL_SID, Blank, SidTypeWellKnownGroup },
|
||||||
|
{ WinWorldSid, Everyone, Blank, SidTypeWellKnownGroup },
|
||||||
|
{ WinLocalSid, LOCAL, Blank, SidTypeWellKnownGroup },
|
||||||
|
{ WinCreatorOwnerSid, CREATOR_OWNER, Blank, SidTypeWellKnownGroup },
|
||||||
|
{ WinCreatorGroupSid, CREATOR_GROUP, Blank, SidTypeWellKnownGroup },
|
||||||
|
{ WinCreatorOwnerServerSid, CREATOR_OWNER_SERVER, Blank, SidTypeWellKnownGroup },
|
||||||
|
{ WinCreatorGroupServerSid, CREATOR_GROUP_SERVER, Blank, SidTypeWellKnownGroup },
|
||||||
|
{ WinNtAuthoritySid, NT_Pseudo_Domain, NT_Pseudo_Domain, SidTypeDomain },
|
||||||
|
{ WinDialupSid, DIALUP, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinNetworkSid, NETWORK, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinBatchSid, BATCH, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinInteractiveSid, INTERACTIVE, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinServiceSid, SERVICE, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinAnonymousSid, ANONYMOUS_LOGON, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinProxySid, PROXY, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinEnterpriseControllersSid, ENTERPRISE_DOMAIN_CONTROLLERS, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinSelfSid, SELF, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinAuthenticatedUserSid, Authenticated_Users, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinRestrictedCodeSid, RESTRICTED, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinTerminalServerSid, TERMINAL_SERVER_USER, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinRemoteLogonIdSid, REMOTE_INTERACTIVE_LOGON, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinLocalSystemSid, SYSTEM, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinLocalServiceSid, LOCAL_SERVICE, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinNetworkServiceSid, NETWORK_SERVICE, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinBuiltinDomainSid, BUILTIN, BUILTIN, SidTypeDomain },
|
||||||
|
{ WinBuiltinAdministratorsSid, Administrators, BUILTIN, SidTypeAlias },
|
||||||
|
{ WinBuiltinUsersSid, Users, BUILTIN, SidTypeAlias },
|
||||||
|
{ WinBuiltinGuestsSid, Guests, BUILTIN, SidTypeAlias },
|
||||||
|
{ WinBuiltinPowerUsersSid, Power_Users, BUILTIN, SidTypeAlias },
|
||||||
|
{ WinBuiltinAccountOperatorsSid, Account_Operators, BUILTIN, SidTypeAlias },
|
||||||
|
{ WinBuiltinSystemOperatorsSid, Server_Operators, BUILTIN, SidTypeAlias },
|
||||||
|
{ WinBuiltinPrintOperatorsSid, Print_Operators, BUILTIN, SidTypeAlias },
|
||||||
|
{ WinBuiltinBackupOperatorsSid, Backup_Operators, BUILTIN, SidTypeAlias },
|
||||||
|
{ WinBuiltinReplicatorSid, Replicators, BUILTIN, SidTypeAlias },
|
||||||
|
{ WinBuiltinPreWindows2000CompatibleAccessSid, Pre_Windows_2000_Compatible_Access, BUILTIN, SidTypeAlias },
|
||||||
|
{ WinBuiltinRemoteDesktopUsersSid, Remote_Desktop_Users, BUILTIN, SidTypeAlias },
|
||||||
|
{ WinBuiltinNetworkConfigurationOperatorsSid, Network_Configuration_Operators, BUILTIN, SidTypeAlias },
|
||||||
|
{ WinNTLMAuthenticationSid, NTML_Authentication, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinDigestAuthenticationSid, Digest_Authentication, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinSChannelAuthenticationSid, SChannel_Authentication, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinThisOrganizationSid, This_Organization, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinOtherOrganizationSid, Other_Organization, NT_AUTHORITY, SidTypeWellKnownGroup },
|
||||||
|
{ WinBuiltinPerfMonitoringUsersSid, Performance_Monitor_Users, BUILTIN, SidTypeAlias },
|
||||||
|
{ WinBuiltinPerfLoggingUsersSid, Performance_Log_Users, BUILTIN, SidTypeAlias },
|
||||||
|
};
|
||||||
|
|
||||||
/* Interface to ntmarta.dll ***************************************************/
|
/* Interface to ntmarta.dll ***************************************************/
|
||||||
|
|
||||||
NTMARTA NtMartaStatic = { 0 };
|
NTMARTA NtMartaStatic = { 0 };
|
||||||
|
@ -984,20 +1100,42 @@ LookupAccountSidW (
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* LookupAccountNameA [ADVAPI32.@]
|
* LookupAccountNameA [ADVAPI32.@]
|
||||||
*
|
*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL STDCALL
|
||||||
LookupAccountNameA (LPCSTR SystemName,
|
LookupAccountNameA (LPCSTR SystemName,
|
||||||
LPCSTR AccountName,
|
LPCSTR AccountName,
|
||||||
PSID Sid,
|
PSID Sid,
|
||||||
LPDWORD SidLength,
|
LPDWORD SidLength,
|
||||||
LPSTR ReferencedDomainName,
|
LPSTR ReferencedDomainName,
|
||||||
LPDWORD hReferencedDomainNameLength,
|
LPDWORD hReferencedDomainNameLength,
|
||||||
PSID_NAME_USE SidNameUse)
|
PSID_NAME_USE SidNameUse)
|
||||||
{
|
{
|
||||||
DPRINT1("LookupAccountNameA is unimplemented\n");
|
BOOL ret;
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
UNICODE_STRING lpSystemW;
|
||||||
return FALSE;
|
UNICODE_STRING lpAccountW;
|
||||||
|
LPWSTR lpReferencedDomainNameW = NULL;
|
||||||
|
|
||||||
|
RtlCreateUnicodeStringFromAsciiz(&lpSystemW, SystemName);
|
||||||
|
RtlCreateUnicodeStringFromAsciiz(&lpAccountW, AccountName);
|
||||||
|
|
||||||
|
if (ReferencedDomainName)
|
||||||
|
lpReferencedDomainNameW = HeapAlloc(GetProcessHeap(), 0, *hReferencedDomainNameLength * sizeof(WCHAR));
|
||||||
|
|
||||||
|
ret = LookupAccountNameW(lpSystemW.Buffer, lpAccountW.Buffer, Sid, SidLength, lpReferencedDomainNameW,
|
||||||
|
hReferencedDomainNameLength, SidNameUse);
|
||||||
|
|
||||||
|
if (ret && lpReferencedDomainNameW)
|
||||||
|
{
|
||||||
|
WideCharToMultiByte(CP_ACP, 0, lpReferencedDomainNameW, *hReferencedDomainNameLength,
|
||||||
|
ReferencedDomainName, *hReferencedDomainNameLength, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
RtlFreeUnicodeString(&lpSystemW);
|
||||||
|
RtlFreeUnicodeString(&lpAccountW);
|
||||||
|
HeapFree(GetProcessHeap(), 0, lpReferencedDomainNameW);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1006,18 +1144,71 @@ LookupAccountNameA (LPCSTR SystemName,
|
||||||
*
|
*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL WINAPI LookupAccountNameW(LPCWSTR lpSystemName, LPCWSTR lpAccountName, PSID Sid,
|
||||||
LookupAccountNameW (LPCWSTR SystemName,
|
LPDWORD cbSid, LPWSTR ReferencedDomainName,
|
||||||
LPCWSTR AccountName,
|
LPDWORD cchReferencedDomainName, PSID_NAME_USE peUse)
|
||||||
PSID Sid,
|
|
||||||
LPDWORD SidLength,
|
|
||||||
LPWSTR ReferencedDomainName,
|
|
||||||
LPDWORD hReferencedDomainNameLength,
|
|
||||||
PSID_NAME_USE SidNameUse)
|
|
||||||
{
|
{
|
||||||
DPRINT1("LookupAccountNameW is unimplemented\n");
|
/* Default implementation: Always return a default SID */
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
SID_IDENTIFIER_AUTHORITY identifierAuthority = {SECURITY_NT_AUTHORITY};
|
||||||
return FALSE;
|
BOOL ret;
|
||||||
|
PSID pSid;
|
||||||
|
static const WCHAR dm[] = {'D','O','M','A','I','N',0};
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
DPRINT("%s %s %p %p %p %p %p - stub\n", lpSystemName, lpAccountName,
|
||||||
|
Sid, cbSid, ReferencedDomainName, cchReferencedDomainName, peUse);
|
||||||
|
|
||||||
|
for (i = 0; i < (sizeof(ACCOUNT_SIDS) / sizeof(ACCOUNT_SIDS[0])); i++)
|
||||||
|
{
|
||||||
|
if (!wcscmp(lpAccountName, ACCOUNT_SIDS[i].account))
|
||||||
|
{
|
||||||
|
if (*cchReferencedDomainName)
|
||||||
|
*ReferencedDomainName = '\0';
|
||||||
|
*cchReferencedDomainName = 0;
|
||||||
|
*peUse = SidTypeWellKnownGroup;
|
||||||
|
return CreateWellKnownSid(ACCOUNT_SIDS[i].type, NULL, Sid, cbSid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = AllocateAndInitializeSid(&identifierAuthority,
|
||||||
|
2,
|
||||||
|
SECURITY_BUILTIN_DOMAIN_RID,
|
||||||
|
DOMAIN_ALIAS_RID_ADMINS,
|
||||||
|
0, 0, 0, 0, 0, 0,
|
||||||
|
&pSid);
|
||||||
|
|
||||||
|
if (!ret)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (!RtlValidSid(pSid))
|
||||||
|
{
|
||||||
|
FreeSid(pSid);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Sid != NULL && (*cbSid >= GetLengthSid(pSid)))
|
||||||
|
CopySid(*cbSid, Sid, pSid);
|
||||||
|
if (*cbSid < GetLengthSid(pSid))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
*cbSid = GetLengthSid(pSid);
|
||||||
|
|
||||||
|
if (ReferencedDomainName != NULL && (*cchReferencedDomainName > wcslen(dm)))
|
||||||
|
wcscpy(ReferencedDomainName, dm);
|
||||||
|
|
||||||
|
if (*cchReferencedDomainName <= wcslen(dm))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*cchReferencedDomainName = wcslen(dm)+1;
|
||||||
|
|
||||||
|
FreeSid(pSid);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue