mirror of
https://github.com/reactos/reactos.git
synced 2025-01-07 14:51:00 +00:00
[advapi32_winetest]
sync advapi32_winetest with wine 1.1.35 svn path=/trunk/; revision=44736
This commit is contained in:
parent
a059004e99
commit
1c1ceaa277
5 changed files with 1558 additions and 106 deletions
|
@ -234,6 +234,7 @@ static void test_incorrect_api_usage(void)
|
|||
result = pCryptCreateHash(hProv, CALG_SHA, 0, 0, &hHash);
|
||||
ok (result, "%d\n", GetLastError());
|
||||
if (!result) return;
|
||||
pCryptDestroyHash(hHash);
|
||||
|
||||
result = pCryptGenKey(hProv, CALG_RC4, 0, &hKey);
|
||||
ok (result, "%d\n", GetLastError());
|
||||
|
@ -557,6 +558,7 @@ static void test_enum_providers(void)
|
|||
ok(!strcmp(pszProvName, provider), "expected %s, got %s\n", pszProvName, provider);
|
||||
ok(cbName==providerLen, "expected %d, got %d\n", cbName, providerLen);
|
||||
|
||||
LocalFree(pszProvName);
|
||||
LocalFree(provider);
|
||||
}
|
||||
|
||||
|
@ -844,6 +846,7 @@ static void test_get_default_provider(void)
|
|||
ok(!strcmp(pszProvName, provName), "expected %s, got %s\n", pszProvName, provName);
|
||||
ok(provNameSize==cbProvName, "expected %d, got %d\n", cbProvName, provNameSize);
|
||||
|
||||
LocalFree(pszProvName);
|
||||
LocalFree(provName);
|
||||
}
|
||||
|
||||
|
@ -933,17 +936,156 @@ static void test_machine_guid(void)
|
|||
RegCloseKey(key);
|
||||
}
|
||||
|
||||
#define key_length 16
|
||||
|
||||
static const unsigned char key[key_length] =
|
||||
{ 0xbf, 0xf6, 0x83, 0x4b, 0x3e, 0xa3, 0x23, 0xdd,
|
||||
0x96, 0x78, 0x70, 0x8e, 0xa1, 0x9d, 0x3b, 0x40 };
|
||||
|
||||
static void test_rc2_keylen(void)
|
||||
{
|
||||
struct KeyBlob
|
||||
{
|
||||
BLOBHEADER header;
|
||||
DWORD key_size;
|
||||
BYTE key_data[2048];
|
||||
} key_blob;
|
||||
|
||||
HCRYPTPROV provider;
|
||||
HCRYPTKEY hkey = 0;
|
||||
BOOL ret;
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCryptAcquireContextA(&provider, NULL, NULL,
|
||||
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
|
||||
ok(ret, "CryptAcquireContext error %u\n", GetLastError());
|
||||
if (ret)
|
||||
{
|
||||
key_blob.header.bType = PLAINTEXTKEYBLOB;
|
||||
key_blob.header.bVersion = CUR_BLOB_VERSION;
|
||||
key_blob.header.reserved = 0;
|
||||
key_blob.header.aiKeyAlg = CALG_RC2;
|
||||
key_blob.key_size = sizeof(key);
|
||||
memcpy(key_blob.key_data, key, key_length);
|
||||
|
||||
/* Importing a 16-byte key works with the default provider. */
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCryptImportKey(provider, (BYTE*)&key_blob,
|
||||
sizeof(BLOBHEADER)+sizeof(DWORD)+key_blob.key_size,
|
||||
0, CRYPT_IPSEC_HMAC_KEY, &hkey);
|
||||
/* CRYPT_IPSEC_HMAC_KEY is not supported on W2K and lower */
|
||||
todo_wine
|
||||
ok(ret ||
|
||||
broken(!ret && GetLastError() == NTE_BAD_FLAGS),
|
||||
"CryptImportKey error %08x\n", GetLastError());
|
||||
|
||||
if (ret)
|
||||
pCryptDestroyKey(hkey);
|
||||
pCryptReleaseContext(provider, 0);
|
||||
}
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCryptAcquireContextA(&provider, NULL, MS_DEF_PROV,
|
||||
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
|
||||
ok(ret, "CryptAcquireContext error %08x\n", GetLastError());
|
||||
|
||||
if (ret)
|
||||
{
|
||||
/* Importing a 16-byte key doesn't work with the base provider.. */
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCryptImportKey(provider, (BYTE*)&key_blob,
|
||||
sizeof(BLOBHEADER)+sizeof(DWORD)+key_blob.key_size,
|
||||
0, 0, &hkey);
|
||||
ok(!ret && (GetLastError() == NTE_BAD_DATA ||
|
||||
GetLastError() == NTE_BAD_LEN || /* Win7 */
|
||||
GetLastError() == NTE_BAD_TYPE || /* W2K */
|
||||
GetLastError() == NTE_PERM), /* Win9x, WinMe and NT4 */
|
||||
"unexpected error %08x\n", GetLastError());
|
||||
/* but importing an 56-bit (7-byte) key does.. */
|
||||
key_blob.key_size = 7;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCryptImportKey(provider, (BYTE*)&key_blob,
|
||||
sizeof(BLOBHEADER)+sizeof(DWORD)+key_blob.key_size,
|
||||
0, 0, &hkey);
|
||||
ok(ret ||
|
||||
broken(!ret && GetLastError() == NTE_BAD_TYPE) || /* W2K */
|
||||
broken(!ret && GetLastError() == NTE_PERM), /* Win9x, WinMe and NT4 */
|
||||
"CryptAcquireContext error %08x\n", GetLastError());
|
||||
if (ret)
|
||||
pCryptDestroyKey(hkey);
|
||||
/* as does importing a 16-byte key with the base provider when
|
||||
* CRYPT_IPSEC_HMAC_KEY is specified.
|
||||
*/
|
||||
key_blob.key_size = sizeof(key);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCryptImportKey(provider, (BYTE*)&key_blob,
|
||||
sizeof(BLOBHEADER)+sizeof(DWORD)+key_blob.key_size,
|
||||
0, CRYPT_IPSEC_HMAC_KEY, &hkey);
|
||||
/* CRYPT_IPSEC_HMAC_KEY is not supported on W2K and lower */
|
||||
todo_wine
|
||||
ok(ret ||
|
||||
broken(!ret && GetLastError() == NTE_BAD_FLAGS),
|
||||
"CryptImportKey error %08x\n", GetLastError());
|
||||
if (ret)
|
||||
pCryptDestroyKey(hkey);
|
||||
|
||||
pCryptReleaseContext(provider, 0);
|
||||
}
|
||||
|
||||
key_blob.key_size = sizeof(key);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCryptAcquireContextA(&provider, NULL, NULL,
|
||||
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
|
||||
ok(ret, "CryptAcquireContext error %08x\n", GetLastError());
|
||||
|
||||
if (ret)
|
||||
{
|
||||
/* Importing a 16-byte key also works with the default provider when
|
||||
* CRYPT_IPSEC_HMAC_KEY is specified.
|
||||
*/
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCryptImportKey(provider, (BYTE*)&key_blob,
|
||||
sizeof(BLOBHEADER)+sizeof(DWORD)+key_blob.key_size,
|
||||
0, CRYPT_IPSEC_HMAC_KEY, &hkey);
|
||||
todo_wine
|
||||
ok(ret ||
|
||||
broken(!ret && GetLastError() == NTE_BAD_FLAGS),
|
||||
"CryptImportKey error %08x\n", GetLastError());
|
||||
if (ret)
|
||||
pCryptDestroyKey(hkey);
|
||||
|
||||
/* There is no apparent limit to the size of the input key when
|
||||
* CRYPT_IPSEC_HMAC_KEY is specified.
|
||||
*/
|
||||
key_blob.key_size = sizeof(key_blob.key_data);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCryptImportKey(provider, (BYTE*)&key_blob,
|
||||
sizeof(BLOBHEADER)+sizeof(DWORD)+key_blob.key_size,
|
||||
0, CRYPT_IPSEC_HMAC_KEY, &hkey);
|
||||
todo_wine
|
||||
ok(ret ||
|
||||
broken(!ret && GetLastError() == NTE_BAD_FLAGS),
|
||||
"CryptImportKey error %08x\n", GetLastError());
|
||||
if (ret)
|
||||
pCryptDestroyKey(hkey);
|
||||
|
||||
pCryptReleaseContext(provider, 0);
|
||||
}
|
||||
}
|
||||
|
||||
START_TEST(crypt)
|
||||
{
|
||||
init_function_pointers();
|
||||
if(pCryptAcquireContextA && pCryptReleaseContext) {
|
||||
init_function_pointers();
|
||||
if (pCryptAcquireContextA && pCryptReleaseContext)
|
||||
{
|
||||
test_rc2_keylen();
|
||||
init_environment();
|
||||
test_acquire_context();
|
||||
test_incorrect_api_usage();
|
||||
test_verify_sig();
|
||||
test_machine_guid();
|
||||
clean_up_environment();
|
||||
}
|
||||
}
|
||||
|
||||
test_enum_providers();
|
||||
test_enum_provider_types();
|
||||
|
|
1144
rostests/winetests/advapi32/eventlog.c
Normal file
1144
rostests/winetests/advapi32/eventlog.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -956,6 +956,28 @@ static void test_reg_create_key(void)
|
|||
/* clean up */
|
||||
RegDeleteKey(hkey2, "");
|
||||
RegDeleteKey(hkey1, "");
|
||||
RegCloseKey(hkey2);
|
||||
RegCloseKey(hkey1);
|
||||
|
||||
/* test creation of volatile keys */
|
||||
ret = RegCreateKeyExA(hkey_main, "Volatile", 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey1, NULL);
|
||||
ok(!ret, "RegCreateKeyExA failed with error %d\n", ret);
|
||||
ret = RegCreateKeyExA(hkey1, "Subkey2", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey2, NULL);
|
||||
ok(ret == ERROR_CHILD_MUST_BE_VOLATILE || broken(!ret), /* win9x */
|
||||
"RegCreateKeyExA failed with error %d\n", ret);
|
||||
if (!ret) RegCloseKey( hkey2 );
|
||||
ret = RegCreateKeyExA(hkey1, "Subkey2", 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey2, NULL);
|
||||
ok(!ret, "RegCreateKeyExA failed with error %d\n", ret);
|
||||
RegCloseKey(hkey2);
|
||||
/* should succeed if the key already exists */
|
||||
ret = RegCreateKeyExA(hkey1, "Subkey2", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey2, NULL);
|
||||
ok(!ret, "RegCreateKeyExA failed with error %d\n", ret);
|
||||
|
||||
/* clean up */
|
||||
RegDeleteKey(hkey2, "");
|
||||
RegDeleteKey(hkey1, "");
|
||||
RegCloseKey(hkey2);
|
||||
RegCloseKey(hkey1);
|
||||
|
||||
/* beginning backslash character */
|
||||
ret = RegCreateKeyExA(hkey_main, "\\Subkey3", 0, NULL, 0, KEY_NOTIFY, NULL, &hkey1, NULL);
|
||||
|
@ -964,6 +986,7 @@ static void test_reg_create_key(void)
|
|||
else {
|
||||
ok(!ret, "RegCreateKeyExA failed with error %d\n", ret);
|
||||
RegDeleteKey(hkey1, NULL);
|
||||
RegCloseKey(hkey1);
|
||||
}
|
||||
|
||||
/* WOW64 flags - open an existing key */
|
||||
|
|
|
@ -79,6 +79,7 @@ typedef LPSTR (WINAPI *fnGetTrusteeNameA)( PTRUSTEEA pTrustee );
|
|||
typedef BOOL (WINAPI *fnMakeSelfRelativeSD)( PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR, LPDWORD );
|
||||
typedef BOOL (WINAPI *fnConvertSidToStringSidA)( PSID pSid, LPSTR *str );
|
||||
typedef BOOL (WINAPI *fnConvertStringSidToSidA)( LPCSTR str, PSID pSid );
|
||||
static BOOL (WINAPI *pCheckTokenMembership)(HANDLE, PSID, PBOOL);
|
||||
static BOOL (WINAPI *pConvertStringSecurityDescriptorToSecurityDescriptorA)(LPCSTR, DWORD,
|
||||
PSECURITY_DESCRIPTOR*, PULONG );
|
||||
static BOOL (WINAPI *pConvertStringSecurityDescriptorToSecurityDescriptorW)(LPCWSTR, DWORD,
|
||||
|
@ -153,6 +154,7 @@ static void init(void)
|
|||
pAddAccessAllowedAceEx = (void *)GetProcAddress(hmod, "AddAccessAllowedAceEx");
|
||||
pAddAccessDeniedAceEx = (void *)GetProcAddress(hmod, "AddAccessDeniedAceEx");
|
||||
pAddAuditAccessAceEx = (void *)GetProcAddress(hmod, "AddAuditAccessAceEx");
|
||||
pCheckTokenMembership = (void *)GetProcAddress(hmod, "CheckTokenMembership");
|
||||
pConvertStringSecurityDescriptorToSecurityDescriptorA =
|
||||
(void *)GetProcAddress(hmod, "ConvertStringSecurityDescriptorToSecurityDescriptorA" );
|
||||
pConvertStringSecurityDescriptorToSecurityDescriptorW =
|
||||
|
@ -254,6 +256,7 @@ static void test_sid(void)
|
|||
ok(pisid->SubAuthority[0] == 21, "Invalid subauthority 0 - expceted 21, got %d\n", pisid->SubAuthority[0]);
|
||||
ok(pisid->SubAuthority[3] == 4576, "Invalid subauthority 0 - expceted 4576, got %d\n", pisid->SubAuthority[3]);
|
||||
LocalFree(str);
|
||||
LocalFree(psid);
|
||||
|
||||
for( i = 0; i < sizeof(refs) / sizeof(refs[0]); i++ )
|
||||
{
|
||||
|
@ -1226,10 +1229,18 @@ static void test_token_attr(void)
|
|||
ok(ret, "OpenProcessToken failed with error %d\n", GetLastError());
|
||||
|
||||
/* groups */
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetTokenInformation(Token, TokenGroups, NULL, 0, &Size);
|
||||
ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
||||
"GetTokenInformation(TokenGroups) %s with error %d\n",
|
||||
ret ? "succeeded" : "failed", GetLastError());
|
||||
Groups = HeapAlloc(GetProcessHeap(), 0, Size);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetTokenInformation(Token, TokenGroups, Groups, Size, &Size);
|
||||
ok(ret, "GetTokenInformation(TokenGroups) failed with error %d\n", GetLastError());
|
||||
ok(GetLastError() == 0xdeadbeef,
|
||||
"GetTokenInformation shouldn't have set last error to %d\n",
|
||||
GetLastError());
|
||||
trace("TokenGroups:\n");
|
||||
for (i = 0; i < Groups->GroupCount; i++)
|
||||
{
|
||||
|
@ -1238,12 +1249,12 @@ static void test_token_attr(void)
|
|||
DWORD DomainLength = 255;
|
||||
TCHAR Domain[255];
|
||||
SID_NAME_USE SidNameUse;
|
||||
pConvertSidToStringSidA(Groups->Groups[i].Sid, &SidString);
|
||||
Name[0] = '\0';
|
||||
Domain[0] = '\0';
|
||||
ret = LookupAccountSid(NULL, Groups->Groups[i].Sid, Name, &NameLength, Domain, &DomainLength, &SidNameUse);
|
||||
if (ret)
|
||||
{
|
||||
pConvertSidToStringSidA(Groups->Groups[i].Sid, &SidString);
|
||||
trace("%s, %s\\%s use: %d attr: 0x%08x\n", SidString, Domain, Name, SidNameUse, Groups->Groups[i].Attributes);
|
||||
LocalFree(SidString);
|
||||
}
|
||||
|
@ -1478,6 +1489,8 @@ static void test_CreateWellKnownSid(void)
|
|||
ok(memcmp(buf2, sid_buffer, cb) == 0, "SID create with domain is different than without (%d)\n", i);
|
||||
}
|
||||
}
|
||||
|
||||
LocalFree(domainsid);
|
||||
}
|
||||
|
||||
static void test_LookupAccountSid(void)
|
||||
|
@ -2047,7 +2060,8 @@ static void test_LookupAccountName(void)
|
|||
domain = HeapAlloc(GetProcessHeap(), 0, domain_size);
|
||||
ret = LookupAccountNameA(NULL, computer_name, psid, &sid_size, domain, &domain_size, &sid_use);
|
||||
ok(ret, "LookupAccountNameA failed: %d\n", GetLastError());
|
||||
ok(sid_use == SidTypeDomain, "expected SidTypeDomain, got %d\n", sid_use);
|
||||
ok(sid_use == SidTypeDomain ||
|
||||
(sid_use == SidTypeUser && ! strcmp(computer_name, user_name)), "expected SidTypeDomain for %s, got %d\n", computer_name, sid_use);
|
||||
HeapFree(GetProcessHeap(), 0, domain);
|
||||
HeapFree(GetProcessHeap(), 0, psid);
|
||||
}
|
||||
|
@ -2528,11 +2542,19 @@ static void test_SetEntriesInAcl(void)
|
|||
ExplicitAccess.grfAccessPermissions = KEY_WRITE;
|
||||
ExplicitAccess.grfAccessMode = GRANT_ACCESS;
|
||||
ExplicitAccess.grfInheritance = NO_INHERITANCE;
|
||||
ExplicitAccess.Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
|
||||
ExplicitAccess.Trustee.TrusteeForm = TRUSTEE_IS_SID;
|
||||
ExplicitAccess.Trustee.ptstrName = EveryoneSid;
|
||||
ExplicitAccess.Trustee.MultipleTrusteeOperation = 0xDEADBEEF;
|
||||
ExplicitAccess.Trustee.pMultipleTrustee = (PVOID)0xDEADBEEF;
|
||||
res = pSetEntriesInAclW(1, &ExplicitAccess, OldAcl, &NewAcl);
|
||||
ok(res == ERROR_SUCCESS, "SetEntriesInAclW failed: %u\n", res);
|
||||
ok(NewAcl != NULL, "returned acl was NULL\n");
|
||||
LocalFree(NewAcl);
|
||||
|
||||
ExplicitAccess.Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN;
|
||||
ExplicitAccess.Trustee.pMultipleTrustee = NULL;
|
||||
ExplicitAccess.Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
|
||||
ExplicitAccess.Trustee.TrusteeForm = TRUSTEE_IS_SID;
|
||||
ExplicitAccess.Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN;
|
||||
ExplicitAccess.Trustee.ptstrName = EveryoneSid;
|
||||
res = pSetEntriesInAclW(1, &ExplicitAccess, OldAcl, &NewAcl);
|
||||
ok(res == ERROR_SUCCESS, "SetEntriesInAclW failed: %u\n", res);
|
||||
ok(NewAcl != NULL, "returned acl was NULL\n");
|
||||
|
@ -2651,6 +2673,50 @@ static void test_ConvertStringSecurityDescriptor(void)
|
|||
BOOL ret;
|
||||
PSECURITY_DESCRIPTOR pSD;
|
||||
static const WCHAR Blank[] = { 0 };
|
||||
int i;
|
||||
static const struct
|
||||
{
|
||||
const char *sidstring;
|
||||
DWORD revision;
|
||||
BOOL ret;
|
||||
DWORD GLE;
|
||||
DWORD altGLE;
|
||||
} cssd[] =
|
||||
{
|
||||
{ "D:(A;;GA;;;WD)", 0xdeadbeef, FALSE, ERROR_UNKNOWN_REVISION },
|
||||
/* test ACE string type */
|
||||
{ "D:(A;;GA;;;WD)", SDDL_REVISION_1, TRUE },
|
||||
{ "D:(D;;GA;;;WD)", SDDL_REVISION_1, TRUE },
|
||||
{ "ERROR:(D;;GA;;;WD)", SDDL_REVISION_1, FALSE, ERROR_INVALID_PARAMETER },
|
||||
/* test ACE string with spaces */
|
||||
{ " D:(D;;GA;;;WD)", SDDL_REVISION_1, TRUE },
|
||||
{ "D: (D;;GA;;;WD)", SDDL_REVISION_1, TRUE },
|
||||
{ "D:( D;;GA;;;WD)", SDDL_REVISION_1, TRUE },
|
||||
{ "D:(D ;;GA;;;WD)", SDDL_REVISION_1, FALSE, RPC_S_INVALID_STRING_UUID, ERROR_INVALID_ACL }, /* Vista+ */
|
||||
{ "D:(D; ;GA;;;WD)", SDDL_REVISION_1, TRUE },
|
||||
{ "D:(D;; GA;;;WD)", SDDL_REVISION_1, TRUE },
|
||||
{ "D:(D;;GA ;;;WD)", SDDL_REVISION_1, FALSE, ERROR_INVALID_ACL },
|
||||
{ "D:(D;;GA; ;;WD)", SDDL_REVISION_1, TRUE },
|
||||
{ "D:(D;;GA;; ;WD)", SDDL_REVISION_1, TRUE },
|
||||
{ "D:(D;;GA;;; WD)", SDDL_REVISION_1, TRUE },
|
||||
{ "D:(D;;GA;;;WD )", SDDL_REVISION_1, TRUE },
|
||||
/* test ACE string access rights */
|
||||
{ "D:(A;;GA;;;WD)", SDDL_REVISION_1, TRUE },
|
||||
{ "D:(A;;GRGWGX;;;WD)", SDDL_REVISION_1, TRUE },
|
||||
{ "D:(A;;RCSDWDWO;;;WD)", SDDL_REVISION_1, TRUE },
|
||||
{ "D:(A;;RPWPCCDCLCSWLODTCR;;;WD)", SDDL_REVISION_1, TRUE },
|
||||
{ "D:(A;;FAFRFWFX;;;WD)", SDDL_REVISION_1, TRUE },
|
||||
{ "D:(A;;KAKRKWKX;;;WD)", SDDL_REVISION_1, TRUE },
|
||||
{ "D:(A;;0xFFFFFFFF;;;WD)", SDDL_REVISION_1, TRUE },
|
||||
{ "S:(AU;;0xFFFFFFFF;;;WD)", SDDL_REVISION_1, TRUE },
|
||||
/* test ACE string access right error case */
|
||||
{ "D:(A;;ROB;;;WD)", SDDL_REVISION_1, FALSE, ERROR_INVALID_ACL },
|
||||
/* test behaviour with empty strings */
|
||||
{ "", SDDL_REVISION_1, TRUE },
|
||||
/* test ACE string SID */
|
||||
{ "D:(D;;GA;;;S-1-0-0)", SDDL_REVISION_1, TRUE },
|
||||
{ "D:(D;;GA;;;Nonexistent account)", SDDL_REVISION_1, FALSE, ERROR_INVALID_ACL, ERROR_INVALID_SID } /* W2K */
|
||||
};
|
||||
|
||||
if (!pConvertStringSecurityDescriptorToSecurityDescriptorA)
|
||||
{
|
||||
|
@ -2658,82 +2724,22 @@ static void test_ConvertStringSecurityDescriptor(void)
|
|||
return;
|
||||
}
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
|
||||
"D:(A;;GA;;;WD)", 0xdeadbeef, &pSD, NULL);
|
||||
ok(!ret && GetLastError() == ERROR_UNKNOWN_REVISION,
|
||||
"ConvertStringSecurityDescriptorToSecurityDescriptor should have failed with ERROR_UNKNOWN_REVISION instead of %d\n",
|
||||
GetLastError());
|
||||
for (i = 0; i < sizeof(cssd)/sizeof(cssd[0]); i++)
|
||||
{
|
||||
DWORD GLE;
|
||||
|
||||
/* test ACE string type */
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
|
||||
"D:(A;;GA;;;WD)", SDDL_REVISION_1, &pSD, NULL);
|
||||
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
|
||||
LocalFree(pSD);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
|
||||
"D:(D;;GA;;;WD)", SDDL_REVISION_1, &pSD, NULL);
|
||||
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
|
||||
LocalFree(pSD);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
|
||||
"ERROR:(D;;GA;;;WD)", SDDL_REVISION_1, &pSD, NULL);
|
||||
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"ConvertStringSecurityDescriptorToSecurityDescriptor should have failed with ERROR_INVALID_PARAMETER instead of %d\n",
|
||||
GetLastError());
|
||||
|
||||
/* test ACE string access rights */
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
|
||||
"D:(A;;GA;;;WD)", SDDL_REVISION_1, &pSD, NULL);
|
||||
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
|
||||
LocalFree(pSD);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
|
||||
"D:(A;;GRGWGX;;;WD)", SDDL_REVISION_1, &pSD, NULL);
|
||||
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
|
||||
LocalFree(pSD);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
|
||||
"D:(A;;RCSDWDWO;;;WD)", SDDL_REVISION_1, &pSD, NULL);
|
||||
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
|
||||
LocalFree(pSD);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
|
||||
"D:(A;;RPWPCCDCLCSWLODTCR;;;WD)", SDDL_REVISION_1, &pSD, NULL);
|
||||
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
|
||||
LocalFree(pSD);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
|
||||
"D:(A;;FAFRFWFX;;;WD)", SDDL_REVISION_1, &pSD, NULL);
|
||||
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
|
||||
LocalFree(pSD);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
|
||||
"D:(A;;KAKRKWKX;;;WD)", SDDL_REVISION_1, &pSD, NULL);
|
||||
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
|
||||
LocalFree(pSD);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
|
||||
"D:(A;;0xFFFFFFFF;;;WD)", SDDL_REVISION_1, &pSD, NULL);
|
||||
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
|
||||
LocalFree(pSD);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
|
||||
"S:(AU;;0xFFFFFFFF;;;WD)", SDDL_REVISION_1, &pSD, NULL);
|
||||
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
|
||||
LocalFree(pSD);
|
||||
|
||||
/* test ACE string access right error case */
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
|
||||
"D:(A;;ROB;;;WD)", SDDL_REVISION_1, &pSD, NULL);
|
||||
ok(!ret && GetLastError() == ERROR_INVALID_ACL,
|
||||
"ConvertStringSecurityDescriptorToSecurityDescriptor should have failed with ERROR_INVALID_ACL instead of %d\n",
|
||||
GetLastError());
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
|
||||
cssd[i].sidstring, cssd[i].revision, &pSD, NULL);
|
||||
GLE = GetLastError();
|
||||
ok(ret == cssd[i].ret, "(%02d) Expected %s (%d)\n", i, cssd[i].ret ? "success" : "failure", GLE);
|
||||
if (!cssd[i].ret)
|
||||
ok(GLE == cssd[i].GLE ||
|
||||
(cssd[i].altGLE && GLE == cssd[i].altGLE),
|
||||
"(%02d) Unexpected last error %d\n", i, GLE);
|
||||
if (ret)
|
||||
LocalFree(pSD);
|
||||
}
|
||||
|
||||
/* test behaviour with NULL parameters */
|
||||
SetLastError(0xdeadbeef);
|
||||
|
@ -2766,29 +2772,11 @@ static void test_ConvertStringSecurityDescriptor(void)
|
|||
GetLastError());
|
||||
|
||||
/* test behaviour with empty strings */
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
|
||||
"", SDDL_REVISION_1, &pSD, NULL);
|
||||
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorW(
|
||||
Blank, SDDL_REVISION_1, &pSD, NULL);
|
||||
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
|
||||
|
||||
/* test ACE string SID */
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
|
||||
"D:(D;;GA;;;S-1-0-0)", SDDL_REVISION_1, &pSD, NULL);
|
||||
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
|
||||
LocalFree(pSD);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
|
||||
"D:(D;;GA;;;Nonexistent account)", SDDL_REVISION_1, &pSD, NULL);
|
||||
ok(!ret, "Expected failure, got %d\n", ret);
|
||||
ok(GetLastError() == ERROR_INVALID_ACL || GetLastError() == ERROR_INVALID_SID,
|
||||
"Expected ERROR_INVALID_ACL or ERROR_INVALID_SID, got %d\n", GetLastError());
|
||||
}
|
||||
|
||||
static void test_ConvertSecurityDescriptorToString(void)
|
||||
|
@ -2900,6 +2888,9 @@ static void test_ConvertSecurityDescriptorToString(void)
|
|||
CHECK_ONE_OF_AND_FREE("O:SYG:S-1-5-21-93476-23408-4576D:S:(AU;OICINPIOIDSAFA;CCDCLCSWRPRC;;;SU)(AU;NPSA;0x12019f;;;SU)", /* XP */
|
||||
"O:SYG:S-1-5-21-93476-23408-4576D:NO_ACCESS_CONTROLS:(AU;OICINPIOIDSAFA;CCDCLCSWRPRC;;;SU)(AU;NPSA;0x12019f;;;SU)" /* Vista */);
|
||||
}
|
||||
|
||||
LocalFree(psid2);
|
||||
LocalFree(psid);
|
||||
}
|
||||
|
||||
static void test_SetSecurityDescriptorControl (PSECURITY_DESCRIPTOR sec)
|
||||
|
@ -3171,8 +3162,10 @@ static void test_GetSecurityInfo(void)
|
|||
ok(sd != NULL, "GetSecurityInfo\n");
|
||||
ok(owner != NULL, "GetSecurityInfo\n");
|
||||
ok(group != NULL, "GetSecurityInfo\n");
|
||||
ok(dacl != NULL, "GetSecurityInfo\n");
|
||||
ok(IsValidAcl(dacl), "GetSecurityInfo\n");
|
||||
if (dacl != NULL)
|
||||
ok(IsValidAcl(dacl), "GetSecurityInfo\n");
|
||||
else
|
||||
win_skip("No ACL information returned\n");
|
||||
|
||||
LocalFree(sd);
|
||||
|
||||
|
@ -3191,8 +3184,10 @@ static void test_GetSecurityInfo(void)
|
|||
ok(ret == ERROR_SUCCESS, "GetSecurityInfo returned %d\n", ret);
|
||||
ok(owner != NULL, "GetSecurityInfo\n");
|
||||
ok(group != NULL, "GetSecurityInfo\n");
|
||||
ok(dacl != NULL, "GetSecurityInfo\n");
|
||||
ok(IsValidAcl(dacl), "GetSecurityInfo\n");
|
||||
if (dacl != NULL)
|
||||
ok(IsValidAcl(dacl), "GetSecurityInfo\n");
|
||||
else
|
||||
win_skip("No ACL information returned\n");
|
||||
|
||||
CloseHandle(obj);
|
||||
}
|
||||
|
@ -3220,11 +3215,140 @@ static void test_GetSidSubAuthority(void)
|
|||
ok(*pGetSidSubAuthority(psid,1) == 93476,"GetSidSubAuthority gave %d expected 93476\n",*pGetSidSubAuthority(psid,1));
|
||||
ok(GetLastError() == 0,"GetLastError returned %d instead of 0\n",GetLastError());
|
||||
SetLastError(0xbebecaca);
|
||||
todo_wine ok(*pGetSidSubAuthority(psid,4) == 0,"GetSidSubAuthority gave %d,expected 0\n",*pGetSidSubAuthority(psid,4));
|
||||
ok(pGetSidSubAuthority(psid,4) != NULL,"Expected out of bounds GetSidSubAuthority to return a non-NULL pointer\n");
|
||||
ok(GetLastError() == 0,"GetLastError returned %d instead of 0\n",GetLastError());
|
||||
LocalFree(psid);
|
||||
}
|
||||
|
||||
static void test_CheckTokenMembership(void)
|
||||
{
|
||||
PTOKEN_GROUPS token_groups;
|
||||
DWORD size;
|
||||
HANDLE process_token, token;
|
||||
BOOL is_member;
|
||||
BOOL ret;
|
||||
DWORD i;
|
||||
|
||||
if (!pCheckTokenMembership)
|
||||
{
|
||||
win_skip("CheckTokenMembership is not available\n");
|
||||
return;
|
||||
}
|
||||
ret = OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE|TOKEN_QUERY, &process_token);
|
||||
ok(ret, "OpenProcessToken failed with error %d\n", GetLastError());
|
||||
|
||||
ret = DuplicateToken(process_token, SecurityImpersonation, &token);
|
||||
ok(ret, "DuplicateToken failed with error %d\n", GetLastError());
|
||||
|
||||
/* groups */
|
||||
ret = GetTokenInformation(token, TokenGroups, NULL, 0, &size);
|
||||
ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
||||
"GetTokenInformation(TokenGroups) %s with error %d\n",
|
||||
ret ? "succeeded" : "failed", GetLastError());
|
||||
token_groups = HeapAlloc(GetProcessHeap(), 0, size);
|
||||
ret = GetTokenInformation(token, TokenGroups, token_groups, size, &size);
|
||||
ok(ret, "GetTokenInformation(TokenGroups) failed with error %d\n", GetLastError());
|
||||
|
||||
for (i = 0; i < token_groups->GroupCount; i++)
|
||||
{
|
||||
if (token_groups->Groups[i].Attributes & SE_GROUP_ENABLED)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == token_groups->GroupCount)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, token_groups);
|
||||
CloseHandle(token);
|
||||
skip("user not a member of any group\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = pCheckTokenMembership(token, token_groups->Groups[i].Sid, &is_member);
|
||||
ok(ret, "CheckTokenMembership failed with error %d\n", GetLastError());
|
||||
ok(is_member, "CheckTokenMembership should have detected sid as member\n");
|
||||
|
||||
ret = pCheckTokenMembership(NULL, token_groups->Groups[i].Sid, &is_member);
|
||||
ok(ret, "CheckTokenMembership failed with error %d\n", GetLastError());
|
||||
ok(is_member, "CheckTokenMembership should have detected sid as member\n");
|
||||
|
||||
ret = pCheckTokenMembership(process_token, token_groups->Groups[i].Sid, &is_member);
|
||||
todo_wine {
|
||||
ok(!ret && GetLastError() == ERROR_NO_IMPERSONATION_TOKEN,
|
||||
"CheckTokenMembership with process token %s with error %d\n",
|
||||
ret ? "succeeded" : "failed", GetLastError());
|
||||
ok(!is_member, "CheckTokenMembership should have cleared is_member\n");
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, token_groups);
|
||||
CloseHandle(token);
|
||||
CloseHandle(process_token);
|
||||
}
|
||||
|
||||
static void test_EqualSid(void)
|
||||
{
|
||||
PSID sid1, sid2;
|
||||
BOOL ret;
|
||||
SID_IDENTIFIER_AUTHORITY SIDAuthWorld = { SECURITY_WORLD_SID_AUTHORITY };
|
||||
SID_IDENTIFIER_AUTHORITY SIDAuthNT = { SECURITY_NT_AUTHORITY };
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = AllocateAndInitializeSid(&SIDAuthNT, 2, SECURITY_BUILTIN_DOMAIN_RID,
|
||||
DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &sid1);
|
||||
if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
||||
{
|
||||
win_skip("AllocateAndInitializeSid is not implemented\n");
|
||||
return;
|
||||
}
|
||||
ok(ret, "AllocateAndInitializeSid failed with error %d\n", GetLastError());
|
||||
ok(GetLastError() == 0xdeadbeef,
|
||||
"AllocateAndInitializeSid shouldn't have set last error to %d\n",
|
||||
GetLastError());
|
||||
|
||||
ret = AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID,
|
||||
0, 0, 0, 0, 0, 0, 0, &sid2);
|
||||
ok(ret, "AllocateAndInitializeSid failed with error %d\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = EqualSid(sid1, sid2);
|
||||
ok(!ret, "World and domain admins sids shouldn't have been equal\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS ||
|
||||
broken(GetLastError() == 0xdeadbeef), /* NT4 */
|
||||
"EqualSid should have set last error to ERROR_SUCCESS instead of %d\n",
|
||||
GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
sid2 = FreeSid(sid2);
|
||||
ok(!sid2, "FreeSid should have returned NULL instead of %p\n", sid2);
|
||||
ok(GetLastError() == 0xdeadbeef,
|
||||
"FreeSid shouldn't have set last error to %d\n",
|
||||
GetLastError());
|
||||
|
||||
ret = AllocateAndInitializeSid(&SIDAuthNT, 2, SECURITY_BUILTIN_DOMAIN_RID,
|
||||
DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &sid2);
|
||||
ok(ret, "AllocateAndInitializeSid failed with error %d\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = EqualSid(sid1, sid2);
|
||||
ok(ret, "Same sids should have been equal\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS ||
|
||||
broken(GetLastError() == 0xdeadbeef), /* NT4 */
|
||||
"EqualSid should have set last error to ERROR_SUCCESS instead of %d\n",
|
||||
GetLastError());
|
||||
|
||||
((SID *)sid2)->Revision = 2;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = EqualSid(sid1, sid2);
|
||||
ok(!ret, "EqualSid with invalid sid should have returned FALSE\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS ||
|
||||
broken(GetLastError() == 0xdeadbeef), /* NT4 */
|
||||
"EqualSid should have set last error to ERROR_SUCCESS instead of %d\n",
|
||||
GetLastError());
|
||||
((SID *)sid2)->Revision = SID_REVISION;
|
||||
|
||||
FreeSid(sid1);
|
||||
FreeSid(sid2);
|
||||
}
|
||||
|
||||
START_TEST(security)
|
||||
{
|
||||
init();
|
||||
|
@ -3255,4 +3379,6 @@ START_TEST(security)
|
|||
test_acls();
|
||||
test_GetSecurityInfo();
|
||||
test_GetSidSubAuthority();
|
||||
test_CheckTokenMembership();
|
||||
test_EqualSid();
|
||||
}
|
||||
|
|
|
@ -38,6 +38,9 @@ static BOOL (WINAPI *pChangeServiceConfig2A)(SC_HANDLE,DWORD,LPVOID);
|
|||
static BOOL (WINAPI *pEnumServicesStatusExA)(SC_HANDLE, SC_ENUM_TYPE, DWORD,
|
||||
DWORD, LPBYTE, DWORD, LPDWORD,
|
||||
LPDWORD, LPDWORD, LPCSTR);
|
||||
static BOOL (WINAPI *pEnumServicesStatusExW)(SC_HANDLE, SC_ENUM_TYPE, DWORD,
|
||||
DWORD, LPBYTE, DWORD, LPDWORD,
|
||||
LPDWORD, LPDWORD, LPCWSTR);
|
||||
static DWORD (WINAPI *pGetSecurityInfo)(HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
|
||||
PSID*, PSID*, PACL*, PACL*, PSECURITY_DESCRIPTOR*);
|
||||
static BOOL (WINAPI *pQueryServiceConfig2A)(SC_HANDLE,DWORD,LPBYTE,DWORD,LPDWORD);
|
||||
|
@ -51,6 +54,7 @@ static void init_function_pointers(void)
|
|||
|
||||
pChangeServiceConfig2A = (void*)GetProcAddress(hadvapi32, "ChangeServiceConfig2A");
|
||||
pEnumServicesStatusExA= (void*)GetProcAddress(hadvapi32, "EnumServicesStatusExA");
|
||||
pEnumServicesStatusExW= (void*)GetProcAddress(hadvapi32, "EnumServicesStatusExW");
|
||||
pGetSecurityInfo = (void *)GetProcAddress(hadvapi32, "GetSecurityInfo");
|
||||
pQueryServiceConfig2A= (void*)GetProcAddress(hadvapi32, "QueryServiceConfig2A");
|
||||
pQueryServiceConfig2W= (void*)GetProcAddress(hadvapi32, "QueryServiceConfig2W");
|
||||
|
@ -1030,6 +1034,7 @@ static void test_enum_svc(void)
|
|||
SC_HANDLE scm_handle;
|
||||
BOOL ret;
|
||||
DWORD bufsize, needed, returned, resume;
|
||||
DWORD neededW, returnedW;
|
||||
DWORD tempneeded, tempreturned, missing;
|
||||
DWORD servicecountactive, servicecountinactive;
|
||||
ENUM_SERVICE_STATUS *services;
|
||||
|
@ -1160,6 +1165,12 @@ static void test_enum_svc(void)
|
|||
"Expected ERROR_MORE_DATA, got %d\n", GetLastError());
|
||||
}
|
||||
|
||||
/* Test to show we get the same needed buffer size for the W-call */
|
||||
neededW = 0xdeadbeef;
|
||||
ret = EnumServicesStatusW(scm_handle, SERVICE_WIN32, SERVICE_STATE_ALL, NULL, 0,
|
||||
&neededW, &returnedW, NULL);
|
||||
ok(neededW == needed, "Expected needed buffersize to be the same for A- and W-calls\n");
|
||||
|
||||
/* Store the needed bytes */
|
||||
tempneeded = needed;
|
||||
|
||||
|
@ -1506,6 +1517,12 @@ static void test_enum_svc(void)
|
|||
"Expected ERROR_MORE_DATA, got %d\n", GetLastError());
|
||||
}
|
||||
|
||||
/* Test to show we get the same needed buffer size for the W-call */
|
||||
neededW = 0xdeadbeef;
|
||||
ret = pEnumServicesStatusExW(scm_handle, 0, SERVICE_WIN32, SERVICE_STATE_ALL,
|
||||
NULL, 0, &neededW, &returnedW, NULL, NULL);
|
||||
ok(neededW == needed, "Expected needed buffersize to be the same for A- and W-calls\n");
|
||||
|
||||
/* Store the needed bytes */
|
||||
tempneeded = needed;
|
||||
|
||||
|
|
Loading…
Reference in a new issue