483b06
From 0703a575b4e337e7ce41860956bd339c12cd44ea Mon Sep 17 00:00:00 2001
483b06
From: Thierry Bordaz <tbordaz@redhat.com>
483b06
Date: Tue, 20 Jun 2017 18:22:33 +0200
483b06
Subject: [PATCH] NULL LDAP context in call to ldap_search_ext_s during search
483b06
483b06
    KDC crashes on quite random interval while trying to reach LDAP
483b06
    https://pagure.io/freeipa/issue/7017
483b06
483b06
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
483b06
---
483b06
 daemons/ipa-kdb/ipa_kdb.c | 6 ++++++
483b06
 1 file changed, 6 insertions(+)
483b06
483b06
diff --git a/daemons/ipa-kdb/ipa_kdb.c b/daemons/ipa-kdb/ipa_kdb.c
483b06
index 050bfc90cef1bce4c932f54bb6050438c60ca79f..c0f1e276ca32ecb318add3a0d36f57acc3d17d51 100644
483b06
--- a/daemons/ipa-kdb/ipa_kdb.c
483b06
+++ b/daemons/ipa-kdb/ipa_kdb.c
483b06
@@ -465,6 +465,12 @@ int ipadb_get_connection(struct ipadb_context *ipactx)
483b06
     ret = ipadb_reinit_mspac(ipactx, false);
483b06
     if (ret && ret != ENOENT) {
483b06
         /* TODO: log that there is an issue with adtrust settings */
483b06
+        if (ipactx->lcontext == NULL) {
483b06
+            /* for some reason ldap connection was reset in ipadb_reinit_mspac
483b06
+             * and is no longer established => failure of ipadb_get_connection
483b06
+             */
483b06
+            goto done;
483b06
+        }
483b06
     }
483b06
 
483b06
     ret = 0;
483b06
-- 
483b06
2.9.4
483b06