From 7bd3b3e12147b794c4cf2f4457df5e20638c7b0e Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Wed, 5 Oct 2011 17:16:05 -0400 Subject: Fix DNS permissions and membership in privileges This resolves two issues: 1. The DNS acis lacked a prefix so weren't tied to permissions 2. The permissions were added before the privileges so the member values weren't calculated properly For updates we need to add in the members and recalculate memberof via a DS task. https://fedorahosted.org/freeipa/ticket/1898 --- ipaserver/install/ldapupdate.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'ipaserver/install/ldapupdate.py') diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py index f2f416b9c..e1f6b1f43 100644 --- a/ipaserver/install/ldapupdate.py +++ b/ipaserver/install/ldapupdate.py @@ -267,7 +267,7 @@ class LDAPUpdate: def parse_update_file(self, data, all_updates, dn_list): """Parse the update file into a dictonary of lists and apply the update for each DN in the file.""" - valid_keywords = ["default", "add", "remove", "only", "deleteentry", "replace", "addifnew"] + valid_keywords = ["default", "add", "remove", "only", "deleteentry", "replace", "addifnew", "addifexist"] update = {} d = "" index = "" @@ -533,6 +533,14 @@ class LDAPUpdate: e.append(v) logging.debug('addifnew: set %s to %s', k, e) entry.setValues(k, e) + elif utype == 'addifexist': + logging.debug("addifexist: '%s' to %s, current value %s", v, k, e) + # Only add the attribute if the entry doesn't exist. We + # determine this based on whether it has an objectclass + if entry.getValues('objectclass'): + e.append(v) + logging.debug('addifexist: set %s to %s', k, e) + entry.setValues(k, e) elif utype == 'only': logging.debug("only: set %s to '%s', current value %s", k, v, e) if only.get(k): @@ -645,7 +653,11 @@ class LDAPUpdate: # entry.orig_data = {} try: if self.live_run: - self.conn.addEntry(entry.dn, entry.toTupleList()) + if len(entry.toTupleList()) > 0: + # addifexist may result in an entry with only a + # dn defined. In that case there is nothing to do. + # It means the entry doesn't exist, so skip it. + self.conn.addEntry(entry.dn, entry.toTupleList()) self.modified = True except Exception, e: logging.error("Add failure %s", e) -- cgit