Finally reenable RtlAcquirePrivilege and RtlReleasePrivilege now that they are fixed.

[KERNEL32]
Remove the hacks in SetSystemTime() and SetLocalTime() now that RtlAcquirePrivilege is working properly.

[SYSSETUP]
Remove the hack for privileges in SetSystemLocalTime() now that SetLocalTime() can properly acquire needed privilege.

CORE-7168 #comment Fixed with r58960 #resolve

svn path=/trunk/; revision=58960
This commit is contained in:
Pierre Schweitzer 2013-05-05 22:31:17 +00:00
parent be5914df2f
commit 567881b593
3 changed files with 4 additions and 67 deletions

View file

@ -384,11 +384,6 @@ SetLocalTime(IN CONST SYSTEMTIME *lpSystemTime)
Status = NtSetSystemTime(&NewSystemTime, NULL); Status = NtSetSystemTime(&NewSystemTime, NULL);
RtlReleasePrivilege(State); RtlReleasePrivilege(State);
} }
else
{
DPRINT1("HACK: Workaround RtlAcquirePrivilege failure! Remove me once RAP is fine\n");
Status = NtSetSystemTime(&NewSystemTime, NULL);
}
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -432,11 +427,6 @@ SetSystemTime(IN CONST SYSTEMTIME *lpSystemTime)
Status = NtSetSystemTime(&NewSystemTime, NULL); Status = NtSetSystemTime(&NewSystemTime, NULL);
RtlReleasePrivilege(State); RtlReleasePrivilege(State);
} }
else
{
DPRINT1("HACK: Workaround RtlAcquirePrivilege failure! Remove me once RAP is fine\n");
Status = NtSetSystemTime(&NewSystemTime, NULL);
}
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {

View file

@ -1374,57 +1374,13 @@ SetAutoDaylightInfo(HWND hwnd)
static BOOL static BOOL
SetSystemLocalTime(HWND hwnd, PSETUPDATA SetupData) SetSystemLocalTime(HWND hwnd, PSETUPDATA SetupData)
{ {
HANDLE hToken;
DWORD PrevSize;
TOKEN_PRIVILEGES priv, previouspriv;
BOOL Ret = FALSE; BOOL Ret = FALSE;
/* /*
* enable the SeSystemtimePrivilege privilege * Call SetLocalTime twice to ensure correct results
*/ */
Ret = SetLocalTime(&SetupData->SystemTime) &&
if(OpenProcessToken(GetCurrentProcess(), SetLocalTime(&SetupData->SystemTime);
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
&hToken))
{
priv.PrivilegeCount = 1;
priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if(LookupPrivilegeValue(NULL,
SE_SYSTEMTIME_NAME,
&priv.Privileges[0].Luid))
{
if(AdjustTokenPrivileges(hToken,
FALSE,
&priv,
sizeof(previouspriv),
&previouspriv,
&PrevSize) &&
GetLastError() == ERROR_SUCCESS)
{
/*
* We successfully enabled it, we're permitted to change the system time
* Call SetLocalTime twice to ensure correct results
*/
Ret = SetLocalTime(&SetupData->SystemTime) &&
SetLocalTime(&SetupData->SystemTime);
/*
* for the sake of security, restore the previous status again
*/
if(previouspriv.PrivilegeCount > 0)
{
AdjustTokenPrivileges(hToken,
FALSE,
&previouspriv,
0,
NULL,
0);
}
}
}
CloseHandle(hToken);
}
return Ret; return Ret;
} }

View file

@ -11,7 +11,7 @@
#include <rtl.h> #include <rtl.h>
//#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
@ -112,7 +112,6 @@ RtlAcquirePrivilege(IN PULONG Privilege,
IN ULONG Flags, IN ULONG Flags,
OUT PVOID *ReturnedState) OUT PVOID *ReturnedState)
{ {
#if 0
PRTL_ACQUIRE_STATE State; PRTL_ACQUIRE_STATE State;
NTSTATUS Status, IntStatus; NTSTATUS Status, IntStatus;
ULONG ReturnLength, i, OldSize; ULONG ReturnLength, i, OldSize;
@ -354,10 +353,6 @@ Cleanup:
DPRINT("RtlAcquirePrivilege() failed with status: %lx\n", Status); DPRINT("RtlAcquirePrivilege() failed with status: %lx\n", Status);
return Status; return Status;
#else
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
#endif
} }
/* /*
@ -367,7 +362,6 @@ VOID
NTAPI NTAPI
RtlReleasePrivilege(IN PVOID ReturnedState) RtlReleasePrivilege(IN PVOID ReturnedState)
{ {
#if 0
NTSTATUS Status; NTSTATUS Status;
PRTL_ACQUIRE_STATE State = (PRTL_ACQUIRE_STATE)ReturnedState; PRTL_ACQUIRE_STATE State = (PRTL_ACQUIRE_STATE)ReturnedState;
@ -408,9 +402,6 @@ RtlReleasePrivilege(IN PVOID ReturnedState)
/* Release token and free state */ /* Release token and free state */
ZwClose(State->Token); ZwClose(State->Token);
RtlFreeHeap(RtlGetProcessHeap(), 0, State); RtlFreeHeap(RtlGetProcessHeap(), 0, State);
#else
UNIMPLEMENTED;
#endif
} }
/* /*