* sec_acl.cc (setacl): Introduce bool array "invalid" to note the

invalidation of incoming acl entries while iterating over them.
This commit is contained in:
Corinna Vinschen
2015-02-12 17:53:24 +00:00
parent b49934db7f
commit 1072cb2e7d
3 changed files with 16 additions and 3 deletions

View File

@@ -125,6 +125,9 @@ setacl (HANDLE handle, path_conv &pc, int nentries, aclent_t *aclbufp,
writable = false;
bool *invalid = (bool *) tp.c_get ();
memset (invalid, 0, nentries * sizeof *invalid);
/* Pre-compute owner, group, and other permissions to allow creating
matching deny ACEs as in alloc_sd. */
DWORD owner_allow = 0, group_allow = 0, other_allow = 0;
@@ -163,7 +166,7 @@ setacl (HANDLE handle, path_conv &pc, int nentries, aclent_t *aclbufp,
&& (aclbufp[i].a_type == USER_OBJ
|| !(null_mask & FILE_READ_DATA)))
*allow |= FILE_DELETE_CHILD;
aclbufp[i].a_type = 0;
invalid[i] = true;
}
bool isownergroup = (owner_sid == group_sid);
DWORD owner_deny = ~owner_allow & (group_allow | other_allow);
@@ -210,7 +213,7 @@ setacl (HANDLE handle, path_conv &pc, int nentries, aclent_t *aclbufp,
{
DWORD allow;
/* Skip invalidated entries. */
if (!aclbufp[i].a_type)
if (invalid[i])
continue;
allow = STANDARD_RIGHTS_READ
@@ -249,7 +252,7 @@ setacl (HANDLE handle, path_conv &pc, int nentries, aclent_t *aclbufp,
{
inheritance = CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE;
/* invalidate the corresponding default entry. */
aclbufp[i + 1 + pos].a_type = 0;
invalid[i + 1 + pos] = true;
}
switch (aclbufp[i].a_type)
{