advapi32/tests: Account for limited users in registry test.
This commit is contained in:
parent
fa8d59c30b
commit
8340636c55
|
@ -48,6 +48,8 @@ static NTSTATUS (WINAPI * pNtDeleteKey)(HANDLE);
|
|||
static NTSTATUS (WINAPI * pRtlFormatCurrentUserKeyPath)(UNICODE_STRING*);
|
||||
static NTSTATUS (WINAPI * pRtlFreeUnicodeString)(PUNICODE_STRING);
|
||||
|
||||
static BOOL limited_user;
|
||||
|
||||
|
||||
/* Debugging functions from wine/libs/wine/debug.c */
|
||||
|
||||
|
@ -170,6 +172,26 @@ static void setup_main_key(void)
|
|||
assert (!RegCreateKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Test", &hkey_main ));
|
||||
}
|
||||
|
||||
static void check_user_privs(void)
|
||||
{
|
||||
DWORD ret;
|
||||
HKEY hkey = (HKEY)0xdeadbeef;
|
||||
|
||||
ret = RegOpenKeyExA( HKEY_LOCAL_MACHINE, "Software", 0, KEY_READ|KEY_WRITE, &hkey);
|
||||
ok(ret == ERROR_SUCCESS || ret == ERROR_ACCESS_DENIED, "expected success or access denied, got %i\n", ret);
|
||||
if (ret == ERROR_SUCCESS)
|
||||
{
|
||||
ok(hkey != NULL, "RegOpenKeyExA succeeded but returned NULL hkey\n");
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
else
|
||||
{
|
||||
ok(hkey == NULL, "RegOpenKeyExA failed but returned hkey %p\n", hkey);
|
||||
limited_user = TRUE;
|
||||
trace("running as limited user\n");
|
||||
}
|
||||
}
|
||||
|
||||
#define lok ok_(__FILE__, line)
|
||||
#define test_hkey_main_Value_A(name, string, full_byte_len) _test_hkey_main_Value_A(__LINE__, name, string, full_byte_len)
|
||||
static void _test_hkey_main_Value_A(int line, LPCSTR name, LPCSTR string,
|
||||
|
@ -997,11 +1019,19 @@ static void test_reg_open_key(void)
|
|||
|
||||
ret = RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine", 0, NULL, 0,
|
||||
KEY_WOW64_32KEY | KEY_ALL_ACCESS, NULL, &hkRoot32, NULL);
|
||||
if (limited_user)
|
||||
ok(ret == ERROR_ACCESS_DENIED && hkRoot32 == NULL,
|
||||
"RegCreateKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret);
|
||||
else
|
||||
ok(ret == ERROR_SUCCESS && hkRoot32 != NULL,
|
||||
"RegCreateKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret);
|
||||
|
||||
ret = RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine", 0, NULL, 0,
|
||||
KEY_WOW64_64KEY | KEY_ALL_ACCESS, NULL, &hkRoot64, NULL);
|
||||
if (limited_user)
|
||||
ok(ret == ERROR_ACCESS_DENIED && hkRoot64 == NULL,
|
||||
"RegCreateKeyEx with KEY_WOW64_64KEY failed (err=%u)\n", ret);
|
||||
else
|
||||
ok(ret == ERROR_SUCCESS && hkRoot64 != NULL,
|
||||
"RegCreateKeyEx with KEY_WOW64_64KEY failed (err=%u)\n", ret);
|
||||
|
||||
|
@ -1032,6 +1062,12 @@ static void test_reg_open_key(void)
|
|||
ok(bRet == TRUE,
|
||||
"Expected SetSecurityDescriptorDacl to return TRUE, got %d, last error %u\n", bRet, GetLastError());
|
||||
|
||||
if (limited_user)
|
||||
{
|
||||
skip("not enough privileges to modify HKLM\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The "sanctioned" methods of setting a registry ACL aren't implemented in Wine. */
|
||||
bRet = SetKernelObjectSecurity(hkRoot64, DACL_SECURITY_INFORMATION, sd);
|
||||
ok(bRet == TRUE,
|
||||
|
@ -1052,6 +1088,7 @@ static void test_reg_open_key(void)
|
|||
ok(ret == ERROR_SUCCESS && hkResult != NULL,
|
||||
"RegOpenKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret);
|
||||
RegCloseKey(hkResult);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, sd);
|
||||
LocalFree(key_acl);
|
||||
|
@ -1143,11 +1180,19 @@ static void test_reg_create_key(void)
|
|||
|
||||
ret = RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine", 0, NULL, 0,
|
||||
KEY_WOW64_32KEY | KEY_ALL_ACCESS, NULL, &hkRoot32, NULL);
|
||||
if (limited_user)
|
||||
ok(ret == ERROR_ACCESS_DENIED && hkRoot32 == NULL,
|
||||
"RegCreateKeyEx with KEY_WOW64_32KEY failed (err=%d)\n", ret);
|
||||
else
|
||||
ok(ret == ERROR_SUCCESS && hkRoot32 != NULL,
|
||||
"RegCreateKeyEx with KEY_WOW64_32KEY failed (err=%d)\n", ret);
|
||||
|
||||
ret = RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine", 0, NULL, 0,
|
||||
KEY_WOW64_64KEY | KEY_ALL_ACCESS, NULL, &hkRoot64, NULL);
|
||||
if (limited_user)
|
||||
ok(ret == ERROR_ACCESS_DENIED && hkRoot64 == NULL,
|
||||
"RegCreateKeyEx with KEY_WOW64_64KEY failed (err=%d)\n", ret);
|
||||
else
|
||||
ok(ret == ERROR_SUCCESS && hkRoot64 != NULL,
|
||||
"RegCreateKeyEx with KEY_WOW64_64KEY failed (err=%d)\n", ret);
|
||||
|
||||
|
@ -1166,7 +1211,7 @@ static void test_reg_create_key(void)
|
|||
access.Trustee.ptstrName = (char *)world_sid;
|
||||
|
||||
dwRet = SetEntriesInAclA(1, &access, NULL, &key_acl);
|
||||
ok(ret == ERROR_SUCCESS,
|
||||
ok(dwRet == ERROR_SUCCESS,
|
||||
"Expected SetEntriesInAclA to return ERROR_SUCCESS, got %u, last error %u\n", dwRet, GetLastError());
|
||||
|
||||
sd = HeapAlloc(GetProcessHeap(), 0, SECURITY_DESCRIPTOR_MIN_LENGTH);
|
||||
|
@ -1178,6 +1223,12 @@ static void test_reg_create_key(void)
|
|||
ok(bRet == TRUE,
|
||||
"Expected SetSecurityDescriptorDacl to return TRUE, got %d, last error %u\n", bRet, GetLastError());
|
||||
|
||||
if (limited_user)
|
||||
{
|
||||
skip("not enough privileges to modify HKLM\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The "sanctioned" methods of setting a registry ACL aren't implemented in Wine. */
|
||||
bRet = SetKernelObjectSecurity(hkRoot64, DACL_SECURITY_INFORMATION, sd);
|
||||
ok(bRet == TRUE,
|
||||
|
@ -1200,6 +1251,7 @@ static void test_reg_create_key(void)
|
|||
ok(ret == ERROR_SUCCESS && hkey1 != NULL,
|
||||
"RegOpenKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret);
|
||||
RegCloseKey(hkey1);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, sd);
|
||||
LocalFree(key_acl);
|
||||
|
@ -2722,6 +2774,7 @@ START_TEST(registry)
|
|||
InitFunctionPtrs();
|
||||
|
||||
setup_main_key();
|
||||
check_user_privs();
|
||||
test_set_value();
|
||||
create_test_entries();
|
||||
test_enum_value();
|
||||
|
|
Loading…
Reference in New Issue