Skip to content

Commit d0a02bd

Browse files
committed
Update configure's probe for libldap to work with OpenLDAP 2.5.
The separate libldap_r is gone and libldap itself is now always thread-safe. Unfortunately there seems no easy way to tell by inspection whether libldap is thread-safe, so we have to take it on faith that libldap is thread-safe if there's no libldap_r. That should be okay, as it appears that libldap_r was a standard part of the installation going back at least 20 years. Report and patch by Adrian Ho. Back-patch to all supported branches, since people might try to build any of them with a newer OpenLDAP. Discussion: https://postgr.es/m/17083-a19190d9591946a7@postgresql.org
1 parent a9da193 commit d0a02bd

File tree

4 files changed

+64
-49
lines changed

4 files changed

+64
-49
lines changed

configure

Lines changed: 52 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12880,13 +12880,17 @@ fi
1288012880
if test "$with_ldap" = yes ; then
1288112881
_LIBS="$LIBS"
1288212882
if test "$PORTNAME" != "win32"; then
12883-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ldap_bind in -lldap" >&5
12884-
$as_echo_n "checking for ldap_bind in -lldap... " >&6; }
12885-
if ${ac_cv_lib_ldap_ldap_bind+:} false; then :
12883+
if test "$enable_thread_safety" = yes; then
12884+
# Use ldap_r for FE if available, else assume ldap is thread-safe.
12885+
# If ldap_r does exist, assume without checking that ldap does too.
12886+
# on some platforms ldap_r fails to link without PTHREAD_LIBS
12887+
LIBS=""
12888+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ldap_bind" >&5
12889+
$as_echo_n "checking for library containing ldap_bind... " >&6; }
12890+
if ${ac_cv_search_ldap_bind+:} false; then :
1288612891
$as_echo_n "(cached) " >&6
1288712892
else
12888-
ac_check_lib_save_LIBS=$LIBS
12889-
LIBS="-lldap $EXTRA_LDAP_LIBS $LIBS"
12893+
ac_func_search_save_LIBS=$LIBS
1289012894
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1289112895
/* end confdefs.h. */
1289212896

@@ -12905,38 +12909,50 @@ return ldap_bind ();
1290512909
return 0;
1290612910
}
1290712911
_ACEOF
12908-
if ac_fn_c_try_link "$LINENO"; then :
12909-
ac_cv_lib_ldap_ldap_bind=yes
12910-
else
12911-
ac_cv_lib_ldap_ldap_bind=no
12912+
for ac_lib in '' ldap_r ldap; do
12913+
if test -z "$ac_lib"; then
12914+
ac_res="none required"
12915+
else
12916+
ac_res=-l$ac_lib
12917+
LIBS="-l$ac_lib $PTHREAD_CFLAGS $PTHREAD_LIBS $EXTRA_LDAP_LIBS $ac_func_search_save_LIBS"
12918+
fi
12919+
if ac_fn_c_try_link "$LINENO"; then :
12920+
ac_cv_search_ldap_bind=$ac_res
1291212921
fi
1291312922
rm -f core conftest.err conftest.$ac_objext \
12914-
conftest$ac_exeext conftest.$ac_ext
12915-
LIBS=$ac_check_lib_save_LIBS
12923+
conftest$ac_exeext
12924+
if ${ac_cv_search_ldap_bind+:} false; then :
12925+
break
1291612926
fi
12917-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ldap_ldap_bind" >&5
12918-
$as_echo "$ac_cv_lib_ldap_ldap_bind" >&6; }
12919-
if test "x$ac_cv_lib_ldap_ldap_bind" = xyes; then :
12920-
cat >>confdefs.h <<_ACEOF
12921-
#define HAVE_LIBLDAP 1
12922-
_ACEOF
12927+
done
12928+
if ${ac_cv_search_ldap_bind+:} false; then :
1292312929

12924-
LIBS="-lldap $LIBS"
12930+
else
12931+
ac_cv_search_ldap_bind=no
12932+
fi
12933+
rm conftest.$ac_ext
12934+
LIBS=$ac_func_search_save_LIBS
12935+
fi
12936+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ldap_bind" >&5
12937+
$as_echo "$ac_cv_search_ldap_bind" >&6; }
12938+
ac_res=$ac_cv_search_ldap_bind
12939+
if test "$ac_res" != no; then :
12940+
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
1292512941

1292612942
else
1292712943
as_fn_error $? "library 'ldap' is required for LDAP" "$LINENO" 5
1292812944
fi
1292912945

12930-
LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS"
12931-
if test "$enable_thread_safety" = yes; then
12932-
# on some platforms ldap_r fails to link without PTHREAD_LIBS
12933-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ldap_simple_bind in -lldap_r" >&5
12934-
$as_echo_n "checking for ldap_simple_bind in -lldap_r... " >&6; }
12935-
if ${ac_cv_lib_ldap_r_ldap_simple_bind+:} false; then :
12946+
LDAP_LIBS_FE="$LIBS $EXTRA_LDAP_LIBS"
12947+
LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS"
12948+
else
12949+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ldap_bind in -lldap" >&5
12950+
$as_echo_n "checking for ldap_bind in -lldap... " >&6; }
12951+
if ${ac_cv_lib_ldap_ldap_bind+:} false; then :
1293612952
$as_echo_n "(cached) " >&6
1293712953
else
1293812954
ac_check_lib_save_LIBS=$LIBS
12939-
LIBS="-lldap_r $PTHREAD_CFLAGS $PTHREAD_LIBS $EXTRA_LDAP_LIBS $LIBS"
12955+
LIBS="-lldap $EXTRA_LDAP_LIBS $LIBS"
1294012956
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1294112957
/* end confdefs.h. */
1294212958

@@ -12946,40 +12962,39 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1294612962
#ifdef __cplusplus
1294712963
extern "C"
1294812964
#endif
12949-
char ldap_simple_bind ();
12965+
char ldap_bind ();
1295012966
int
1295112967
main ()
1295212968
{
12953-
return ldap_simple_bind ();
12969+
return ldap_bind ();
1295412970
;
1295512971
return 0;
1295612972
}
1295712973
_ACEOF
1295812974
if ac_fn_c_try_link "$LINENO"; then :
12959-
ac_cv_lib_ldap_r_ldap_simple_bind=yes
12975+
ac_cv_lib_ldap_ldap_bind=yes
1296012976
else
12961-
ac_cv_lib_ldap_r_ldap_simple_bind=no
12977+
ac_cv_lib_ldap_ldap_bind=no
1296212978
fi
1296312979
rm -f core conftest.err conftest.$ac_objext \
1296412980
conftest$ac_exeext conftest.$ac_ext
1296512981
LIBS=$ac_check_lib_save_LIBS
1296612982
fi
12967-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ldap_r_ldap_simple_bind" >&5
12968-
$as_echo "$ac_cv_lib_ldap_r_ldap_simple_bind" >&6; }
12969-
if test "x$ac_cv_lib_ldap_r_ldap_simple_bind" = xyes; then :
12983+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ldap_ldap_bind" >&5
12984+
$as_echo "$ac_cv_lib_ldap_ldap_bind" >&6; }
12985+
if test "x$ac_cv_lib_ldap_ldap_bind" = xyes; then :
1297012986
cat >>confdefs.h <<_ACEOF
12971-
#define HAVE_LIBLDAP_R 1
12987+
#define HAVE_LIBLDAP 1
1297212988
_ACEOF
1297312989

12974-
LIBS="-lldap_r $LIBS"
12990+
LIBS="-lldap $LIBS"
1297512991

1297612992
else
12977-
as_fn_error $? "library 'ldap_r' is required for LDAP" "$LINENO" 5
12993+
as_fn_error $? "library 'ldap' is required for LDAP" "$LINENO" 5
1297812994
fi
1297912995

12980-
LDAP_LIBS_FE="-lldap_r $EXTRA_LDAP_LIBS"
12981-
else
1298212996
LDAP_LIBS_FE="-lldap $EXTRA_LDAP_LIBS"
12997+
LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS"
1298312998
fi
1298412999
for ac_func in ldap_initialize
1298513000
do :

configure.ac

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,18 +1289,22 @@ fi
12891289
if test "$with_ldap" = yes ; then
12901290
_LIBS="$LIBS"
12911291
if test "$PORTNAME" != "win32"; then
1292-
AC_CHECK_LIB(ldap, ldap_bind, [],
1293-
[AC_MSG_ERROR([library 'ldap' is required for LDAP])],
1294-
[$EXTRA_LDAP_LIBS])
1295-
LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS"
12961292
if test "$enable_thread_safety" = yes; then
1293+
# Use ldap_r for FE if available, else assume ldap is thread-safe.
1294+
# If ldap_r does exist, assume without checking that ldap does too.
12971295
# on some platforms ldap_r fails to link without PTHREAD_LIBS
1298-
AC_CHECK_LIB(ldap_r, ldap_simple_bind, [],
1299-
[AC_MSG_ERROR([library 'ldap_r' is required for LDAP])],
1300-
[$PTHREAD_CFLAGS $PTHREAD_LIBS $EXTRA_LDAP_LIBS])
1301-
LDAP_LIBS_FE="-lldap_r $EXTRA_LDAP_LIBS"
1296+
LIBS=""
1297+
AC_SEARCH_LIBS(ldap_bind, [ldap_r ldap], [],
1298+
[AC_MSG_ERROR([library 'ldap' is required for LDAP])],
1299+
[$PTHREAD_CFLAGS $PTHREAD_LIBS $EXTRA_LDAP_LIBS])
1300+
LDAP_LIBS_FE="$LIBS $EXTRA_LDAP_LIBS"
1301+
LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS"
13021302
else
1303+
AC_CHECK_LIB(ldap, ldap_bind, [],
1304+
[AC_MSG_ERROR([library 'ldap' is required for LDAP])],
1305+
[$EXTRA_LDAP_LIBS])
13031306
LDAP_LIBS_FE="-lldap $EXTRA_LDAP_LIBS"
1307+
LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS"
13041308
fi
13051309
AC_CHECK_FUNCS([ldap_initialize])
13061310
else

src/include/pg_config.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,6 @@
322322
/* Define to 1 if you have the `ldap' library (-lldap). */
323323
#undef HAVE_LIBLDAP
324324

325-
/* Define to 1 if you have the `ldap_r' library (-lldap_r). */
326-
#undef HAVE_LIBLDAP_R
327-
328325
/* Define to 1 if you have the `lz4' library (-llz4). */
329326
#undef HAVE_LIBLZ4
330327

src/tools/msvc/Solution.pm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ sub GenerateFiles
302302
HAVE_LDAP_INITIALIZE => undef,
303303
HAVE_LIBCRYPTO => undef,
304304
HAVE_LIBLDAP => undef,
305-
HAVE_LIBLDAP_R => undef,
306305
HAVE_LIBLZ4 => undef,
307306
HAVE_LIBM => undef,
308307
HAVE_LIBPAM => undef,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy