This means skipping any test that requires creating a task as the test would be unable to clean up after itself.
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=52193 Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=54634 ---- taskschd:scheduler is able to delete folders without elevated privileges on Windows 8 but apparently not schtasks.exe:schtasks. There must be something different but I don't know what :-( I guess we don't care much about this special case so this patch just skips bluntly.
From: Francois Gouget fgouget@codeweavers.com
This means skipping any test that requires creating a task as the test would be unable to clean up after itself.
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=52193 Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=54634 ---- taskschd:scheduler is able to delete folders without elevated privileges on Windows 8 but apparently not schtasks.exe:schtasks. There must be something different but I don't know what :-( I guess we don't care much about this special case so this patch just skips bluntly. --- programs/schtasks/tests/Makefile.in | 2 +- programs/schtasks/tests/schtasks.c | 40 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/programs/schtasks/tests/Makefile.in b/programs/schtasks/tests/Makefile.in index dcf641c4b13..424f9a294d1 100644 --- a/programs/schtasks/tests/Makefile.in +++ b/programs/schtasks/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = schtasks.exe -IMPORTS = ole32 +IMPORTS = advapi32 ole32
C_SRCS = \ diff --git a/programs/schtasks/tests/schtasks.c b/programs/schtasks/tests/schtasks.c index c1168d4b209..238dc3bdc16 100644 --- a/programs/schtasks/tests/schtasks.c +++ b/programs/schtasks/tests/schtasks.c @@ -16,8 +16,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#include <stdarg.h> + #define COBJMACROS
+#include "winternl.h" #include "initguid.h" #include "taskschd.h"
@@ -58,6 +61,37 @@ static WCHAR *a2w(const char *str) return ret; }
+static BOOL is_process_elevated(void) +{ + HANDLE token; + if (OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY, &token )) + { + TOKEN_ELEVATION_TYPE type; + DWORD size; + BOOL ret; + + ret = GetTokenInformation( token, TokenElevationType, &type, sizeof(type), &size ); + CloseHandle( token ); + return (ret && type == TokenElevationTypeFull); + } + return FALSE; +} + +static BOOL check_win_version(int min_major, int min_minor) +{ + HMODULE hntdll = GetModuleHandleA("ntdll.dll"); + NTSTATUS (WINAPI *pRtlGetVersion)(RTL_OSVERSIONINFOEXW *); + RTL_OSVERSIONINFOEXW rtlver; + + rtlver.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW); + pRtlGetVersion = (void *)GetProcAddress(hntdll, "RtlGetVersion"); + pRtlGetVersion(&rtlver); + return rtlver.dwMajorVersion > min_major || + (rtlver.dwMajorVersion == min_major && + rtlver.dwMinorVersion >= min_minor); +} +#define is_win10_plus() check_win_version(10, 0) + #define run_command(a) _run_command(__LINE__,a) static DWORD _run_command(unsigned line, const char *cmd) { @@ -173,6 +207,12 @@ START_TEST(schtasks) static WCHAR wine_testW[] = L"\wine\test"; DWORD r;
+ if (!is_process_elevated() && !is_win10_plus()) + { + win_skip("Deleting the test folders requires elevated privileges on Windows <= 8\n"); + return; + } + CoInitialize(NULL); if(!initialize_task_service()) { CoUninitialize();
From: Francois Gouget fgouget@codeweavers.com
--- programs/schtasks/tests/schtasks.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/programs/schtasks/tests/schtasks.c b/programs/schtasks/tests/schtasks.c index 238dc3bdc16..3ed2378c90c 100644 --- a/programs/schtasks/tests/schtasks.c +++ b/programs/schtasks/tests/schtasks.c @@ -266,8 +266,10 @@ START_TEST(schtasks) r = DeleteFileA("test.xml"); ok(r, "DeleteFileA failed: %lu\n", GetLastError());
- ITaskFolder_DeleteFolder(root, wine_testW, 0); - ITaskFolder_DeleteFolder(root, wineW, 0); + r = ITaskFolder_DeleteFolder(root, wine_testW, 0); + ok(r == S_OK, "DeleteFolder(\wine\test) failed: %lx\n", r); + r = ITaskFolder_DeleteFolder(root, wineW, 0); + ok(r == S_OK, "DeleteFolder(\wine) failed: %lx\n", r);
ITaskFolder_Release(root); ITaskService_Release(service);