e3ffab
From 925904b8724c50b6336c0cd17f5dbb2eb85be8a4 Mon Sep 17 00:00:00 2001
e3ffab
From: Martin Basti <mbasti@redhat.com>
e3ffab
Date: Tue, 4 Nov 2014 15:59:50 +0100
e3ffab
Subject: [PATCH] Fix upgrade: do not use invalid ldap connection
e3ffab
e3ffab
Ticket: https://fedorahosted.org/freeipa/ticket/4670
e3ffab
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
e3ffab
---
e3ffab
 ipaserver/install/ldapupdate.py           | 6 ++++++
e3ffab
 ipaserver/install/plugins/updateclient.py | 3 +++
e3ffab
 2 files changed, 9 insertions(+)
e3ffab
e3ffab
diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py
e3ffab
index 6bed046d2661f48218b66c11e6f6a43c6dc0f6bf..47f0399b928b3b0da3954592d56750450454aac7 100644
e3ffab
--- a/ipaserver/install/ldapupdate.py
e3ffab
+++ b/ipaserver/install/ldapupdate.py
e3ffab
@@ -889,3 +889,9 @@ class LDAPUpdate:
e3ffab
         self._run_updates(updates)
e3ffab
 
e3ffab
         return self.modified
e3ffab
+
e3ffab
+    def close_connection(self):
e3ffab
+        """Close ldap connection"""
e3ffab
+        if self.conn:
e3ffab
+            self.conn.unbind()
e3ffab
+            self.conn = None
e3ffab
diff --git a/ipaserver/install/plugins/updateclient.py b/ipaserver/install/plugins/updateclient.py
e3ffab
index 7566b6cd807dafc3af5e7b51a1dfa68847ca91c2..8f5c5b5fdbc2b7bfec8be342ee267425c93b47cf 100644
e3ffab
--- a/ipaserver/install/plugins/updateclient.py
e3ffab
+++ b/ipaserver/install/plugins/updateclient.py
e3ffab
@@ -122,6 +122,9 @@ class updateclient(backend.Executioner):
e3ffab
         for update in self.order(updatetype):
e3ffab
             (restart, apply_now, res) = self.run(update.name, **kw)
e3ffab
             if restart:
e3ffab
+                # connection has to be closed before restart, otherwise
e3ffab
+                # ld instance will try to reuse old non-valid connection
e3ffab
+                ld.close_connection()
e3ffab
                 self.restart(dm_password, live_run)
e3ffab
 
e3ffab
             if apply_now:
e3ffab
-- 
e3ffab
2.1.0
e3ffab