1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-21 16:02:15 +03:00

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
This commit is contained in:
Tom Lane
2022-05-10 18:42:02 -04:00
parent 6979736b4b
commit c61f36d996
2 changed files with 20 additions and 2 deletions

13
configure vendored
View File

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

View File

@ -1202,7 +1202,14 @@ if test "$with_ldap" = yes ; then
[AC_MSG_ERROR([library 'ldap' is required for LDAP])], [AC_MSG_ERROR([library 'ldap' is required for LDAP])],
[$EXTRA_LDAP_LIBS]) [$EXTRA_LDAP_LIBS])
LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS" LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS"
if test "$enable_thread_safety" = yes; then # The separate ldap_r library only exists in OpenLDAP < 2.5, and if we
# have 2.5 or later, we shouldn't even probe for ldap_r (we might find a
# library from a separate OpenLDAP installation). The most reliable
# way to check that is to check for a function introduced in 2.5.
AC_CHECK_FUNC([ldap_verify_credentials],
[thread_safe_libldap=yes],
[thread_safe_libldap=no])
if test "$enable_thread_safety" = yes -a "$thread_safe_libldap" = no; then
# Use ldap_r for FE if available, else assume ldap is thread-safe. # Use ldap_r for FE if available, else assume ldap is thread-safe.
# On some platforms ldap_r fails to link without PTHREAD_LIBS. # On some platforms ldap_r fails to link without PTHREAD_LIBS.
LIBS="$_LIBS" LIBS="$_LIBS"