Francois Gouget : fsutils/tests: Fsutils requires elevated privileges on Windows <= 7.

Alexandre Julliard julliard at winehq.org
Wed Dec 2 15:21:07 CST 2020


Module: wine
Branch: master
Commit: fe719e16a4d3a8fbaebd8c6ed6919a4af63cde3b
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=fe719e16a4d3a8fbaebd8c6ed6919a4af63cde3b

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Wed Dec  2 06:34:04 2020 +0100

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 <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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");




More information about the wine-cvs mailing list