From 567881b5938047663f74b09bc1b521755ca665e3 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 5 May 2013 22:31:17 +0000 Subject: [PATCH] [RTL] 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 --- reactos/dll/win32/kernel32/client/time.c | 10 ----- reactos/dll/win32/syssetup/wizard.c | 50 ++---------------------- reactos/lib/rtl/priv.c | 11 +----- 3 files changed, 4 insertions(+), 67 deletions(-) diff --git a/reactos/dll/win32/kernel32/client/time.c b/reactos/dll/win32/kernel32/client/time.c index c9669fa5d30..8a6835cb8d5 100644 --- a/reactos/dll/win32/kernel32/client/time.c +++ b/reactos/dll/win32/kernel32/client/time.c @@ -384,11 +384,6 @@ SetLocalTime(IN CONST SYSTEMTIME *lpSystemTime) Status = NtSetSystemTime(&NewSystemTime, NULL); RtlReleasePrivilege(State); } - else - { - DPRINT1("HACK: Workaround RtlAcquirePrivilege failure! Remove me once RAP is fine\n"); - Status = NtSetSystemTime(&NewSystemTime, NULL); - } if (!NT_SUCCESS(Status)) { @@ -432,11 +427,6 @@ SetSystemTime(IN CONST SYSTEMTIME *lpSystemTime) Status = NtSetSystemTime(&NewSystemTime, NULL); RtlReleasePrivilege(State); } - else - { - DPRINT1("HACK: Workaround RtlAcquirePrivilege failure! Remove me once RAP is fine\n"); - Status = NtSetSystemTime(&NewSystemTime, NULL); - } if (!NT_SUCCESS(Status)) { diff --git a/reactos/dll/win32/syssetup/wizard.c b/reactos/dll/win32/syssetup/wizard.c index f1caf2ac4a7..ff181e34bce 100644 --- a/reactos/dll/win32/syssetup/wizard.c +++ b/reactos/dll/win32/syssetup/wizard.c @@ -1374,57 +1374,13 @@ SetAutoDaylightInfo(HWND hwnd) static BOOL SetSystemLocalTime(HWND hwnd, PSETUPDATA SetupData) { - HANDLE hToken; - DWORD PrevSize; - TOKEN_PRIVILEGES priv, previouspriv; BOOL Ret = FALSE; /* - * enable the SeSystemtimePrivilege privilege + * Call SetLocalTime twice to ensure correct results */ - - if(OpenProcessToken(GetCurrentProcess(), - 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); - } + Ret = SetLocalTime(&SetupData->SystemTime) && + SetLocalTime(&SetupData->SystemTime); return Ret; } diff --git a/reactos/lib/rtl/priv.c b/reactos/lib/rtl/priv.c index 5021966d45c..5d925af85bb 100644 --- a/reactos/lib/rtl/priv.c +++ b/reactos/lib/rtl/priv.c @@ -11,7 +11,7 @@ #include -//#define NDEBUG +#define NDEBUG #include /* FUNCTIONS ***************************************************************/ @@ -112,7 +112,6 @@ RtlAcquirePrivilege(IN PULONG Privilege, IN ULONG Flags, OUT PVOID *ReturnedState) { -#if 0 PRTL_ACQUIRE_STATE State; NTSTATUS Status, IntStatus; ULONG ReturnLength, i, OldSize; @@ -354,10 +353,6 @@ Cleanup: DPRINT("RtlAcquirePrivilege() failed with status: %lx\n", Status); return Status; -#else - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; -#endif } /* @@ -367,7 +362,6 @@ VOID NTAPI RtlReleasePrivilege(IN PVOID ReturnedState) { -#if 0 NTSTATUS Status; PRTL_ACQUIRE_STATE State = (PRTL_ACQUIRE_STATE)ReturnedState; @@ -408,9 +402,6 @@ RtlReleasePrivilege(IN PVOID ReturnedState) /* Release token and free state */ ZwClose(State->Token); RtlFreeHeap(RtlGetProcessHeap(), 0, State); -#else - UNIMPLEMENTED; -#endif } /*