From 40f86500e755883aaa824dba16743bc89d693a42 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 25 Jan 2013 18:03:09 -0500 Subject: [PATCH] Fix the bug from the latest test case. --- src/apply-default-acl.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/apply-default-acl.c b/src/apply-default-acl.c index 5fea3a3..0f7e9ae 100644 --- a/src/apply-default-acl.c +++ b/src/apply-default-acl.c @@ -380,6 +380,7 @@ int acl_execute_masked(const char* path) { } + /** * @brief Determine whether @c path is executable (by anyone) or a * directory. @@ -435,6 +436,23 @@ int any_can_execute_or_dir(const char* path) { int ge_result = acl_get_entry(acl, ACL_FIRST_ENTRY, &entry); while (ge_result == ACL_SUCCESS) { + /* The first thing we do is check to see if this is a mask + entry. If it is, we skip it entirely. */ + acl_tag_t tag = ACL_UNDEFINED_TAG; + int tag_result = acl_get_tag_type(entry, &tag); + + if (tag_result == ACL_ERROR) { + perror("any_can_execute_or_dir (acl_get_tag_type)"); + result = ACL_ERROR; + goto cleanup; + } + + if (tag == ACL_MASK) { + ge_result = acl_get_entry(acl, ACL_NEXT_ENTRY, &entry); + continue; + } + + /* Ok, so it's not a mask entry. Check the execute perms. */ acl_permset_t permset; int ps_result = acl_get_permset(entry, &permset); @@ -452,7 +470,7 @@ int any_can_execute_or_dir(const char* path) { } if (gp_result == ACL_SUCCESS) { - /* Only return one if this execute bit is not masked. */ + /* Only return ACL_SUCCESS if this execute bit is not masked. */ if (acl_execute_masked(path) != ACL_SUCCESS) { result = ACL_SUCCESS; goto cleanup; -- 2.43.2