Commit 3103adb6 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

winetest: Elevate test processes on Wine.

parent 4860be47
...@@ -687,6 +687,21 @@ extract_test (struct wine_test *test, const char *dir, LPSTR res_name) ...@@ -687,6 +687,21 @@ extract_test (struct wine_test *test, const char *dir, LPSTR res_name)
CloseHandle(hfile); CloseHandle(hfile);
} }
static HANDLE get_admin_token(void)
{
TOKEN_ELEVATION_TYPE type;
TOKEN_LINKED_TOKEN linked;
DWORD size;
if (!GetTokenInformation(GetCurrentThreadEffectiveToken(), TokenElevationType, &type, sizeof(type), &size)
|| type == TokenElevationTypeFull)
return NULL;
if (!GetTokenInformation(GetCurrentThreadEffectiveToken(), TokenLinkedToken, &linked, sizeof(linked), &size))
return NULL;
return linked.LinkedToken;
}
static DWORD wait_process( HANDLE process, DWORD timeout ) static DWORD wait_process( HANDLE process, DWORD timeout )
{ {
DWORD wait, diff = 0, start = GetTickCount(); DWORD wait, diff = 0, start = GetTickCount();
...@@ -722,6 +737,7 @@ run_ex (char *cmd, HANDLE out_file, const char *tempdir, DWORD ms, BOOL nocritic ...@@ -722,6 +737,7 @@ run_ex (char *cmd, HANDLE out_file, const char *tempdir, DWORD ms, BOOL nocritic
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
DWORD wait, status, flags; DWORD wait, status, flags;
UINT old_errmode; UINT old_errmode;
HANDLE token = NULL;
GetStartupInfoA (&si); GetStartupInfoA (&si);
si.dwFlags = STARTF_USESTDHANDLES; si.dwFlags = STARTF_USESTDHANDLES;
...@@ -737,8 +753,16 @@ run_ex (char *cmd, HANDLE out_file, const char *tempdir, DWORD ms, BOOL nocritic ...@@ -737,8 +753,16 @@ run_ex (char *cmd, HANDLE out_file, const char *tempdir, DWORD ms, BOOL nocritic
else else
flags = CREATE_DEFAULT_ERROR_MODE; flags = CREATE_DEFAULT_ERROR_MODE;
if (!CreateProcessA (NULL, cmd, NULL, NULL, TRUE, flags, /* Some tests cause a UAC prompt on Windows if the user is not elevated,
NULL, tempdir, &si, &pi)) * so to allow them to run unattended the relevant test units need to skip
* the tests if so.
*
* However, we still want Wine to run as many tests as possible, so always
* elevate ourselves. On Wine elevation isn't interactive. */
if (running_under_wine())
token = get_admin_token();
if (!CreateProcessAsUserA(token, NULL, cmd, NULL, NULL, TRUE, flags, NULL, tempdir, &si, &pi))
{ {
if (nocritical) SetErrorMode(old_errmode); if (nocritical) SetErrorMode(old_errmode);
if (pid) *pid = 0; if (pid) *pid = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment