msi/tests: Skip some package tests if in a non-administrator, non-power user account.
Francois Gouget
fgouget at codeweavers.com
Wed Mar 5 04:14:10 CST 2014
---
This should fix the test failures on fg-win2000-susr, fg-winxp-lusr and
half the test failures of fg-win2000-rusr.
The first remaining test failure happen in test_appsearch_inilocator()
and involve MsiGetPropertyA() not returning the expected values which I
believe means a previous command failed but went undetected. This will
likely require a more expert look into it.
dlls/msi/tests/package.c | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c
index d8728f2..40ec71d 100644
--- a/dlls/msi/tests/package.c
+++ b/dlls/msi/tests/package.c
@@ -41,6 +41,7 @@ static UINT (WINAPI *pMsiApplyMultiplePatchesA)(LPCSTR, LPCSTR, LPCSTR);
static INSTALLSTATE (WINAPI *pMsiGetComponentPathExA)(LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPSTR, LPDWORD);
static HRESULT (WINAPI *pSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR);
+static BOOL (WINAPI *pCheckTokenMembership)(HANDLE,PSID,PBOOL);
static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
static BOOL (WINAPI *pOpenProcessToken)( HANDLE, DWORD, PHANDLE );
static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD);
@@ -68,6 +69,7 @@ static void init_functionpointers(void)
GET_PROC(hmsi, MsiGetComponentPathExA);
GET_PROC(hshell32, SHGetFolderPathA);
+ GET_PROC(hadvapi32, CheckTokenMembership);
GET_PROC(hadvapi32, ConvertSidToStringSidA);
GET_PROC(hadvapi32, OpenProcessToken);
GET_PROC(hadvapi32, RegDeleteKeyExA)
@@ -85,9 +87,38 @@ static void init_functionpointers(void)
static BOOL is_process_limited(void)
{
+ SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
+ PSID Group;
+ BOOL IsInGroup;
HANDLE token;
- if (!pOpenProcessToken) return FALSE;
+ if (!pCheckTokenMembership || !pOpenProcessToken) return FALSE;
+
+ if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID,
+ DOMAIN_ALIAS_RID_ADMINS,
+ 0, 0, 0, 0, 0, 0, &Group) ||
+ !pCheckTokenMembership(NULL, Group, &IsInGroup))
+ {
+ trace("Could not check if the current user is an administrator\n");
+ return FALSE;
+ }
+ if (!IsInGroup)
+ {
+ if (!AllocateAndInitializeSid(&NtAuthority, 2,
+ SECURITY_BUILTIN_DOMAIN_RID,
+ DOMAIN_ALIAS_RID_POWER_USERS,
+ 0, 0, 0, 0, 0, 0, &Group) ||
+ !pCheckTokenMembership(NULL, Group, &IsInGroup))
+ {
+ trace("Could not check if the current user is a power user\n");
+ return FALSE;
+ }
+ if (!IsInGroup)
+ {
+ /* Only administrators and power users can be powerful */
+ return TRUE;
+ }
+ }
if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
{
--
1.8.5.3
More information about the wine-patches
mailing list