freeradius/freeradius-ldap-allow-to-co...

50 lines
1.8 KiB
Diff

From ab6bbcc41293ae745c1607618f88e5404b98d769 Mon Sep 17 00:00:00 2001
From: Antonio Torres <antorres@redhat.com>
Date: Wed, 13 Oct 2021 13:29:02 +0200
Subject: [PATCH] ldap: allow to connect on partially open handle
The LDAP library returns a partially open connection. Setting the
'retry' flag to true during the module inst creation and the pool start
to 0 allows to connect even if the connection is not completely opened
yet.
Upstream commit: https://github.com/FreeRADIUS/freeradius-server/commit/21d95b268b4cf56e75064898d83123825d673818
Signed-off-by: Antonio Torres <antorres@redhat.com>
---
diff --git a/src/modules/rlm_ldap/ldap.c b/src/modules/rlm_ldap/ldap.c
index f25ee9e2e0..4b6ae44afb 100644
--- a/src/modules/rlm_ldap/ldap.c
+++ b/src/modules/rlm_ldap/ldap.c
@@ -717,7 +717,8 @@ ldap_rcode_t rlm_ldap_bind(rlm_ldap_t const *inst, REQUEST *request, ldap_handle
* For sanity, for when no connections are viable,
* and we can't make a new one.
*/
- num = retry ? fr_connection_pool_get_num(inst->pool) : 0;
+ num = 0;
+ if (inst->pool && retry) num = fr_connection_pool_get_num(inst->pool);
for (i = num; i >= 0; i--) {
#ifdef WITH_SASL
if (sasl && sasl->mech) {
@@ -758,7 +759,7 @@ ldap_rcode_t rlm_ldap_bind(rlm_ldap_t const *inst, REQUEST *request, ldap_handle
break;
case LDAP_PROC_RETRY:
- if (retry) {
+ if (num) {
*pconn = fr_connection_reconnect(inst->pool, *pconn);
if (*pconn) {
LDAP_DBGW_REQ("Bind with %s to %s failed: %s. Got new socket, retrying...",
@@ -1563,7 +1564,7 @@ void *mod_conn_create(TALLOC_CTX *ctx, void *instance)
}
status = rlm_ldap_bind(inst, NULL, &conn, conn->inst->admin_identity, conn->inst->admin_password,
- &(conn->inst->admin_sasl), false);
+ &(conn->inst->admin_sasl), true);
if (status != LDAP_PROC_SUCCESS) {
goto error;
}
--
2.31.1