- /* If we've made it this far, we need to add a new entry to the
- ACL. */
- acl_entry_t new_entry;
-
- /* The acl_create_entry() function can allocate new memory and/or
- * change the location of the ACL structure entirely. When that
- * happens, the value pointed to by aclp is updated, which means
- * that a new acl_t gets "passed out" to our caller, eventually to
- * be fed to acl_free(). In other words, we should still be freeing
- * the right thing, even if the value pointed to by aclp changes.
- */
- if (acl_create_entry(aclp, &new_entry) == ACL_ERROR) {
- perror("acl_set_entry (acl_create_entry)");
- return ACL_ERROR;
- }
-
- if (acl_set_tag_type(new_entry, entry_tag) == ACL_ERROR) {
- perror("acl_set_entry (acl_set_tag_type)");
- return ACL_ERROR;
- }
-
- if (acl_set_permset(new_entry, entry_permset) == ACL_ERROR) {
- perror("acl_set_entry (acl_set_permset)");
- return ACL_ERROR;
- }
-
- if (entry_tag == ACL_USER || entry_tag == ACL_GROUP) {
- /* We need to set the qualifier too. */
- void* entry_qual = acl_get_qualifier(entry);
- if (entry_qual == (void*)NULL) {
- perror("acl_set_entry (acl_get_qualifier)");
- return ACL_ERROR;
- }
-
- if (acl_set_qualifier(new_entry, entry_qual) == ACL_ERROR) {
- perror("acl_set_entry (acl_set_qualifier)");
- return ACL_ERROR;
- }
- }
-
- return ACL_SUCCESS;