Skip Menu |

This queue is for tickets about the Linux-ACL CPAN distribution.

Report information
The Basics
Id: 121126
Status: resolved
Priority: 0/
Queue: Linux-ACL

People
Owner: Nobody in particular
Requestors: JMEGERMAN [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.04
Fixed in: 0.05



Subject: setfacl returns true even if an error occurs
setfacl_internal always returns CONSTANT_YES, even if an error occurs while setting the ACL. As a result, the only way that setfacl returns a FALSE value is if the acl hashref is not passed to setfacl. setfacl_internal needs to return a non-zero value in the event that an error occurs while updating the acl on the filesystem.
This may not be a 100% solution, but here's a patch to return false in the event that an error occurs during setfacl_internal. It passes basic testing, but I haven't been exhaustive. Also it initializes the counter 'i', which was left uninitialized.
Subject: Linux-ACL.setfacl.patch
--- ACL.xs.orig 2014-08-28 18:03:47.000000000 -0400 +++ ACL.xs 2017-04-14 16:03:18.656908512 -0400 @@ -186,7 +186,8 @@ int setfacl_internal(char *filename, HV *in_acl_hash, HV *in_default_acl_hash){ HV *acl_hashes[3] = {in_acl_hash, in_default_acl_hash, NULL}; acl_type_t acl_types[3] = {ACL_TYPE_ACCESS, ACL_TYPE_DEFAULT, 0}; - int i; + int i = 0; + int rc = CONSTANT_YES; while(NULL != acl_hashes[i]){ acl_t acl = NULL; @@ -210,21 +211,32 @@ } acl = acl_init(0); + if (!acl) { + rc = CONSTANT_NO; + } if (acl_create_entry(&acl, &ent) == 0){ acl_set_tag_type(ent, ACL_USER_OBJ); set_perm(ent, get_perm_from_hash(current_acl, USER_OBJ_KEY, USER_OBJ_KEY_LENGTH)); + } else { + rc = CONSTANT_NO; } if (acl_create_entry(&acl, &ent) == 0){ acl_set_tag_type(ent, ACL_GROUP_OBJ); set_perm(ent, get_perm_from_hash(current_acl, GROUP_OBJ_KEY, GROUP_OBJ_KEY_LENGTH)); + } else { + rc = CONSTANT_NO; } if (acl_create_entry(&acl, &ent) == 0){ acl_set_tag_type(ent, ACL_MASK); set_perm(ent, get_perm_from_hash(current_acl, MASK_KEY, MASK_KEY_LENGTH)); + } else { + rc = CONSTANT_NO; } if (acl_create_entry(&acl, &ent) == 0){ acl_set_tag_type(ent, ACL_OTHER); set_perm(ent, get_perm_from_hash(current_acl, OTHER_KEY, OTHER_KEY_LENGTH)); + } else { + rc = CONSTANT_NO; } if(NULL != user_hash){ @@ -238,6 +250,8 @@ acl_set_tag_type(ent, ACL_USER); acl_set_qualifier(ent, &id_p); set_perm(ent, get_perm_from_hash(user_hash, key, key_len)); + } else { + rc = CONSTANT_NO; } } } @@ -253,18 +267,22 @@ acl_set_tag_type(ent, ACL_GROUP); acl_set_qualifier(ent, &id_p); set_perm(ent, get_perm_from_hash(group_hash, key, key_len)); + } else { + rc = CONSTANT_NO; } } } - acl_set_file(filename, acl_types[i], acl); + if (acl_set_file(filename, acl_types[i], acl) == -1) { + rc = CONSTANT_NO; + } acl_free(acl); i++; } - return CONSTANT_YES; + return rc; } /*
On Fri Apr 14 16:09:42 2017, JMEGERMAN wrote: Show quoted text
> This may not be a 100% solution, but here's a patch to return false in > the event that an error occurs during setfacl_internal. It passes > basic testing, but I haven't been exhaustive. Also it initializes the > counter 'i', which was left uninitialized.
Thanks a lot! Patched version just published. Should be available in few days or even hours.
Patch applied.