pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0070-dsinstance-reconnect-ldap2-after-DS-is-restarted-by-.patch

483b06
From f6ecef4bdf8f5f99c89c0649232a230c28191869 Mon Sep 17 00:00:00 2001
483b06
From: Jan Cholasta <jcholast@redhat.com>
483b06
Date: Fri, 7 Apr 2017 07:40:19 +0200
483b06
Subject: [PATCH] dsinstance: reconnect ldap2 after DS is restarted by
483b06
 certmonger
483b06
483b06
DS is restarted by certmonger in the restart_dirsrv script after the DS
483b06
certificate is saved. This breaks the ldap2 backend and makes any operation
483b06
fail with NetworkError until it is reconnected.
483b06
483b06
Reconnect ldap2 after the DS certificate request is finished to fix the
483b06
issue. Make sure restart_dirsrv waits for the ldapi socket so that the
483b06
reconnect does not fail.
483b06
483b06
https://pagure.io/freeipa/issue/6757
483b06
483b06
Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
483b06
---
483b06
 install/restart_scripts/restart_dirsrv | 2 +-
483b06
 ipaserver/install/dsinstance.py        | 4 ++++
483b06
 2 files changed, 5 insertions(+), 1 deletion(-)
483b06
483b06
diff --git a/install/restart_scripts/restart_dirsrv b/install/restart_scripts/restart_dirsrv
483b06
index b4c9490c10506aba60eee16c3f46ee7cb0474f50..ff476cac46f76d4964d39b12c04401dfc19c2d3a 100644
483b06
--- a/install/restart_scripts/restart_dirsrv
483b06
+++ b/install/restart_scripts/restart_dirsrv
483b06
@@ -41,7 +41,7 @@ def _main():
483b06
 
483b06
     try:
483b06
         if services.knownservices.dirsrv.is_running():
483b06
-            services.knownservices.dirsrv.restart(instance)
483b06
+            services.knownservices.dirsrv.restart(instance, ldapi=True)
483b06
     except Exception as e:
483b06
         syslog.syslog(syslog.LOG_ERR, "Cannot restart dirsrv (instance: '%s'): %s" % (instance, str(e)))
483b06
 
483b06
diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py
483b06
index 79dc90e92cac49a2b64ff6645f75dc3a8cbcc104..fb5f925de8e658dca9370714413012527f00c39d 100644
483b06
--- a/ipaserver/install/dsinstance.py
483b06
+++ b/ipaserver/install/dsinstance.py
483b06
@@ -837,6 +837,10 @@ class DsInstance(service.Service):
483b06
             finally:
483b06
                 certmonger.modify_ca_helper('IPA', prev_helper)
483b06
 
483b06
+            # restart_dirsrv in the request above restarts DS, reconnect ldap2
483b06
+            api.Backend.ldap2.disconnect()
483b06
+            api.Backend.ldap2.connect()
483b06
+
483b06
             self.dercert = dsdb.get_cert_from_db(self.nickname, pem=False)
483b06
 
483b06
         dsdb.create_pin_file()
483b06
-- 
483b06
2.9.3
483b06