ldapupdate: Restore 'replace' functionality

The replace directive was made a no-op by mistake in commit 6381d76.
Restore it.

Reviewed-By: Martin Kosek <mkosek@redhat.com>
This commit is contained in:
Petr Viktorin 2014-07-04 09:50:58 +02:00 committed by Martin Kosek
parent f8b6595f49
commit 2f99140c92

View File

@ -625,6 +625,14 @@ class LDAPUpdate:
(old, new) = update_value.split('::', 1)
except ValueError:
raise BadSyntax, "bad syntax in replace, needs to be in the format old::new in %s" % update_value
try:
entry_values.remove(old)
except ValueError:
self.debug('replace: %s not found, skipping', safe_output(attr, old))
else:
entry_values.append(new)
self.debug('replace: updated value %s', safe_output(attr, entry_values))
entry[attr] = entry_values
return entry