From 64a62ff3bdf7bd7aea8dc4ffae3ffb130e5a34ea Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Thu, 24 Sep 2009 10:38:55 -0600 Subject: MODIFY/replace with empty values does not ignore missing or unknown attributes https://bugzilla.redhat.com/show_bug.cgi?id=516305 Resolves: bug 516305 Bug Description: MODIFY/replace with empty values does not ignore missing or unknown attributes Reviewed by: nhosoi (Thanks!) Fix Description: The function mods_have_effect() did not work correctly. It would set the flag have_effect = 0 the first time a type was not found. Then if a subsequent mod would apply, it would still return have_effect = 0. What it should do is keep looking for all mod types in the list of mods to see if any of them would apply, and return have_effect = 1 if at least one of them would apply. This corresponds to RFC 4511 section 4.6: replace: replace all existing values of the modification attribute with the new values listed, creating the attribute if it did not already exist. A replace with no value will delete the entire attribute if it exists, and it is ignored if the attribute does not exist. So the proper behavior is to ignore attributes that do not exist, and to apply the rest. Platforms tested: RHEL5 x86_64 Flag Day: no Doc impact: no --- ldap/servers/slapd/back-ldbm/ldbm_modify.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modify.c b/ldap/servers/slapd/back-ldbm/ldbm_modify.c index 6ae95448..6883d092 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_modify.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_modify.c @@ -598,13 +598,16 @@ mods_have_effect (Slapi_Entry *entry, Slapi_Mods *smods) * to actually remove an existing attribute */ if ( strcasecmp ( mod->mod_type, attr->a_type ) == 0 ) { + have_effect = 1; /* found one - mod has effect */ goto done; } + /* this mod type was not found in the entry - if we don't + find one of the other mod types, or if there are no more + mod types to look for, this mod does not apply */ + have_effect = 0; } - have_effect = 0; } } - } done: -- cgit