1
0
mirror of https://github.com/wine-mirror/wine synced 2024-07-08 03:45:57 +00:00

schedsvc/tests: Deleting tasks & folders requires elevated privileges on Windows 7.

This means skipping any test that requires creating a folder as the
test would be unable to clean up after itself.

Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=53128
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=54109
This commit is contained in:
Francois Gouget 2023-03-26 17:59:04 +02:00 committed by Alexandre Julliard
parent 4385a3c29e
commit bb516ae1a6
2 changed files with 39 additions and 1 deletions

View File

@ -1,5 +1,5 @@
TESTDLL = schedsvc.dll
IMPORTS = rpcrt4 ole32
IMPORTS = advapi32 rpcrt4 ole32
C_SRCS = \
atsvcapi.c \

View File

@ -18,6 +18,7 @@
#include <stdio.h>
#include <windows.h>
#include "winternl.h"
#include <ole2.h>
#include <rpcdce.h>
#include <taskschd.h>
@ -25,6 +26,37 @@
#include "wine/test.h"
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_win8_plus() check_win_version(6, 2)
extern handle_t schrpc_handle;
static LONG CALLBACK rpc_exception_filter(EXCEPTION_POINTERS *ptrs)
@ -143,6 +175,12 @@ START_TEST(rpcapi)
hr = SchRpcDelete(L"", 0);
ok(hr == E_ACCESSDENIED /* win7 */ || hr == E_INVALIDARG /* vista */, "expected E_ACCESSDENIED, got %#lx\n", hr);
if (!is_process_elevated() && !is_win8_plus())
{
win_skip("Skipping because deleting anything requires elevated privileges on Windows 7\n");
return;
}
hr = SchRpcCreateFolder(L"\\Wine", NULL, 0);
ok(hr == S_OK, "expected S_OK, got %#lx\n", hr);