This seem to fix a long-standing bug that was mitigated by a
workaround, but was still present after all.

Simo.

-- 
Simo Sorce * Red Hat, Inc * New York
>From 04777b8938d929e0464d3953cbfce76f243e04c8 Mon Sep 17 00:00:00 2001
From: Simo Sorce <sso...@redhat.com>
Date: Mon, 20 Dec 2010 21:19:36 -0500
Subject: [PATCH] Fix race condition in installation due to use of asynchronous search.

Fixes: https://fedorahosted.org/freeipa/ticket/640
---
 ipaserver/install/krbinstance.py |   31 ++++++++++++-------------------
 1 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/ipaserver/install/krbinstance.py b/ipaserver/install/krbinstance.py
index c1e5a3f0a10596d8a28774dd791a3bf4f44aaa8c..63903ef48e273b880670c2bbb9fa510705a0e7a1 100644
--- a/ipaserver/install/krbinstance.py
+++ b/ipaserver/install/krbinstance.py
@@ -268,28 +268,21 @@ class KrbInstance(service.Service):
 
     def __configure_sasl_mappings(self):
         # we need to remove any existing SASL mappings in the directory as otherwise they
-        # they may conflict. There is no way to define the order they are used in atm.
+        # they may conflict.
 
-        # FIXME: for some reason IPAdmin dies here, so we switch
-        # it out for a regular ldapobject.
-        conn = self.conn
-        self.conn = ldapobject.SimpleLDAPObject("ldap://127.0.0.1/";)
-        self.conn.bind("cn=directory manager", self.admin_password)
         try:
-            msgid = self.conn.search("cn=mapping,cn=sasl,cn=config", ldap.SCOPE_ONELEVEL, "(objectclass=nsSaslMapping)")
-            res = self.conn.result(msgid)
-            for r in res[1]:
-                self.conn.delete_s(r[0])
-        #except LDAPError, e:
-        #    logging.critical("Error during SASL mapping removal: %s" % str(e))
-        except Exception, e:
-            logging.critical("Could not connect to the Directory Server on %s" % self.fqdn)
+            res = self.conn.search_s("cn=mapping,cn=sasl,cn=config",
+                                     ldap.SCOPE_ONELEVEL,
+                                     "(objectclass=nsSaslMapping)")
+            for r in res:
+                try:
+                    self.conn.delete_s(r.dn)
+                except LDAPError, e:
+                    logging.critical("Error during SASL mapping removal: %s" % str(e))
+                    raise e
+        except LDAPError, e:
+            logging.critical("Error while enumerating SASL mappings %s" % str(e))
             raise e
-            print type(e)
-            print dir(e)
-            raise e
-
-        self.conn = conn
 
         entry = ipaldap.Entry("cn=Full Principal,cn=mapping,cn=sasl,cn=config")
         entry.setValues("objectclass", "top", "nsSaslMapping")
-- 
1.7.3.3

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

Reply via email to