X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2Fapply-default-acl.c;h=465f70ad9794f55220f43abb8692d833238d2e4d;hb=b70d254436f1c3304d5ae98e82cb81340854d820;hp=5fea3a30a6efcb9c7359d5f9a19d25de7ead83e5;hpb=012ac3813d30a1bc3f405a2f8f33809cea607c6c;p=apply-default-acl.git diff --git a/src/apply-default-acl.c b/src/apply-default-acl.c index 5fea3a3..465f70a 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; @@ -776,7 +794,7 @@ int apply_default_acl(const char* path, bool no_exec_mask) { * The program name to use in the output. * */ -void usage(char* program_name) { +void usage(const char* program_name) { printf("Apply any applicable default ACLs to the given files or " "directories.\n\n"); printf("Usage: %s [flags] [ [ ...]]\n\n",