Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
601c5a1a
Commit
601c5a1a
authored
Mar 05, 2014
by
Francois Gouget
Committed by
Alexandre Julliard
Mar 05, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msi/tests: Avoid msi test failures when running in an account with insufficient privileges.
parent
65bacd4b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
29 deletions
+82
-29
msi.c
dlls/msi/tests/msi.c
+82
-29
No files found.
dlls/msi/tests/msi.c
View file @
601c5a1a
...
@@ -42,6 +42,7 @@ static char PROG_FILES_DIR_NATIVE[MAX_PATH];
...
@@ -42,6 +42,7 @@ static char PROG_FILES_DIR_NATIVE[MAX_PATH];
static
char
COMMON_FILES_DIR
[
MAX_PATH
];
static
char
COMMON_FILES_DIR
[
MAX_PATH
];
static
char
WINDOWS_DIR
[
MAX_PATH
];
static
char
WINDOWS_DIR
[
MAX_PATH
];
static
BOOL
(
WINAPI
*
pCheckTokenMembership
)(
HANDLE
,
PSID
,
PBOOL
);
static
BOOL
(
WINAPI
*
pConvertSidToStringSidA
)(
PSID
,
LPSTR
*
);
static
BOOL
(
WINAPI
*
pConvertSidToStringSidA
)(
PSID
,
LPSTR
*
);
static
BOOL
(
WINAPI
*
pOpenProcessToken
)(
HANDLE
,
DWORD
,
PHANDLE
);
static
BOOL
(
WINAPI
*
pOpenProcessToken
)(
HANDLE
,
DWORD
,
PHANDLE
);
static
LONG
(
WINAPI
*
pRegDeleteKeyExA
)(
HKEY
,
LPCSTR
,
REGSAM
,
DWORD
);
static
LONG
(
WINAPI
*
pRegDeleteKeyExA
)(
HKEY
,
LPCSTR
,
REGSAM
,
DWORD
);
...
@@ -100,6 +101,7 @@ static void init_functionpointers(void)
...
@@ -100,6 +101,7 @@ static void init_functionpointers(void)
GET_PROC
(
hmsi
,
MsiEnumComponentsExA
)
GET_PROC
(
hmsi
,
MsiEnumComponentsExA
)
GET_PROC
(
hmsi
,
MsiSourceListGetInfoA
)
GET_PROC
(
hmsi
,
MsiSourceListGetInfoA
)
GET_PROC
(
hadvapi32
,
CheckTokenMembership
);
GET_PROC
(
hadvapi32
,
ConvertSidToStringSidA
)
GET_PROC
(
hadvapi32
,
ConvertSidToStringSidA
)
GET_PROC
(
hadvapi32
,
OpenProcessToken
);
GET_PROC
(
hadvapi32
,
OpenProcessToken
);
GET_PROC
(
hadvapi32
,
RegDeleteKeyExA
)
GET_PROC
(
hadvapi32
,
RegDeleteKeyExA
)
...
@@ -172,16 +174,38 @@ static BOOL delete_pf(const char *rel_path, BOOL is_file)
...
@@ -172,16 +174,38 @@ static BOOL delete_pf(const char *rel_path, BOOL is_file)
static
BOOL
is_process_limited
(
void
)
static
BOOL
is_process_limited
(
void
)
{
{
SID_IDENTIFIER_AUTHORITY
NtAuthority
=
{
SECURITY_NT_AUTHORITY
};
PSID
Group
;
BOOL
IsInGroup
;
HANDLE
token
;
HANDLE
token
;
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
)
{
/* Only administrators have enough privileges for these tests */
return
TRUE
;
}
if
(
pOpenProcessToken
(
GetCurrentProcess
(),
TOKEN_QUERY
,
&
token
))
{
BOOL
ret
;
TOKEN_ELEVATION_TYPE
type
=
TokenElevationTypeDefault
;
TOKEN_ELEVATION_TYPE
type
=
TokenElevationTypeDefault
;
DWORD
size
;
DWORD
size
;
BOOL
ret
;
if
(
!
pOpenProcessToken
)
return
FALSE
;
if
(
!
pOpenProcessToken
(
GetCurrentProcess
(),
TOKEN_QUERY
,
&
token
))
return
FALSE
;
ret
=
GetTokenInformation
(
token
,
TokenElevationType
,
&
type
,
sizeof
(
type
),
&
size
);
ret
=
GetTokenInformation
(
token
,
TokenElevationType
,
&
type
,
sizeof
(
type
),
&
size
);
CloseHandle
(
token
);
CloseHandle
(
token
);
return
(
ret
&&
type
==
TokenElevationTypeLimited
);
return
(
ret
&&
type
==
TokenElevationTypeLimited
);
}
return
FALSE
;
}
}
/* cabinet definitions */
/* cabinet definitions */
...
@@ -1690,6 +1714,7 @@ static void test_MsiQueryProductState(void)
...
@@ -1690,6 +1714,7 @@ static void test_MsiQueryProductState(void)
{
{
skip
(
"Not enough rights to perform tests
\n
"
);
skip
(
"Not enough rights to perform tests
\n
"
);
RegDeleteKeyA
(
userkey
,
""
);
RegDeleteKeyA
(
userkey
,
""
);
RegCloseKey
(
userkey
);
LocalFree
(
usersid
);
LocalFree
(
usersid
);
return
;
return
;
}
}
...
@@ -1724,6 +1749,14 @@ static void test_MsiQueryProductState(void)
...
@@ -1724,6 +1749,14 @@ static void test_MsiQueryProductState(void)
lstrcatA
(
keypath
,
prod_squashed
);
lstrcatA
(
keypath
,
prod_squashed
);
res
=
RegCreateKeyExA
(
HKEY_LOCAL_MACHINE
,
keypath
,
0
,
NULL
,
0
,
access
,
NULL
,
&
localkey
,
NULL
);
res
=
RegCreateKeyExA
(
HKEY_LOCAL_MACHINE
,
keypath
,
0
,
NULL
,
0
,
access
,
NULL
,
&
localkey
,
NULL
);
if
(
res
==
ERROR_ACCESS_DENIED
)
{
skip
(
"Not enough rights to perform tests
\n
"
);
RegDeleteKeyA
(
userkey
,
""
);
RegCloseKey
(
userkey
);
LocalFree
(
usersid
);
return
;
}
ok
(
res
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
res
);
ok
(
res
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
res
);
/* local product key exists */
/* local product key exists */
...
@@ -2560,6 +2593,12 @@ static void test_MsiQueryComponentState(void)
...
@@ -2560,6 +2593,12 @@ static void test_MsiQueryComponentState(void)
lstrcatA
(
keypath
,
"
\\
InstallProperties"
);
lstrcatA
(
keypath
,
"
\\
InstallProperties"
);
res
=
RegCreateKeyExA
(
HKEY_LOCAL_MACHINE
,
keypath
,
0
,
NULL
,
0
,
access
,
NULL
,
&
prodkey
,
NULL
);
res
=
RegCreateKeyExA
(
HKEY_LOCAL_MACHINE
,
keypath
,
0
,
NULL
,
0
,
access
,
NULL
,
&
prodkey
,
NULL
);
if
(
res
==
ERROR_ACCESS_DENIED
)
{
skip
(
"Not enough rights to perform tests
\n
"
);
LocalFree
(
usersid
);
return
;
}
ok
(
res
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
res
);
ok
(
res
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
res
);
/* local system product key exists */
/* local system product key exists */
...
@@ -10350,6 +10389,11 @@ static void test_MsiEnumPatchesEx_machine(void)
...
@@ -10350,6 +10389,11 @@ static void test_MsiEnumPatchesEx_machine(void)
lstrcatA
(
keypath
,
prod_squashed
);
lstrcatA
(
keypath
,
prod_squashed
);
res
=
RegCreateKeyExA
(
HKEY_LOCAL_MACHINE
,
keypath
,
0
,
NULL
,
0
,
access
,
NULL
,
&
udprod
,
NULL
);
res
=
RegCreateKeyExA
(
HKEY_LOCAL_MACHINE
,
keypath
,
0
,
NULL
,
0
,
access
,
NULL
,
&
udprod
,
NULL
);
if
(
res
==
ERROR_ACCESS_DENIED
)
{
skip
(
"Not enough rights to perform tests
\n
"
);
goto
done
;
}
ok
(
res
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
res
);
ok
(
res
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
res
);
/* local UserData product key exists */
/* local UserData product key exists */
...
@@ -10577,15 +10621,17 @@ static void test_MsiEnumPatchesEx_machine(void)
...
@@ -10577,15 +10621,17 @@ static void test_MsiEnumPatchesEx_machine(void)
"Expected targetsid to be unchanged, got %s
\n
"
,
targetsid
);
"Expected targetsid to be unchanged, got %s
\n
"
,
targetsid
);
ok
(
size
==
MAX_PATH
,
"Expected size to be unchanged, got %d
\n
"
,
size
);
ok
(
size
==
MAX_PATH
,
"Expected size to be unchanged, got %d
\n
"
,
size
);
delete_key
(
hpatch
,
""
,
access
&
KEY_WOW64_64KEY
);
RegCloseKey
(
hpatch
);
delete_key
(
udpatch
,
""
,
access
&
KEY_WOW64_64KEY
);
RegCloseKey
(
udpatch
);
done:
RegDeleteValueA
(
patches
,
patch_squashed
);
RegDeleteValueA
(
patches
,
patch_squashed
);
RegDeleteValueA
(
patches
,
"Patches"
);
RegDeleteValueA
(
patches
,
"Patches"
);
delete_key
(
patches
,
""
,
access
&
KEY_WOW64_64KEY
);
delete_key
(
patches
,
""
,
access
&
KEY_WOW64_64KEY
);
RegCloseKey
(
patches
);
RegCloseKey
(
patches
);
RegDeleteValueA
(
hpatch
,
"State"
);
RegDeleteValueA
(
hpatch
,
"State"
);
delete_key
(
hpatch
,
""
,
access
&
KEY_WOW64_64KEY
);
RegCloseKey
(
hpatch
);
delete_key
(
udpatch
,
""
,
access
&
KEY_WOW64_64KEY
);
RegCloseKey
(
udpatch
);
delete_key
(
udprod
,
""
,
access
&
KEY_WOW64_64KEY
);
delete_key
(
udprod
,
""
,
access
&
KEY_WOW64_64KEY
);
RegCloseKey
(
udprod
);
RegCloseKey
(
udprod
);
delete_key
(
prodkey
,
""
,
access
&
KEY_WOW64_64KEY
);
delete_key
(
prodkey
,
""
,
access
&
KEY_WOW64_64KEY
);
...
@@ -12665,6 +12711,11 @@ static void test_MsiGetPatchInfo(void)
...
@@ -12665,6 +12711,11 @@ static void test_MsiGetPatchInfo(void)
lstrcatA
(
keypath
,
prod_squashed
);
lstrcatA
(
keypath
,
prod_squashed
);
res
=
RegCreateKeyExA
(
HKEY_LOCAL_MACHINE
,
keypath
,
0
,
NULL
,
0
,
access
,
NULL
,
&
hkey_udproduct
,
NULL
);
res
=
RegCreateKeyExA
(
HKEY_LOCAL_MACHINE
,
keypath
,
0
,
NULL
,
0
,
access
,
NULL
,
&
hkey_udproduct
,
NULL
);
if
(
res
==
ERROR_ACCESS_DENIED
)
{
skip
(
"Not enough rights to perform tests
\n
"
);
goto
done
;
}
ok
(
res
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS got %d
\n
"
,
res
);
ok
(
res
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS got %d
\n
"
,
res
);
/* UserData product key exists */
/* UserData product key exists */
...
@@ -12756,18 +12807,20 @@ static void test_MsiGetPatchInfo(void)
...
@@ -12756,18 +12807,20 @@ static void test_MsiGetPatchInfo(void)
RegCloseKey
(
hkey_udproductpatches
);
RegCloseKey
(
hkey_udproductpatches
);
delete_key
(
hkey_udpatch
,
""
,
access
&
KEY_WOW64_64KEY
);
delete_key
(
hkey_udpatch
,
""
,
access
&
KEY_WOW64_64KEY
);
RegCloseKey
(
hkey_udpatch
);
RegCloseKey
(
hkey_udpatch
);
delete_key
(
hkey_patches
,
""
,
access
&
KEY_WOW64_64KEY
);
RegCloseKey
(
hkey_patches
);
delete_key
(
hkey_product
,
""
,
access
&
KEY_WOW64_64KEY
);
RegCloseKey
(
hkey_product
);
delete_key
(
hkey_patch
,
""
,
access
&
KEY_WOW64_64KEY
);
RegCloseKey
(
hkey_patch
);
delete_key
(
hkey_udpatches
,
""
,
access
&
KEY_WOW64_64KEY
);
delete_key
(
hkey_udpatches
,
""
,
access
&
KEY_WOW64_64KEY
);
RegCloseKey
(
hkey_udpatches
);
RegCloseKey
(
hkey_udpatches
);
delete_key
(
hkey_udprops
,
""
,
access
&
KEY_WOW64_64KEY
);
delete_key
(
hkey_udprops
,
""
,
access
&
KEY_WOW64_64KEY
);
RegCloseKey
(
hkey_udprops
);
RegCloseKey
(
hkey_udprops
);
delete_key
(
hkey_udproduct
,
""
,
access
&
KEY_WOW64_64KEY
);
delete_key
(
hkey_udproduct
,
""
,
access
&
KEY_WOW64_64KEY
);
RegCloseKey
(
hkey_udproduct
);
RegCloseKey
(
hkey_udproduct
);
done:
delete_key
(
hkey_patches
,
""
,
access
&
KEY_WOW64_64KEY
);
RegCloseKey
(
hkey_patches
);
delete_key
(
hkey_product
,
""
,
access
&
KEY_WOW64_64KEY
);
RegCloseKey
(
hkey_product
);
delete_key
(
hkey_patch
,
""
,
access
&
KEY_WOW64_64KEY
);
RegCloseKey
(
hkey_patch
);
}
}
static
void
test_MsiEnumProducts
(
void
)
static
void
test_MsiEnumProducts
(
void
)
...
@@ -12790,10 +12843,12 @@ static void test_MsiEnumProducts(void)
...
@@ -12790,10 +12843,12 @@ static void test_MsiEnumProducts(void)
if
(
is_wow64
)
if
(
is_wow64
)
access
|=
KEY_WOW64_64KEY
;
access
|=
KEY_WOW64_64KEY
;
strcpy
(
keypath1
,
"Software
\\
Classes
\\
Installer
\\
Products
\\
"
);
strcpy
(
keypath2
,
"Software
\\
Microsoft
\\
Windows
\\
CurrentVersion
\\
Installer
\\
Managed
\\
"
);
strcat
(
keypath1
,
product_squashed1
);
strcat
(
keypath2
,
usersid
);
strcat
(
keypath2
,
"
\\
Installer
\\
Products
\\
"
);
strcat
(
keypath2
,
product_squashed2
);
r
=
RegCreateKeyExA
(
HKEY_LOCAL_MACHINE
,
keypath
1
,
0
,
NULL
,
0
,
access
,
NULL
,
&
key1
,
NULL
);
r
=
RegCreateKeyExA
(
HKEY_LOCAL_MACHINE
,
keypath
2
,
0
,
NULL
,
0
,
access
,
NULL
,
&
key2
,
NULL
);
if
(
r
==
ERROR_ACCESS_DENIED
)
if
(
r
==
ERROR_ACCESS_DENIED
)
{
{
skip
(
"Not enough rights to perform tests
\n
"
);
skip
(
"Not enough rights to perform tests
\n
"
);
...
@@ -12802,12 +12857,10 @@ static void test_MsiEnumProducts(void)
...
@@ -12802,12 +12857,10 @@ static void test_MsiEnumProducts(void)
}
}
ok
(
r
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
r
);
ok
(
r
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
r
);
strcpy
(
keypath2
,
"Software
\\
Microsoft
\\
Windows
\\
CurrentVersion
\\
Installer
\\
Managed
\\
"
);
strcpy
(
keypath1
,
"Software
\\
Classes
\\
Installer
\\
Products
\\
"
);
strcat
(
keypath2
,
usersid
);
strcat
(
keypath1
,
product_squashed1
);
strcat
(
keypath2
,
"
\\
Installer
\\
Products
\\
"
);
strcat
(
keypath2
,
product_squashed2
);
r
=
RegCreateKeyExA
(
HKEY_LOCAL_MACHINE
,
keypath
2
,
0
,
NULL
,
0
,
access
,
NULL
,
&
key2
,
NULL
);
r
=
RegCreateKeyExA
(
HKEY_LOCAL_MACHINE
,
keypath
1
,
0
,
NULL
,
0
,
access
,
NULL
,
&
key1
,
NULL
);
ok
(
r
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
r
);
ok
(
r
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
r
);
strcpy
(
keypath3
,
"Software
\\
Microsoft
\\
Installer
\\
Products
\\
"
);
strcpy
(
keypath3
,
"Software
\\
Microsoft
\\
Installer
\\
Products
\\
"
);
...
@@ -12921,10 +12974,12 @@ static void test_MsiEnumProductsEx(void)
...
@@ -12921,10 +12974,12 @@ static void test_MsiEnumProductsEx(void)
if
(
is_wow64
)
access
|=
KEY_WOW64_64KEY
;
if
(
is_wow64
)
access
|=
KEY_WOW64_64KEY
;
strcpy
(
keypath1
,
"Software
\\
Classes
\\
Installer
\\
Products
\\
"
);
strcpy
(
keypath2
,
"Software
\\
Microsoft
\\
Windows
\\
CurrentVersion
\\
Installer
\\
Managed
\\
"
);
strcat
(
keypath1
,
product_squashed1
);
strcat
(
keypath2
,
usersid
);
strcat
(
keypath2
,
"
\\
Installer
\\
Products
\\
"
);
strcat
(
keypath2
,
product_squashed2
);
r
=
RegCreateKeyExA
(
HKEY_LOCAL_MACHINE
,
keypath
1
,
0
,
NULL
,
0
,
access
,
NULL
,
&
key1
,
NULL
);
r
=
RegCreateKeyExA
(
HKEY_LOCAL_MACHINE
,
keypath
2
,
0
,
NULL
,
0
,
access
,
NULL
,
&
key2
,
NULL
);
if
(
r
==
ERROR_ACCESS_DENIED
)
if
(
r
==
ERROR_ACCESS_DENIED
)
{
{
skip
(
"insufficient rights
\n
"
);
skip
(
"insufficient rights
\n
"
);
...
@@ -12932,12 +12987,10 @@ static void test_MsiEnumProductsEx(void)
...
@@ -12932,12 +12987,10 @@ static void test_MsiEnumProductsEx(void)
}
}
ok
(
r
==
ERROR_SUCCESS
,
"got %u
\n
"
,
r
);
ok
(
r
==
ERROR_SUCCESS
,
"got %u
\n
"
,
r
);
strcpy
(
keypath2
,
"Software
\\
Microsoft
\\
Windows
\\
CurrentVersion
\\
Installer
\\
Managed
\\
"
);
strcpy
(
keypath1
,
"Software
\\
Classes
\\
Installer
\\
Products
\\
"
);
strcat
(
keypath2
,
usersid
);
strcat
(
keypath1
,
product_squashed1
);
strcat
(
keypath2
,
"
\\
Installer
\\
Products
\\
"
);
strcat
(
keypath2
,
product_squashed2
);
r
=
RegCreateKeyExA
(
HKEY_LOCAL_MACHINE
,
keypath
2
,
0
,
NULL
,
0
,
access
,
NULL
,
&
key2
,
NULL
);
r
=
RegCreateKeyExA
(
HKEY_LOCAL_MACHINE
,
keypath
1
,
0
,
NULL
,
0
,
access
,
NULL
,
&
key1
,
NULL
);
ok
(
r
==
ERROR_SUCCESS
,
"got %u
\n
"
,
r
);
ok
(
r
==
ERROR_SUCCESS
,
"got %u
\n
"
,
r
);
strcpy
(
keypath3
,
usersid
);
strcpy
(
keypath3
,
usersid
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment