From fe719e16a4d3a8fbaebd8c6ed6919a4af63cde3b Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Wed, 2 Dec 2020 06:34:04 +0100 Subject: [PATCH] fsutils/tests: Fsutils requires elevated privileges on Windows <= 7. So skip the tests if the first fsutils run fails and we don't have elevated privileges. Signed-off-by: Francois Gouget Signed-off-by: Alexandre Julliard --- programs/fsutil/tests/Makefile.in | 2 +- programs/fsutil/tests/fsutil.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/programs/fsutil/tests/Makefile.in b/programs/fsutil/tests/Makefile.in index 5a69e47dc61..f0490b3b660 100644 --- a/programs/fsutil/tests/Makefile.in +++ b/programs/fsutil/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = fsutil.exe -IMPORTS = user32 +IMPORTS = advapi32 user32 C_SRCS = \ fsutil.c diff --git a/programs/fsutil/tests/fsutil.c b/programs/fsutil/tests/fsutil.c index 1111b5b2fed..eff47a4f8ec 100644 --- a/programs/fsutil/tests/fsutil.c +++ b/programs/fsutil/tests/fsutil.c @@ -21,6 +21,22 @@ #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 DWORD runcmd(const char* cmd) { STARTUPINFOA si = { sizeof(STARTUPINFOA) }; @@ -64,6 +80,11 @@ static void test_hardlink(void) CloseHandle(hfile); rc = runcmd("fsutil"); + if (rc == 1 && !is_process_elevated()) + { + win_skip("Cannot run fsutil without elevated privileges on Windows <= 7\n"); + return; + } ok(rc == 0, "failed to run fsutil\n"); rc = runcmd("fsutil hardlink");