- if (existing_tag == entry_tag) {
- /* If we update something, we're done and return ACL_SUCCESS */
- if (acl_set_permset(existing_entry, entry_permset) == ACL_ERROR) {
- perror("acl_update_entry (acl_set_permset)");
- return ACL_ERROR;
+ if (existing_tag == updated_tag) {
+ /* Our tag types match, but if we have a named user or group
+ entry, then we need to check that the user/group (that is,
+ the qualifier) matches too. */
+ bool qualifiers_match = false;
+
+ /* There are three ways the qualifiers can match... */
+ void* existing_qualifier = acl_get_qualifier(existing_entry);
+ if (existing_qualifier == NULL) {
+ if (existing_tag == ACL_USER || existing_tag == ACL_GROUP) {
+ perror("acl_update_entry (acl_get_qualifier)");
+ result = ACL_ERROR;
+ goto cleanup;
+ }
+ else {
+ /* First, we could be dealing with an entry that isn't a
+ named user or group, in which case they "match
+ vacuously." */
+ qualifiers_match = true;
+ }
+ }
+
+ /* Second, they could have matching UIDs. We don't really need to
+ check both tags here, since we know that they're equal. However,
+ clang-tidy can't figure that out, and the redundant equality
+ check prevents it from complaining about a potential null pointer
+ dereference. */
+ if (updated_tag == ACL_USER && existing_tag == ACL_USER) {
+ qualifiers_match = ( *((uid_t*)existing_qualifier)
+ ==
+ *((uid_t*)updated_qualifier) );