+
+ acl_entry_t existing_entry;
+ /* Loop through the given ACL looking for matching entries. */
+ int result = acl_get_entry(*aclp, ACL_FIRST_ENTRY, &existing_entry);
+
+ while (result == 1) {
+ acl_tag_t existing_tag = ACL_UNDEFINED_TAG;
+ int tag_result = acl_get_tag_type(existing_entry, &existing_tag);
+
+ if (tag_result == -1) {
+ perror("set_acl_tag_permset (acl_get_tag_type)");
+ return -1;
+ }
+
+ if (existing_tag == entry_tag) {
+ if (entry_tag == ACL_USER_OBJ ||
+ entry_tag == ACL_GROUP_OBJ ||
+ entry_tag == ACL_OTHER) {
+ /* Only update for these three since all other tags will have
+ been wiped. */
+ acl_permset_t existing_permset;
+ int gep_result = acl_get_permset(existing_entry, &existing_permset);
+ if (gep_result == -1) {
+ perror("acl_set_entry (acl_get_permset)");
+ return -1;
+ }
+
+ int s_result = acl_set_permset(existing_entry, entry_permset);
+ if (s_result == -1) {
+ perror("acl_set_entry (acl_set_permset)");
+ return -1;
+ }
+
+ return 1;
+ }
+
+ }
+
+ result = acl_get_entry(*aclp, ACL_NEXT_ENTRY, &existing_entry);