From: serassio <> Date: Sat, 19 Mar 2005 22:24:07 +0000 (+0000) Subject: Bug #1258: LDAP helpers fails to compile with SUN LDAP SDK X-Git-Tag: SQUID_3_0_PRE4~831 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=20e869bf11fba5e7b98c074d91b1b76a37ddc153;p=thirdparty%2Fsquid.git Bug #1258: LDAP helpers fails to compile with SUN LDAP SDK Forward port of 2.5 patch with addition of MinGW support. --- diff --git a/configure.in b/configure.in index ca5d4043d9..c406183c12 100644 --- a/configure.in +++ b/configure.in @@ -3,7 +3,7 @@ dnl Configuration input file for Squid dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.370 2005/02/07 22:30:15 serassio Exp $ +dnl $Id: configure.in,v 1.371 2005/03/19 15:24:07 serassio Exp $ dnl dnl dnl @@ -13,7 +13,7 @@ AC_CONFIG_SRCDIR([src/main.cc]) AC_CONFIG_AUX_DIR(cfgaux) AM_INIT_AUTOMAKE(squid, 3.0-PRE3-CVS) AM_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.370 $)dnl +AC_REVISION($Revision: 1.371 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -1999,6 +1999,22 @@ case "$host" in ;; esac +dnl On MinGW OpenLDAP is not available, so LDAP helpers can be linked +dnl only with Windows LDAP libraries using -lwldap32 +case "$host_os" in +mingw|mingw32) + LIB_LDAP="-lwldap32" + LIB_LBER="" + ;; +*) + LIB_LDAP="-lldap" + dnl LDAP helpers need to know if -llber is needed or not + AC_CHECK_LIB(lber, main, [LIB_LBER="-llber"]) + ;; +esac +AC_SUBST(LIB_LDAP) +AC_SUBST(LIB_LBER) + dnl System-specific library modifications dnl case "$host" in diff --git a/helpers/basic_auth/LDAP/Makefile.am b/helpers/basic_auth/LDAP/Makefile.am index c3da4d793e..6b2bdf7957 100644 --- a/helpers/basic_auth/LDAP/Makefile.am +++ b/helpers/basic_auth/LDAP/Makefile.am @@ -1,7 +1,7 @@ # # Makefile for the Squid LDAP authentication helper # -# $Id: Makefile.am,v 1.5 2003/01/23 00:35:21 robertc Exp $ +# $Id: Makefile.am,v 1.6 2005/03/19 15:24:07 serassio Exp $ # # Uncomment and customize the following to suit your needs: # @@ -11,5 +11,5 @@ man_MANS = squid_ldap_auth.8 EXTRA_DIST = squid_ldap_auth.8 squid_ldap_auth_SOURCES = squid_ldap_auth.c -LDADD = -L$(top_builddir)/lib -lmiscutil -lldap -llber $(XTRA_LIBS) +LDADD = -L$(top_builddir)/lib -lmiscutil $(LIB_LDAP) $(LIB_LBER) $(XTRA_LIBS) INCLUDES = -I$(top_srcdir)/include diff --git a/helpers/basic_auth/LDAP/squid_ldap_auth.c b/helpers/basic_auth/LDAP/squid_ldap_auth.c index 0fde1d17c8..9c7b307033 100644 --- a/helpers/basic_auth/LDAP/squid_ldap_auth.c +++ b/helpers/basic_auth/LDAP/squid_ldap_auth.c @@ -98,7 +98,9 @@ #define LDAPAPI __cdecl #endif #ifdef LDAP_VERSION3 -#define LDAP_OPT_SUCCESS LDAP_SUCCESS +#ifndef LDAP_OPT_X_TLS +#define LDAP_OPT_X_TLS 0x6000 +#endif /* Some tricks to allow dynamic bind with ldap_start_tls_s entry point at run time. */ @@ -284,14 +286,24 @@ open_ldap_connection(const char *ldapServer, int port) version = LDAP_VERSION2; } if (ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version) - != LDAP_OPT_SUCCESS) { + != LDAP_SUCCESS) { fprintf(stderr, "Could not set LDAP_OPT_PROTOCOL_VERSION %d\n", version); exit(1); } - if (use_tls && (version == LDAP_VERSION3) && (ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS)) { - fprintf(stderr, "Could not Activate TLS connection\n"); + if (use_tls) { +#ifdef LDAP_OPT_X_TLS + if (version == LDAP_VERSION3 && ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS) { + fprintf(stderr, "Could not Activate TLS connection\n"); + exit(1); + } else { + fprintf(stderr, "TLS requires LDAP version 3\n"); + exit(1); + } +#else + fprintf(stderr, "TLS not supported with your LDAP library\n"); exit(1); +#endif } #endif squid_ldap_set_timelimit(ld, timelimit); diff --git a/helpers/external_acl/ldap_group/Makefile.am b/helpers/external_acl/ldap_group/Makefile.am index 5a9d44b0f1..7e08f39cc5 100644 --- a/helpers/external_acl/ldap_group/Makefile.am +++ b/helpers/external_acl/ldap_group/Makefile.am @@ -1,7 +1,7 @@ # # Makefile for the Squid LDAP authentication helper # -# $Id: Makefile.am,v 1.5 2004/08/14 22:54:53 hno Exp $ +# $Id: Makefile.am,v 1.6 2005/03/19 15:24:07 serassio Exp $ # # Uncomment and customize the following to suit your needs: # @@ -11,5 +11,5 @@ man_MANS = squid_ldap_group.8 EXTRA_DIST = squid_ldap_group.8 squid_ldap_group_SOURCES = squid_ldap_group.c -LDADD = -L$(top_builddir)/lib -lmiscutil -lldap -llber @XTRA_LIBS@ +LDADD = -L$(top_builddir)/lib -lmiscutil $(LIB_LDAP) $(LIB_LBER) @XTRA_LIBS@ INCLUDES = -I. -I$(top_builddir)/include -I$(top_srcdir)/include diff --git a/helpers/external_acl/ldap_group/squid_ldap_group.c b/helpers/external_acl/ldap_group/squid_ldap_group.c index ce859fef98..d97fbb83d3 100644 --- a/helpers/external_acl/ldap_group/squid_ldap_group.c +++ b/helpers/external_acl/ldap_group/squid_ldap_group.c @@ -49,7 +49,9 @@ #define LDAPAPI __cdecl #endif #ifdef LDAP_VERSION3 -#define LDAP_OPT_SUCCESS LDAP_SUCCESS +#ifndef LDAP_OPT_X_TLS +#define LDAP_OPT_X_TLS 0x6000 +#endif /* Some tricks to allow dynamic bind with ldap_start_tls_s entry point at run time. */ @@ -511,19 +513,28 @@ main(int argc, char **argv) if (version == -1) { version = LDAP_VERSION2; } - if (ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version) - != LDAP_OPT_SUCCESS) { + if (ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version) != LDAP_SUCCESS) { fprintf(stderr, "Could not set LDAP_OPT_PROTOCOL_VERSION %d\n", version); ldap_unbind(ld); ld = NULL; break; } - if (use_tls && (version == LDAP_VERSION3) && (ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS)) { - fprintf(stderr, "Could not Activate TLS connection\n"); - ldap_unbind(ld); - ld = NULL; - break; + if (use_tls) { +#ifdef LDAP_OPT_X_TLS + if (version == LDAP_VERSION3 && ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS) { + fprintf(stderr, "Could not Activate TLS connection\n"); + ldap_unbind(ld); + ld = NULL; + break; + } else { + fprintf(stderr, "TLS requires LDAP version 3\n"); + exit(1); + } +#else + fprintf(stderr, "TLS not supported with your LDAP library\n"); + exit(1); +#endif } #endif squid_ldap_set_timelimit(ld, timelimit);