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