Permalink
Browse files

Fixed LDAP library file name bug (KNOWN_BUGS #1). configure now auto-…

…detects

the correct dynamic library names by default, and provides override switches
--with-ldap-lib, --with-lber-lib and --without-lber-lib.  Added
CURL_DISABLE_LDAP to platform-specific config files to disable LDAP
support on those platforms that probably don't have dynamic OpenLDAP
libraries available to avoid compile errors.
  • Loading branch information...
1 parent c4ce9ac commit 205f8b266cfeedc18d4fad134b7fbd6d68c14ef3 @dfandrich dfandrich committed Mar 11, 2005
Showing with 138 additions and 14 deletions.
  1. +55 −0 acinclude.m4
  2. +49 −0 configure.ac
  3. +0 −4 docs/KNOWN_BUGS
  4. +1 −0 lib/Makefile.netware
  5. +2 −0 lib/config-amigaos.h
  6. +2 −0 lib/config-mac.h
  7. +3 −0 lib/config-riscos.h
  8. +6 −0 lib/config-win32.h
  9. +3 −0 lib/config.dj
  10. +14 −10 lib/ldap.c
  11. +3 −0 packages/vms/config-vms.h
View
55 acinclude.m4
@@ -766,3 +766,58 @@ AC_DEFUN([CURL_CC_DEBUG_OPTS],
]) dnl end of AC_DEFUN()
+
+dnl Determine the name of the library to pass to dlopen() based on the name
+dnl that would normally be given to AC_CHECK_LIB. The preprocessor symbol
+dnl given is set to the quoted library file name.
+dnl The standard dynamic library file name is first generated, based on the
+dnl current system type, then a search is performed for that file on the
+dnl standard dynamic library path. If it is a symbolic link, the destination
+dnl of the link is used as the file name, after stripping off any minor
+dnl version numbers. If a library file can't be found, a guess is made.
+dnl This macro assumes AC_PROG_LIBTOOL has been called and requires perl
+dnl to be available.
+dnl
+dnl CURL_DLLIB_NAME(VARIABLE, library_name)
+dnl e.g. CURL_DLLIB_NAME(LDAP_NAME, ldap) on a Linux system might result
+dnl in LDAP_NAME holding the string "libldap.so.2".
+
+AC_DEFUN([CURL_DLLIB_NAME],
+[
+AC_MSG_CHECKING([name of dynamic library $2])
+
+dnl Create the dynamic library name of the correct form for this platform
+DLGUESSLIB=`name=$2 eval echo "$libname_spec"`
+DLGUESSFILE=`libname=$DLGUESSLIB release="" major="" eval echo "$soname_spec"`
+
+if test "$cross_compiling" = yes; then
+ dnl Can't look at filesystem when cross-compiling
+ AC_DEFINE_UNQUOTED($1, "$DLGUESSFILE", [$2 dynamic library file])
+ AC_MSG_RESULT([$DLGUESSFILE (guess while cross-compiling)])
+else
+
+ DLFOUNDFILE=""
+ if test "$sys_lib_dlsearch_path_spec" ; then
+ for direc in $sys_lib_dlsearch_path_spec ; do
+ DLTRYFILE="$direc/$DLGUESSFILE"
+ dnl Find where the symbolic link for this name points
+ changequote(<<, >>)dnl
+ <<
+ DLFOUNDFILE=`perl -e 'use File::Basename; (basename(readlink($ARGV[0])) =~ /^(.*[^\d]\.\d+)[\d\.]*$/ && print ${1}) || exit 1;' "$DLTRYFILE" 2>&5`
+ >>
+ changequote([, ])dnl
+ if test "$?" -eq "0"; then
+ dnl Found the file link
+ break
+ fi
+ done
+ fi
+
+ if test -z "$DLFOUNDFILE" ; then
+ DLFOUNDFILE="$DLGUESSFILE"
+ fi
+
+ AC_DEFINE_UNQUOTED($1, "$DLFOUNDFILE", [$2 dynamic library file])
+ AC_MSG_RESULT($DLFOUNDFILE)
+fi
+])
View
49 configure.ac
@@ -372,6 +372,55 @@ AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
)
dnl **********************************************************************
+dnl Check for the name of dynamic OpenLDAP libraries
+dnl **********************************************************************
+
+LDAPLIBNAME=""
+AC_ARG_WITH(ldap-lib,
+AC_HELP_STRING([--with-ldap-lib=libname],[Specify name of dynamic ldap lib file]),
+ [LDAPLIBNAME="$withval"])
+
+LBERLIBNAME=""
+AC_ARG_WITH(lber-lib,
+AC_HELP_STRING([--with-lber-lib=libname],[Specify name of dynamic lber lib file]),
+ [LBERLIBNAME="$withval"])
+
+if test x$CURL_DISABLE_LDAP != x1 ; then
+
+ if test -z "$LDAPLIBNAME" ; then
+ case $host in
+ *-*-cygwin | *-*-mingw* | *-*-pw32*)
+ dnl Windows uses a single and unique OpenLDAP DLL name
+ LDAPLIBNAME="wldap32.dll"
+ LBERLIBNAME="no"
+ ;;
+ esac
+ fi
+
+ if test "$LDAPLIBNAME" ; then
+ AC_DEFINE_UNQUOTED(DL_LDAP_FILE, "$LDAPLIBNAME")
+ AC_MSG_CHECKING([name of dynamic library ldap])
+ AC_MSG_RESULT($LDAPLIBNAME)
+ else
+ dnl Try to find the right ldap library name for this system
+ CURL_DLLIB_NAME(DL_LDAP_FILE, ldap)
+ fi
+
+ if test "$LBERLIBNAME" ; then
+ dnl If name is "no" then don't define this variable at all
+ dnl (it's only needed if libldap.so's dependencies are broken).
+ if test "$LBERLIBNAME" != "no" ; then
+ AC_DEFINE_UNQUOTED(DL_LBER_FILE, "$LBERLIBNAME")
+ fi
+ AC_MSG_CHECKING([name of dynamic library lber])
+ AC_MSG_RESULT($LBERLIBNAME)
+ else
+ dnl Try to find the right lber library name for this system
+ CURL_DLLIB_NAME(DL_LBER_FILE, lber)
+ fi
+fi
+
+dnl **********************************************************************
dnl Check for the presence of the winmm library.
dnl **********************************************************************
View
4 docs/KNOWN_BUGS
@@ -91,7 +91,3 @@ may have been fixed since this was written!
and havoc is what happens.
More details on this is found in this libcurl mailing list thread:
http://curl.haxx.se/mail/lib-2002-08/0000.html
-
-1. LDAP support requires that not only the OpenLDAP shared libraries be
- present at run time, but the development libraries (liblber.so and
- libldap.so) as well (not applicable to Windows).
View
1 lib/Makefile.netware
@@ -336,6 +336,7 @@ config.h: Makefile.netware
@echo $(DL)#define SIZEOF_CURL_OFF_T 4$(DL) >> $@
@echo $(DL)#define STDC_HEADERS 1$(DL) >> $@
@echo $(DL)#define TIME_WITH_SYS_TIME 1$(DL) >> $@
+ @echo $(DL)#define CURL_DISABLE_LDAP 1$(DL) >> $@
ifdef NW_WINSOCK
@echo $(DL)#define HAVE_CLOSESOCKET 1$(DL) >> $@
else
View
2 lib/config-amigaos.h
@@ -57,6 +57,8 @@
#define USE_OPENSSL 1
#define USE_SSLEAY 1
+#define CURL_DISABLE_LDAP 1
+
#define OS "AmigaOS"
View
2 lib/config-mac.h
@@ -36,6 +36,8 @@
# define USE_OPENSSL 1
#endif
+#define CURL_DISABLE_LDAP 1
+
#define HAVE_RAND_STATUS 1
#define HAVE_RAND_EGD 1
View
3 lib/config-riscos.h
@@ -388,3 +388,6 @@
#define HAVE_FIONBIO
+/* to disable LDAP */
+#define CURL_DISABLE_LDAP
+
View
6 lib/config-win32.h
@@ -232,6 +232,12 @@
/* use ioctlsocket() for non-blocking sockets */
#define HAVE_IOCTLSOCKET
+/* lber dynamic library file */
+/* #undef DL_LBER_FILE */
+
+/* ldap dynamic library file */
+#define DL_LDAP_FILE "wldap32.dll"
+
/*************************************************
* This section is for compiler specific defines.*
*************************************************/
View
3 lib/config.dj
@@ -93,6 +93,9 @@
#define USE_OPENSSL 1
#endif
+/* to disable LDAP */
+#define CURL_DISABLE_LDAP 1
+
/* Because djgpp <= 2.03 doesn't have snprintf() etc.
*/
#if (DJGPP_MINOR < 4)
View
24 lib/ldap.c
@@ -110,7 +110,7 @@ typedef void * (*dynafunc)(void *input);
*/
#if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL) || defined(WIN32)
static void *libldap = NULL;
-#ifndef WIN32
+#if defined(DL_LBER_FILE)
static void *liblber = NULL;
#endif
#endif
@@ -120,24 +120,26 @@ static int DynaOpen(const char **mod_name)
#if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL)
if (libldap == NULL) {
/*
- * libldap.so should be able to resolve its dependency on
- * liblber.so automatically, but since it does not we will
+ * libldap.so can normally resolve its dependency on liblber.so
+ * automatically, but in broken installation it does not so
* handle it here by opening liblber.so as global.
*/
- *mod_name = "liblber.so";
+#ifdef DL_LBER_FILE
+ *mod_name = DL_LBER_FILE;
liblber = dlopen(*mod_name, DLOPEN_MODE);
+ if (!liblber)
+ return 0;
+#endif
/* Assume loading libldap.so will fail if loading of liblber.so failed
*/
- if (liblber) {
- *mod_name = "libldap.so";
- libldap = dlopen(*mod_name, RTLD_LAZY);
- }
+ *mod_name = DL_LDAP_FILE;
+ libldap = dlopen(*mod_name, RTLD_LAZY);
}
- return (libldap != NULL && liblber != NULL);
+ return (libldap != NULL);
#elif defined(WIN32)
- *mod_name = "wldap32.dll";
+ *mod_name = DL_LDAP_FILE;
if (!libldap)
libldap = (void*)LoadLibrary(*mod_name);
return (libldap != NULL);
@@ -155,10 +157,12 @@ static void DynaClose(void)
dlclose(libldap);
libldap=NULL;
}
+#ifdef DL_LBER_FILE
if (liblber) {
dlclose(liblber);
liblber=NULL;
}
+#endif
#elif defined(WIN32)
if (libldap) {
FreeLibrary ((HMODULE)libldap);
View
3 packages/vms/config-vms.h
@@ -274,3 +274,6 @@
/* Somewhere around 7.12.0 HAVE_INET_NTOP was introduced. */
#define HAVE_INET_NTOP 1
+
+/* to disable LDAP */
+#define CURL_DISABLE_LDAP 1

0 comments on commit 205f8b2

Please sign in to comment.