bb772e8
From: Antonio Torres <antorres@redhat.com>
bb772e8
Date: Fri, 28 Jan 2022
bb772e8
Subject: Use infinite timeout when using LDAP+start-TLS
bb772e8
bb772e8
This will ensure that the TLS connection to the LDAP server will complete
bb772e8
before starting FreeRADIUS, as it forces libldap to use a blocking socket during 
bb772e8
the process. Infinite timeout is the OpenLDAP default.
bb772e8
Avoids this: https://git.openldap.org/openldap/openldap/-/blob/87ffc60006298069a5a044b8e63dab27a61d3fdf/libraries/libldap/tls2.c#L1134
bb772e8
bb772e8
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1992551
bb772e8
Signed-off-by: Antonio Torres <antorres@redhat.com>
bb772e8
---
bb772e8
 src/modules/rlm_ldap/ldap.c | 5 ++++-
bb772e8
 1 file changed, 4 insertions(+), 1 deletion(-)
bb772e8
bb772e8
diff --git a/src/modules/rlm_ldap/ldap.c b/src/modules/rlm_ldap/ldap.c
bb772e8
index cf7a84e069..841bf888a1 100644
bb772e8
--- a/src/modules/rlm_ldap/ldap.c
bb772e8
+++ b/src/modules/rlm_ldap/ldap.c
bb772e8
@@ -1472,7 +1472,10 @@ void *mod_conn_create(TALLOC_CTX *ctx, void *instance)
bb772e8
 	}
bb772e8
 
bb772e8
 #ifdef LDAP_OPT_NETWORK_TIMEOUT
bb772e8
-	if (inst->net_timeout) {
bb772e8
+	bool using_tls = inst->start_tls ||
bb772e8
+					 inst->port == 636 ||
bb772e8
+					 strncmp(inst->server, "ldaps://", strlen("ldaps://")) == 0;
bb772e8
+	if (inst->net_timeout && !using_tls) {
bb772e8
 		memset(&tv, 0, sizeof(tv));
bb772e8
 		tv.tv_sec = inst->net_timeout;
bb772e8