advapi32/tests: Explicitly test the ACL contents in test_AddMandatoryAce().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-02-15 19:50:53 -06:00 committed by Alexandre Julliard
parent 50cf8ee9c0
commit f6a723f121
1 changed files with 31 additions and 38 deletions

View File

@ -6395,13 +6395,13 @@ static void test_AddMandatoryAce(void)
static SID_IDENTIFIER_AUTHORITY sia_world = {SECURITY_WORLD_SID_AUTHORITY}; static SID_IDENTIFIER_AUTHORITY sia_world = {SECURITY_WORLD_SID_AUTHORITY};
char buffer_sd[SECURITY_DESCRIPTOR_MIN_LENGTH]; char buffer_sd[SECURITY_DESCRIPTOR_MIN_LENGTH];
SECURITY_DESCRIPTOR *sd2, *sd = (SECURITY_DESCRIPTOR *)&buffer_sd; SECURITY_DESCRIPTOR *sd2, *sd = (SECURITY_DESCRIPTOR *)&buffer_sd;
BOOL defaulted, present, ret, found, found2; BOOL defaulted, present, ret;
ACL_SIZE_INFORMATION acl_size_info; ACL_SIZE_INFORMATION acl_size_info;
SYSTEM_MANDATORY_LABEL_ACE *ace; SYSTEM_MANDATORY_LABEL_ACE *ace;
char buffer_acl[256]; char buffer_acl[256];
ACL *acl = (ACL *)&buffer_acl; ACL *acl = (ACL *)&buffer_acl;
SECURITY_ATTRIBUTES sa; SECURITY_ATTRIBUTES sa;
DWORD index, size; DWORD size;
HANDLE handle; HANDLE handle;
SID *everyone; SID *everyone;
ACL *sacl; ACL *sacl;
@ -6453,18 +6453,17 @@ static void test_AddMandatoryAce(void)
ret = pAddMandatoryAce(acl, ACL_REVISION, 0, SYSTEM_MANDATORY_LABEL_NO_WRITE_UP, &low_level); ret = pAddMandatoryAce(acl, ACL_REVISION, 0, SYSTEM_MANDATORY_LABEL_NO_WRITE_UP, &low_level);
ok(ret, "AddMandatoryAce failed with %u\n", GetLastError()); ok(ret, "AddMandatoryAce failed with %u\n", GetLastError());
index = 0; ret = GetAce(acl, 0, (void **)&ace);
found = FALSE; ok(ret, "got error %u\n", GetLastError());
while (GetAce(acl, index++, (void **)&ace)) ok(ace->Header.AceType == SYSTEM_MANDATORY_LABEL_ACE_TYPE, "got type %#x\n", ace->Header.AceType);
{ ok(!ace->Header.AceFlags, "got flags %#x\n", ace->Header.AceFlags);
if (ace->Header.AceType != SYSTEM_MANDATORY_LABEL_ACE_TYPE) continue; ok(ace->Mask == SYSTEM_MANDATORY_LABEL_NO_WRITE_UP, "got mask %#x\n", ace->Mask);
ok(ace->Header.AceFlags == 0, "Expected flags 0, got %x\n", ace->Header.AceFlags); ok(EqualSid(&ace->SidStart, &low_level), "wrong sid\n");
ok(ace->Mask == SYSTEM_MANDATORY_LABEL_NO_WRITE_UP,
"Expected mask SYSTEM_MANDATORY_LABEL_NO_WRITE_UP, got %x\n", ace->Mask); SetLastError(0xdeadbeef);
ok(EqualSid(&ace->SidStart, &low_level), "Expected low integrity level\n"); ret = GetAce(acl, 1, (void **)&ace);
found = TRUE; ok(!ret, "expected failure\n");
} ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %u\n", GetLastError());
ok(found, "Could not find mandatory label ace\n");
ret = SetSecurityDescriptorSacl(sd, TRUE, acl, FALSE); ret = SetSecurityDescriptorSacl(sd, TRUE, acl, FALSE);
ok(ret, "SetSecurityDescriptorSacl failed with error %u\n", GetLastError()); ok(ret, "SetSecurityDescriptorSacl failed with error %u\n", GetLastError());
@ -6525,30 +6524,24 @@ static void test_AddMandatoryAce(void)
ok(sacl->AceCount == 2, "Expected 2 ACEs, got %d\n", sacl->AceCount); ok(sacl->AceCount == 2, "Expected 2 ACEs, got %d\n", sacl->AceCount);
ok(!defaulted, "SACL defaulted\n"); ok(!defaulted, "SACL defaulted\n");
index = 0; ret = GetAce(acl, 0, (void **)&ace);
found = found2 = FALSE; ok(ret, "got error %u\n", GetLastError());
while (GetAce(sacl, index++, (void **)&ace)) ok(ace->Header.AceType == SYSTEM_MANDATORY_LABEL_ACE_TYPE, "got type %#x\n", ace->Header.AceType);
{ ok(!ace->Header.AceFlags, "got flags %#x\n", ace->Header.AceFlags);
if (ace->Header.AceType == SYSTEM_MANDATORY_LABEL_ACE_TYPE) ok(ace->Mask == SYSTEM_MANDATORY_LABEL_NO_WRITE_UP, "got mask %#x\n", ace->Mask);
{ ok(EqualSid(&ace->SidStart, &low_level), "wrong sid\n");
if (EqualSid(&ace->SidStart, &low_level))
{ ret = GetAce(acl, 1, (void **)&ace);
found = TRUE; ok(ret, "got error %u\n", GetLastError());
ok(!ace->Header.AceFlags, "Expected 0 as flags, got %#x\n", ace->Header.AceFlags); ok(ace->Header.AceType == SYSTEM_MANDATORY_LABEL_ACE_TYPE, "got type %#x\n", ace->Header.AceType);
ok(ace->Mask == SYSTEM_MANDATORY_LABEL_NO_WRITE_UP, ok(!ace->Header.AceFlags, "got flags %#x\n", ace->Header.AceFlags);
"Expected SYSTEM_MANDATORY_LABEL_NO_WRITE_UP as mask, got %#x\n", ace->Mask); ok(ace->Mask == SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP, "got mask %#x\n", ace->Mask);
} ok(EqualSid(&ace->SidStart, &medium_level), "wrong sid\n");
if (EqualSid(&ace->SidStart, &medium_level))
{ SetLastError(0xdeadbeef);
found2 = TRUE; ret = GetAce(acl, 2, (void **)&ace);
ok(!ace->Header.AceFlags, "Expected 0 as flags, got %#x\n", ace->Header.AceFlags); ok(!ret, "expected failure\n");
ok(ace->Mask == SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP, ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %u\n", GetLastError());
"Expected SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP as mask, got %#x\n", ace->Mask);
}
}
}
ok(found, "Could not find low mandatory label\n");
ok(found2, "Could not find medium mandatory label\n");
HeapFree(GetProcessHeap(), 0, sd2); HeapFree(GetProcessHeap(), 0, sd2);