Rob Shearman : advapi32: Add more tests for SetEntriesInAcl.
Alexandre Julliard
julliard at winehq.org
Wed Jan 23 05:25:01 CST 2008
Module: wine
Branch: master
Commit: 261bf8dad5c23e5ba0883510e237d42601b613df
URL: http://source.winehq.org/git/wine.git/?a=commit;h=261bf8dad5c23e5ba0883510e237d42601b613df
Author: Rob Shearman <rob at codeweavers.com>
Date: Tue Jan 22 15:36:04 2008 +0000
advapi32: Add more tests for SetEntriesInAcl.
---
dlls/advapi32/tests/security.c | 90 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 87 insertions(+), 3 deletions(-)
diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index 217d89c..2e9024f 100644
--- a/dlls/advapi32/tests/security.c
+++ b/dlls/advapi32/tests/security.c
@@ -1973,8 +1973,13 @@ static void test_impersonation_level(void)
static void test_SetEntriesInAcl(void)
{
- ACL *acl = (ACL*)0xdeadbeef;
DWORD res;
+ PSID EveryoneSid = NULL, UsersSid = NULL;
+ PACL OldAcl = NULL, NewAcl;
+ SID_IDENTIFIER_AUTHORITY SIDAuthWorld = { SECURITY_WORLD_SID_AUTHORITY };
+ SID_IDENTIFIER_AUTHORITY SIDAuthNT = { SECURITY_NT_AUTHORITY };
+ EXPLICIT_ACCESSW ExplicitAccess;
+ static const WCHAR wszEveryone[] = {'E','v','e','r','y','o','n','e',0};
if (!pSetEntriesInAclW)
{
@@ -1982,14 +1987,93 @@ static void test_SetEntriesInAcl(void)
return;
}
- res = pSetEntriesInAclW(0, NULL, NULL, &acl);
+ NewAcl = (PACL)0xdeadbeef;
+ res = pSetEntriesInAclW(0, NULL, NULL, &NewAcl);
if(res == ERROR_CALL_NOT_IMPLEMENTED)
{
skip("SetEntriesInAclW is not implemented\n");
return;
}
ok(res == ERROR_SUCCESS, "SetEntriesInAclW failed: %u\n", res);
- ok(acl == NULL, "acl=%p, expected NULL\n", acl);
+ ok(NewAcl == NULL, "NewAcl=%p, expected NULL\n", NewAcl);
+
+ OldAcl = HeapAlloc(GetProcessHeap(), 0, 256);
+ res = InitializeAcl(OldAcl, 256, ACL_REVISION);
+ if(!res && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
+ {
+ skip("ACLs not implemented - skipping tests\n");
+ HeapFree(GetProcessHeap(), 0, OldAcl);
+ return;
+ }
+ ok(res, "InitializeAcl failed with error %d\n", GetLastError());
+
+ res = AllocateAndInitializeSid( &SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &EveryoneSid);
+ ok(res, "AllocateAndInitializeSid failed with error %d\n", GetLastError());
+
+ res = AllocateAndInitializeSid( &SIDAuthNT, 2, SECURITY_BUILTIN_DOMAIN_RID,
+ DOMAIN_ALIAS_RID_USERS, 0, 0, 0, 0, 0, 0, &UsersSid);
+ ok(res, "AllocateAndInitializeSid failed with error %d\n", GetLastError());
+
+ res = AddAccessAllowedAce(OldAcl, ACL_REVISION, KEY_READ, UsersSid);
+ ok(res, "AddAccessAllowedAce failed with error %d\n", GetLastError());
+
+ ExplicitAccess.grfAccessPermissions = KEY_WRITE;
+ ExplicitAccess.grfAccessMode = GRANT_ACCESS;
+ ExplicitAccess.grfInheritance = NO_INHERITANCE;
+ 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 = (LPWSTR)EveryoneSid;
+ res = pSetEntriesInAclW(1, &ExplicitAccess, OldAcl, &NewAcl);
+ ok(res == ERROR_SUCCESS, "SetEntriesInAclW failed: %u\n", res);
+ todo_wine
+ ok(NewAcl != NULL, "returned acl was NULL\n");
+ LocalFree(NewAcl);
+
+ ExplicitAccess.Trustee.TrusteeForm = TRUSTEE_IS_USER;
+ ExplicitAccess.Trustee.ptstrName = (LPWSTR)wszEveryone;
+ res = pSetEntriesInAclW(1, &ExplicitAccess, OldAcl, &NewAcl);
+ ok(res == ERROR_SUCCESS, "SetEntriesInAclW failed: %u\n", res);
+ todo_wine
+ ok(NewAcl != NULL, "returned acl was NULL\n");
+ LocalFree(NewAcl);
+
+ ExplicitAccess.Trustee.TrusteeForm = TRUSTEE_BAD_FORM;
+ res = pSetEntriesInAclW(1, &ExplicitAccess, OldAcl, &NewAcl);
+ todo_wine
+ ok(res == ERROR_INVALID_PARAMETER, "SetEntriesInAclW failed: %u\n", res);
+ ok(NewAcl == NULL, "returned acl wasn't NULL: %p\n", NewAcl);
+ LocalFree(NewAcl);
+
+ ExplicitAccess.Trustee.TrusteeForm = TRUSTEE_IS_USER;
+ ExplicitAccess.Trustee.MultipleTrusteeOperation = TRUSTEE_IS_IMPERSONATE;
+ res = pSetEntriesInAclW(1, &ExplicitAccess, OldAcl, &NewAcl);
+ todo_wine
+ ok(res == ERROR_INVALID_PARAMETER, "SetEntriesInAclW failed: %u\n", res);
+ ok(NewAcl == NULL, "returned acl wasn't NULL: %p\n", NewAcl);
+ LocalFree(NewAcl);
+
+ ExplicitAccess.Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
+ ExplicitAccess.grfAccessMode = SET_ACCESS;
+ res = pSetEntriesInAclW(1, &ExplicitAccess, OldAcl, &NewAcl);
+ ok(res == ERROR_SUCCESS, "SetEntriesInAclW failed: %u\n", res);
+ todo_wine
+ ok(NewAcl != NULL, "returned acl was NULL\n");
+ LocalFree(NewAcl);
+
+ ExplicitAccess.grfAccessMode = REVOKE_ACCESS;
+ ExplicitAccess.Trustee.TrusteeForm = TRUSTEE_IS_SID;
+ ExplicitAccess.Trustee.ptstrName = (LPWSTR)UsersSid;
+ res = pSetEntriesInAclW(1, &ExplicitAccess, OldAcl, &NewAcl);
+ ok(res == ERROR_SUCCESS, "SetEntriesInAclW failed: %u\n", res);
+ todo_wine
+ ok(NewAcl != NULL, "returned acl was NULL\n");
+ LocalFree(NewAcl);
+
+ LocalFree(UsersSid);
+ LocalFree(EveryoneSid);
+ HeapFree(GetProcessHeap(), 0, OldAcl);
}
static void test_GetNamedSecurityInfoA(void)
More information about the wine-cvs
mailing list