Some months ago, when working on the schema updater, I broke the 'replace' directive in ldapupdater. Luckily the regression didn't make it to a released version.

Here is a fix.


--
PetrĀ³
From 2c5ccccc96abb0989a84e9c2bb4bd3bf642a1da1 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pvikt...@redhat.com>
Date: Fri, 4 Jul 2014 09:50:58 +0200
Subject: [PATCH] ldapupdate: Restore 'replace' functionality

The replace directive was made a no-op by mistake in commit 6381d76.
Restore it.
---
 ipaserver/install/ldapupdate.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py
index b6c6d2b90b1f86f5d45985d4e1476fd03f7d112d..6bed046d2661f48218b66c11e6f6a43c6dc0f6bf 100644
--- a/ipaserver/install/ldapupdate.py
+++ b/ipaserver/install/ldapupdate.py
@@ -625,6 +625,14 @@ def _apply_update_disposition(self, updates, entry):
                         (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
 
-- 
1.9.3

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to