Allow the internal libpq to use both openldap and mozldap

This commit is contained in:
Fridrich Štrba
2011-12-12 12:45:37 +01:00
parent cdd597746f
commit e96eb62002
2 changed files with 388 additions and 3 deletions

View File

@@ -52,15 +52,19 @@ CONFIGURE_DIR=.
BUILD_DIR=src
CONFIGURE_ACTION =
BUILD_ACTION = nmake -f win32.mak USE_SSL=1
BUILD_ACTION = nmake -f win32.mak USE_SSL=1 USE_LDAP=1 USE_MOZLDAL=1
.ELSE
CONFIGURE_DIR=.
BUILD_DIR=src/interfaces/libpq
CONFIGURE_ACTION = ./configure --without-readline --disable-shared --with-openssl
.IF "$(WITH_LDAP)" == "YES" && "$(WITH_OPENLDAP)" == "YES"
.IF "$(WITH_LDAP)" == "YES"
CONFIGURE_ACTION += --with-ldap
.ENDIF
.IF "$(WITH_OPENLDAP)" != "YES"
CONFIGURE_ACTION += --with-mozldap
.ELSE
.ENDIF
BUILD_ACTION = make -j$(GMAKE_MODULE_PARALLELISM) all-static-lib
.ENDIF

View File

@@ -1,3 +1,380 @@
--- misc/postgresql-9.1.1/src/backend/libpq/auth.c 2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1/src/backend/libpq/auth.c 2011-12-12 12:35:10.944058180 +0100
@@ -93,22 +93,11 @@
*----------------------------------------------------------------
*/
#ifdef USE_LDAP
-#ifndef WIN32
-/* We use a deprecated function to keep the codepath the same as win32. */
#define LDAP_DEPRECATED 1
-#include <ldap.h>
+#ifdef USE_MOZLDAP
+#include <mozilla/ldap/ldap.h>
#else
-#include <winldap.h>
-
-/* Correct header from the Platform SDK */
-typedef
-ULONG (*__ldap_start_tls_sA) (
- IN PLDAP ExternalHandle,
- OUT PULONG ServerReturnValue,
- OUT LDAPMessage **result,
- IN PLDAPControlA * ServerControls,
- IN PLDAPControlA * ClientControls
-);
+#include <ldap.h>
#endif
static int CheckLDAPAuth(Port *port);
--- misc/postgresql-9.1.1/src/interfaces/libpq/fe-connect.c 2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1/src/interfaces/libpq/fe-connect.c 2011-12-12 12:36:14.305233929 +0100
@@ -60,14 +60,13 @@
#endif
#ifdef USE_LDAP
-#ifdef WIN32
-#include <winldap.h>
+#ifdef USE_MOZLDAP
+#include <mozilla/ldap/ldap.h>
#else
-/* OpenLDAP deprecates RFC 1823, but we want standard conformance */
#define LDAP_DEPRECATED 1
#include <ldap.h>
-typedef struct timeval LDAP_TIMEVAL;
#endif
+typedef struct timeval LDAP_TIMEVAL;
static int ldapServiceLookup(const char *purl, PQconninfoOption *options,
PQExpBuffer errorMessage);
#endif
--- misc/postgresql-9.1.1/configure 2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1/configure 2011-12-12 12:26:58.368351739 +0100
@@ -718,6 +718,7 @@
with_selinux
with_openssl
with_bonjour
+with_mozldap
with_ldap
with_pam
krb_srvtab
@@ -836,6 +837,7 @@
with_krb_srvnam
with_pam
with_ldap
+with_mozldap
with_bonjour
with_openssl
with_selinux
@@ -1533,6 +1535,7 @@
[postgres]
--with-pam build with PAM support
--with-ldap build with LDAP support
+ --with-mozldap build with Mozilla LDAP support
--with-bonjour build with Bonjour support
--with-openssl build with OpenSSL support
--with-selinux build with SELinux support
@@ -5432,6 +5435,42 @@
$as_echo "$with_ldap" >&6; }
+{ $as_echo "$as_me:$LINENO: checking whether to use Mozilla LDAP implementation" >&5
+$as_echo_n "checking whether to use Mozilla LDAP implementation... " >&6; }
+
+
+
+# Check whether --with-mozldap was given.
+if test "${with_mozldap+set}" = set; then
+ withval=$with_mozldap;
+ case $withval in
+ yes)
+
+cat >>confdefs.h <<\_ACEOF
+#define USE_MOZLDAP 1
+_ACEOF
+
+ ;;
+ no)
+ :
+ ;;
+ *)
+ { { $as_echo "$as_me:$LINENO: error: no argument expected for --with-mozldap option" >&5
+$as_echo "$as_me: error: no argument expected for --with-mozldap option" >&2;}
+ { (exit 1); exit 1; }; }
+ ;;
+ esac
+
+else
+ with_mozldap=no
+
+fi
+
+
+{ $as_echo "$as_me:$LINENO: result: $with_mozldap" >&5
+$as_echo "$with_mozldap" >&6; }
+
+
#
# Bonjour
@@ -13584,7 +13623,7 @@
fi
if test "$with_ldap" = yes ; then
- if test "$PORTNAME" != "win32"; then
+ if test "$with_mozldap" != "yes"; then
for ac_header in ldap.h
do
@@ -13742,24 +13781,30 @@
else
-for ac_header in winldap.h
+for ac_header in mozilla/ldap/ldap.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
else
- cat >conftest.$ac_ext <<_ACEOF
+ # Is the header compilable?
+{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
+$as_echo_n "checking $ac_header usability... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
-#include <windows.h>
-
-
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
@@ -13780,20 +13825,101 @@
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
- eval "$as_ac_Header=yes"
+ ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- eval "$as_ac_Header=no"
+ ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
+$as_echo_n "checking $ac_header presence... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ ac_header_preproc=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ ( cat <<\_ASBOX
+## ---------------------------------------- ##
+## Report this to pgsql-bugs@postgresql.org ##
+## ---------------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
+
+fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
@@ -13802,8 +13928,8 @@
_ACEOF
else
- { { $as_echo "$as_me:$LINENO: error: header file <winldap.h> is required for LDAP" >&5
-$as_echo "$as_me: error: header file <winldap.h> is required for LDAP" >&2;}
+ { { $as_echo "$as_me:$LINENO: error: header file <mozilla/ldap/ldap.h> is required for LDAP" >&5
+$as_echo "$as_me: error: header file <mozilla/ldap/ldap.h> is required for LDAP" >&2;}
{ (exit 1); exit 1; }; }
fi
@@ -23348,7 +23474,7 @@
# We can test for libldap_r only after we know PTHREAD_LIBS
if test "$with_ldap" = yes ; then
_LIBS="$LIBS"
- if test "$PORTNAME" != "win32"; then
+ if test "$with_mozldap" != "yes"; then
{ $as_echo "$as_me:$LINENO: checking for ldap_bind in -lldap" >&5
$as_echo_n "checking for ldap_bind in -lldap... " >&6; }
@@ -23515,87 +23641,8 @@
LDAP_LIBS_FE="-lldap $EXTRA_LDAP_LIBS"
fi
else
-
-{ $as_echo "$as_me:$LINENO: checking for ldap_bind in -lwldap32" >&5
-$as_echo_n "checking for ldap_bind in -lwldap32... " >&6; }
-if test "${ac_cv_lib_wldap32_ldap_bind+set}" = set; then
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lwldap32 $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char ldap_bind ();
-int
-main ()
-{
-return ldap_bind ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest$ac_exeext && {
- test "$cross_compiling" = yes ||
- $as_test_x conftest$ac_exeext
- }; then
- ac_cv_lib_wldap32_ldap_bind=yes
-else
- $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_wldap32_ldap_bind=no
-fi
-
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_wldap32_ldap_bind" >&5
-$as_echo "$ac_cv_lib_wldap32_ldap_bind" >&6; }
-if test "x$ac_cv_lib_wldap32_ldap_bind" = x""yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBWLDAP32 1
-_ACEOF
-
- LIBS="-lwldap32 $LIBS"
-
-else
- { { $as_echo "$as_me:$LINENO: error: library 'wldap32' is required for LDAP" >&5
-$as_echo "$as_me: error: library 'wldap32' is required for LDAP" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
- LDAP_LIBS_FE="-lwldap32"
- LDAP_LIBS_BE="-lwldap32"
+ LDAP_LIBS_FE=
+ LDAP_LIBS_BE=
fi
LIBS="$_LIBS"
fi
--- misc/postgresql-9.1.1/src/interfaces/libpq/win32.mak 2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1/src/interfaces/libpq/win32.mak 2011-12-12 11:21:08.796898284 +0100
@@ -11,18 +11,19 @@
@@ -65,7 +442,7 @@
/D "FRONTEND" $(DEBUGDEF) \
/D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\libpq.pch" \
/Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c \
@@ -189,6 +183,11 @@
@@ -189,6 +183,15 @@
SSL_LIBS=ssleay32.lib libeay32.lib gdi32.lib
!ENDIF
@@ -73,6 +450,10 @@
+CPP_PROJ=$(CPP_PROJ) /D USE_LDAP
+LDAP_LIBS=wldap32.lib
+!ENDIF
+
+!IFDEF USE_MOZLDAP
+CPP_PROJ=$(CPP_PROJ) /D USE_MOZLDAP
+!ENDIF
+
!IFDEF USE_KFW
CPP_PROJ=$(CPP_PROJ) /D KRB5