Skip to content

Commit aff45c8

Browse files
committed
configure: don't probe for libldap_r if libldap is 2.5 or newer.
In OpenLDAP 2.5 and later, libldap itself is always thread-safe and there's never a libldap_r. Our existing coding dealt with that by assuming it wouldn't find libldap_r if libldap is thread-safe. But that rule fails to cope if there are multiple OpenLDAP versions visible, as is likely to be the case on macOS in particular. We'd end up using shiny new libldap in the backend and a hoary libldap_r in libpq. Instead, once we've found libldap, check if it's >= 2.5 (by probing for a function introduced then) and don't bother looking for libldap_r if so. While one can imagine library setups that this'd still give the wrong answer for, they seem unlikely to occur in practice. Per report from Peter Eisentraut. Back-patch to all supported branches. Discussion: https://postgr.es/m/fedacd7c-2a38-25c9-e7ff-dea549d0e979@enterprisedb.com
1 parent b0d4b3c commit aff45c8

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

configure

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13410,7 +13410,18 @@ _ACEOF
1341013410
fi
1341113411
done
1341213412

13413-
if test "$enable_thread_safety" = yes; then
13413+
# The separate ldap_r library only exists in OpenLDAP < 2.5, and if we
13414+
# have 2.5 or later, we shouldn't even probe for ldap_r (we might find a
13415+
# library from a separate OpenLDAP installation). The most reliable
13416+
# way to check that is to check for a function introduced in 2.5.
13417+
ac_fn_c_check_func "$LINENO" "ldap_verify_credentials" "ac_cv_func_ldap_verify_credentials"
13418+
if test "x$ac_cv_func_ldap_verify_credentials" = xyes; then :
13419+
thread_safe_libldap=yes
13420+
else
13421+
thread_safe_libldap=no
13422+
fi
13423+
13424+
if test "$enable_thread_safety" = yes -a "$thread_safe_libldap" = no; then
1341413425
# Use ldap_r for FE if available, else assume ldap is thread-safe.
1341513426
# On some platforms ldap_r fails to link without PTHREAD_LIBS.
1341613427
LIBS="$_LIBS"

configure.ac

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,14 @@ if test "$with_ldap" = yes ; then
13741374
LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS"
13751375
# This test is carried out against libldap.
13761376
AC_CHECK_FUNCS([ldap_initialize])
1377-
if test "$enable_thread_safety" = yes; then
1377+
# The separate ldap_r library only exists in OpenLDAP < 2.5, and if we
1378+
# have 2.5 or later, we shouldn't even probe for ldap_r (we might find a
1379+
# library from a separate OpenLDAP installation). The most reliable
1380+
# way to check that is to check for a function introduced in 2.5.
1381+
AC_CHECK_FUNC([ldap_verify_credentials],
1382+
[thread_safe_libldap=yes],
1383+
[thread_safe_libldap=no])
1384+
if test "$enable_thread_safety" = yes -a "$thread_safe_libldap" = no; then
13781385
# Use ldap_r for FE if available, else assume ldap is thread-safe.
13791386
# On some platforms ldap_r fails to link without PTHREAD_LIBS.
13801387
LIBS="$_LIBS"

0 commit comments

Comments
 (0)