Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c61f36d

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/[email protected]
1 parent 6979736 commit c61f36d

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
@@ -10696,7 +10696,18 @@ else
1069610696
fi
1069710697

1069810698
LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS"
10699-
if test "$enable_thread_safety" = yes; then
10699+
# The separate ldap_r library only exists in OpenLDAP < 2.5, and if we
10700+
# have 2.5 or later, we shouldn't even probe for ldap_r (we might find a
10701+
# library from a separate OpenLDAP installation). The most reliable
10702+
# way to check that is to check for a function introduced in 2.5.
10703+
ac_fn_c_check_func "$LINENO" "ldap_verify_credentials" "ac_cv_func_ldap_verify_credentials"
10704+
if test "x$ac_cv_func_ldap_verify_credentials" = xyes; then :
10705+
thread_safe_libldap=yes
10706+
else
10707+
thread_safe_libldap=no
10708+
fi
10709+
10710+
if test "$enable_thread_safety" = yes -a "$thread_safe_libldap" = no; then
1070010711
# Use ldap_r for FE if available, else assume ldap is thread-safe.
1070110712
# On some platforms ldap_r fails to link without PTHREAD_LIBS.
1070210713
LIBS="$_LIBS"

configure.in

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,14 @@ if test "$with_ldap" = yes ; then
12021202
[AC_MSG_ERROR([library 'ldap' is required for LDAP])],
12031203
[$EXTRA_LDAP_LIBS])
12041204
LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS"
1205-
if test "$enable_thread_safety" = yes; then
1205+
# The separate ldap_r library only exists in OpenLDAP < 2.5, and if we
1206+
# have 2.5 or later, we shouldn't even probe for ldap_r (we might find a
1207+
# library from a separate OpenLDAP installation). The most reliable
1208+
# way to check that is to check for a function introduced in 2.5.
1209+
AC_CHECK_FUNC([ldap_verify_credentials],
1210+
[thread_safe_libldap=yes],
1211+
[thread_safe_libldap=no])
1212+
if test "$enable_thread_safety" = yes -a "$thread_safe_libldap" = no; then
12061213
# Use ldap_r for FE if available, else assume ldap is thread-safe.
12071214
# On some platforms ldap_r fails to link without PTHREAD_LIBS.
12081215
LIBS="$_LIBS"

0 commit comments

Comments
 (0)