mirror of
https://github.com/reactos/reactos.git
synced 2025-06-01 23:48:12 +00:00
Implement LookupPrivilegeNameW based on Wine code.
svn path=/trunk/; revision=37280
This commit is contained in:
parent
71e82c9ecb
commit
db0c66dcb0
2 changed files with 160 additions and 7 deletions
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include <advapi32.h>
|
||||
#include "wine/unicode.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(advapi);
|
||||
|
@ -127,6 +128,101 @@ static const AccountSid ACCOUNT_SIDS[] = {
|
|||
{ WinBuiltinPerfLoggingUsersSid, Performance_Log_Users, BUILTIN, SidTypeAlias },
|
||||
};
|
||||
|
||||
static const WCHAR SE_CREATE_TOKEN_NAME_W[] =
|
||||
{ 'S','e','C','r','e','a','t','e','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_ASSIGNPRIMARYTOKEN_NAME_W[] =
|
||||
{ 'S','e','A','s','s','i','g','n','P','r','i','m','a','r','y','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_LOCK_MEMORY_NAME_W[] =
|
||||
{ 'S','e','L','o','c','k','M','e','m','o','r','y','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_INCREASE_QUOTA_NAME_W[] =
|
||||
{ 'S','e','I','n','c','r','e','a','s','e','Q','u','o','t','a','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_MACHINE_ACCOUNT_NAME_W[] =
|
||||
{ 'S','e','M','a','c','h','i','n','e','A','c','c','o','u','n','t','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_TCB_NAME_W[] =
|
||||
{ 'S','e','T','c','b','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_SECURITY_NAME_W[] =
|
||||
{ 'S','e','S','e','c','u','r','i','t','y','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_TAKE_OWNERSHIP_NAME_W[] =
|
||||
{ 'S','e','T','a','k','e','O','w','n','e','r','s','h','i','p','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_LOAD_DRIVER_NAME_W[] =
|
||||
{ 'S','e','L','o','a','d','D','r','i','v','e','r','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_SYSTEM_PROFILE_NAME_W[] =
|
||||
{ 'S','e','S','y','s','t','e','m','P','r','o','f','i','l','e','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_SYSTEMTIME_NAME_W[] =
|
||||
{ 'S','e','S','y','s','t','e','m','t','i','m','e','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_PROF_SINGLE_PROCESS_NAME_W[] =
|
||||
{ 'S','e','P','r','o','f','i','l','e','S','i','n','g','l','e','P','r','o','c','e','s','s','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_INC_BASE_PRIORITY_NAME_W[] =
|
||||
{ 'S','e','I','n','c','r','e','a','s','e','B','a','s','e','P','r','i','o','r','i','t','y','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_CREATE_PAGEFILE_NAME_W[] =
|
||||
{ 'S','e','C','r','e','a','t','e','P','a','g','e','f','i','l','e','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_CREATE_PERMANENT_NAME_W[] =
|
||||
{ 'S','e','C','r','e','a','t','e','P','e','r','m','a','n','e','n','t','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_BACKUP_NAME_W[] =
|
||||
{ 'S','e','B','a','c','k','u','p','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_RESTORE_NAME_W[] =
|
||||
{ 'S','e','R','e','s','t','o','r','e','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_SHUTDOWN_NAME_W[] =
|
||||
{ 'S','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_DEBUG_NAME_W[] =
|
||||
{ 'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_AUDIT_NAME_W[] =
|
||||
{ 'S','e','A','u','d','i','t','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_SYSTEM_ENVIRONMENT_NAME_W[] =
|
||||
{ 'S','e','S','y','s','t','e','m','E','n','v','i','r','o','n','m','e','n','t','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_CHANGE_NOTIFY_NAME_W[] =
|
||||
{ 'S','e','C','h','a','n','g','e','N','o','t','i','f','y','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_REMOTE_SHUTDOWN_NAME_W[] =
|
||||
{ 'S','e','R','e','m','o','t','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_UNDOCK_NAME_W[] =
|
||||
{ 'S','e','U','n','d','o','c','k','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_SYNC_AGENT_NAME_W[] =
|
||||
{ 'S','e','S','y','n','c','A','g','e','n','t','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_ENABLE_DELEGATION_NAME_W[] =
|
||||
{ 'S','e','E','n','a','b','l','e','D','e','l','e','g','a','t','i','o','n','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_MANAGE_VOLUME_NAME_W[] =
|
||||
{ 'S','e','M','a','n','a','g','e','V','o','l','u','m','e','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_IMPERSONATE_NAME_W[] =
|
||||
{ 'S','e','I','m','p','e','r','s','o','n','a','t','e','P','r','i','v','i','l','e','g','e',0 };
|
||||
static const WCHAR SE_CREATE_GLOBAL_NAME_W[] =
|
||||
{ 'S','e','C','r','e','a','t','e','G','l','o','b','a','l','P','r','i','v','i','l','e','g','e',0 };
|
||||
|
||||
static const WCHAR * const WellKnownPrivNames[SE_MAX_WELL_KNOWN_PRIVILEGE + 1] =
|
||||
{
|
||||
NULL,
|
||||
NULL,
|
||||
SE_CREATE_TOKEN_NAME_W,
|
||||
SE_ASSIGNPRIMARYTOKEN_NAME_W,
|
||||
SE_LOCK_MEMORY_NAME_W,
|
||||
SE_INCREASE_QUOTA_NAME_W,
|
||||
SE_MACHINE_ACCOUNT_NAME_W,
|
||||
SE_TCB_NAME_W,
|
||||
SE_SECURITY_NAME_W,
|
||||
SE_TAKE_OWNERSHIP_NAME_W,
|
||||
SE_LOAD_DRIVER_NAME_W,
|
||||
SE_SYSTEM_PROFILE_NAME_W,
|
||||
SE_SYSTEMTIME_NAME_W,
|
||||
SE_PROF_SINGLE_PROCESS_NAME_W,
|
||||
SE_INC_BASE_PRIORITY_NAME_W,
|
||||
SE_CREATE_PAGEFILE_NAME_W,
|
||||
SE_CREATE_PERMANENT_NAME_W,
|
||||
SE_BACKUP_NAME_W,
|
||||
SE_RESTORE_NAME_W,
|
||||
SE_SHUTDOWN_NAME_W,
|
||||
SE_DEBUG_NAME_W,
|
||||
SE_AUDIT_NAME_W,
|
||||
SE_SYSTEM_ENVIRONMENT_NAME_W,
|
||||
SE_CHANGE_NOTIFY_NAME_W,
|
||||
SE_REMOTE_SHUTDOWN_NAME_W,
|
||||
SE_UNDOCK_NAME_W,
|
||||
SE_SYNC_AGENT_NAME_W,
|
||||
SE_ENABLE_DELEGATION_NAME_W,
|
||||
SE_MANAGE_VOLUME_NAME_W,
|
||||
SE_IMPERSONATE_NAME_W,
|
||||
SE_CREATE_GLOBAL_NAME_W,
|
||||
};
|
||||
|
||||
|
||||
/* Interface to ntmarta.dll ***************************************************/
|
||||
|
||||
NTMARTA NtMartaStatic = { 0 };
|
||||
|
@ -264,6 +360,31 @@ AreAnyAccessesGranted(DWORD GrantedAccess,
|
|||
}
|
||||
|
||||
|
||||
/************************************************************
|
||||
* ADVAPI_IsLocalComputer
|
||||
*
|
||||
* Checks whether the server name indicates local machine.
|
||||
*/
|
||||
BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName)
|
||||
{
|
||||
DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
|
||||
BOOL Result;
|
||||
LPWSTR buf;
|
||||
|
||||
if (!ServerName || !ServerName[0])
|
||||
return TRUE;
|
||||
|
||||
buf = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
|
||||
Result = GetComputerNameW(buf, &dwSize);
|
||||
if (Result && (ServerName[0] == '\\') && (ServerName[1] == '\\'))
|
||||
ServerName += 2;
|
||||
Result = Result && !lstrcmpW(ServerName, buf);
|
||||
HeapFree(GetProcessHeap(), 0, buf);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* GetFileSecurityA [ADVAPI32.@]
|
||||
*
|
||||
|
@ -1391,7 +1512,7 @@ LookupPrivilegeDisplayNameW(LPCWSTR lpSystemName,
|
|||
/**********************************************************************
|
||||
* LookupPrivilegeNameA EXPORTED
|
||||
*
|
||||
* @unimplemented
|
||||
* @implemented
|
||||
*/
|
||||
BOOL
|
||||
STDCALL
|
||||
|
@ -1449,18 +1570,44 @@ LookupPrivilegeNameA(LPCSTR lpSystemName,
|
|||
/**********************************************************************
|
||||
* LookupPrivilegeNameW EXPORTED
|
||||
*
|
||||
* @unimplemented
|
||||
* @implemented
|
||||
*/
|
||||
BOOL
|
||||
STDCALL
|
||||
LookupPrivilegeNameW(LPCWSTR lpSystemName,
|
||||
PLUID lpLuid,
|
||||
LPWSTR lpName,
|
||||
LPDWORD cbName)
|
||||
LPDWORD cchName)
|
||||
{
|
||||
FIXME("%s() not implemented!\n", __FUNCTION__);
|
||||
SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
size_t privNameLen;
|
||||
|
||||
TRACE("%s,%p,%p,%p\n",debugstr_w(lpSystemName), lpLuid, lpName, cchName);
|
||||
|
||||
if (!ADVAPI_IsLocalComputer(lpSystemName))
|
||||
{
|
||||
SetLastError(RPC_S_SERVER_UNAVAILABLE);
|
||||
return FALSE;
|
||||
}
|
||||
if (lpLuid->HighPart || (lpLuid->LowPart < SE_MIN_WELL_KNOWN_PRIVILEGE ||
|
||||
lpLuid->LowPart > SE_MAX_WELL_KNOWN_PRIVILEGE))
|
||||
{
|
||||
SetLastError(ERROR_NO_SUCH_PRIVILEGE);
|
||||
return FALSE;
|
||||
}
|
||||
privNameLen = strlenW(WellKnownPrivNames[lpLuid->LowPart]);
|
||||
/* Windows crashes if cchName is NULL, so will I */
|
||||
if (*cchName <= privNameLen)
|
||||
{
|
||||
*cchName = privNameLen + 1;
|
||||
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpyW(lpName, WellKnownPrivNames[lpLuid->LowPart]);
|
||||
*cchName = privNameLen;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -58,7 +58,13 @@ Author:
|
|||
#define SE_SYSTEM_ENVIRONMENT_PRIVILEGE (22L)
|
||||
#define SE_CHANGE_NOTIFY_PRIVILEGE (23L)
|
||||
#define SE_REMOTE_SHUTDOWN_PRIVILEGE (24L)
|
||||
#define SE_MAX_WELL_KNOWN_PRIVILEGE (SE_REMOTE_SHUTDOWN_PRIVILEGE)
|
||||
#define SE_UNDOCK_PRIVILEGE (25L)
|
||||
#define SE_SYNC_AGENT_PRIVILEGE (26L)
|
||||
#define SE_ENABLE_DELEGATION_PRIVILEGE (27L)
|
||||
#define SE_MANAGE_VOLUME_PRIVILEGE (28L)
|
||||
#define SE_IMPERSONATE_PRIVILEGE (29L)
|
||||
#define SE_CREATE_GLOBAL_PRIVILEGE (30L)
|
||||
#define SE_MAX_WELL_KNOWN_PRIVILEGE (SE_CREATE_GLOBAL_PRIVILEGE)
|
||||
|
||||
#else
|
||||
|
||||
|
|
Loading…
Reference in a new issue