summaryrefslogtreecommitdiffstats
path: root/m4
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2009-07-06 12:11:01 -0600
committerRich Megginson <rmeggins@redhat.com>2009-07-07 08:32:42 -0600
commit209521323f731daad54682fd98715f7b22c88c78 (patch)
tree74a1fa8df06641fe543c8518e4db4357ab610828 /m4
parent3116dbec570b65d2d0a1df5bd000f6e63439e8ee (diff)
downloadds-209521323f731daad54682fd98715f7b22c88c78.tar.gz
ds-209521323f731daad54682fd98715f7b22c88c78.tar.xz
ds-209521323f731daad54682fd98715f7b22c88c78.zip
OpenLDAP support
These changes allow the server to be built with OpenLDAP (2.4.17+). A brief summary of the changes: * #defines not provided by OpenLDAP were copied into slapi-plugin.h and protected with #ifndef blocks * where it made sense, I created slapi wrapper functions for things like URL and LDIF processing to abstract way the differences in the APIs * I created a new file utf8.c which contains the UTF8 functions from MozLDAP - this is only compiled when using OpenLDAP * I tried to clean up the code - use the _ext versions of LDAP functions everywhere since the older versions should be considered deprecated * I removed some unused code NOTE that this should still be considered a work in progress since it depends on functionality not yet present in a released version of OpenLDAP, for NSS crypto and for the LDIF public API.
Diffstat (limited to 'm4')
-rw-r--r--m4/mozldap.m488
-rw-r--r--m4/openldap.m4147
2 files changed, 198 insertions, 37 deletions
diff --git a/m4/mozldap.m4 b/m4/mozldap.m4
index 9bfd4fa2..475e868b 100644
--- a/m4/mozldap.m4
+++ b/m4/mozldap.m4
@@ -18,13 +18,16 @@
#
# END COPYRIGHT BLOCK
-AC_CHECKING(for LDAPSDK)
+AC_CHECKING(for Mozilla LDAPSDK)
# check for --with-ldapsdk
AC_MSG_CHECKING(for --with-ldapsdk)
AC_ARG_WITH(ldapsdk, [ --with-ldapsdk=PATH Mozilla LDAP SDK directory],
[
- if test -e "$withval"/include/ldap.h -a -d "$withval"/lib
+ if test "$withval" = yes
+ then
+ AC_MSG_RESULT([using system MozLDAP])
+ elif test -e "$withval"/include/ldap.h -a -d "$withval"/lib
then
AC_MSG_RESULT([using $withval])
LDAPSDKDIR=$withval
@@ -32,6 +35,7 @@ AC_ARG_WITH(ldapsdk, [ --with-ldapsdk=PATH Mozilla LDAP SDK directory],
ldapsdk_lib="-L$LDAPSDKDIR/lib"
ldapsdk_libdir="$LDAPSDKDIR/lib"
ldapsdk_bindir="$LDAPSDKDIR/bin"
+ with_ldapsdk=yes
else
echo
AC_MSG_ERROR([$withval not found])
@@ -47,6 +51,7 @@ AC_ARG_WITH(ldapsdk-inc, [ --with-ldapsdk-inc=PATH Mozilla LDAP SDK include
then
AC_MSG_RESULT([using $withval])
ldapsdk_inc="-I$withval"
+ with_ldapsdk=yes
else
echo
AC_MSG_ERROR([$withval not found])
@@ -63,6 +68,7 @@ AC_ARG_WITH(ldapsdk-lib, [ --with-ldapsdk-lib=PATH Mozilla LDAP SDK library
AC_MSG_RESULT([using $withval])
ldapsdk_lib="-L$withval"
ldapsdk_libdir="$withval"
+ with_ldapsdk=yes
else
echo
AC_MSG_ERROR([$withval not found])
@@ -78,6 +84,7 @@ AC_ARG_WITH(ldapsdk-bin, [ --with-ldapsdk-bin=PATH Mozilla LDAP SDK binary
then
AC_MSG_RESULT([using $withval])
ldapsdk_bindir="$withval"
+ with_ldapsdk=yes
else
echo
AC_MSG_ERROR([$withval not found])
@@ -88,49 +95,56 @@ AC_MSG_RESULT(no))
# if LDAPSDK is not found yet, try pkg-config
# last resort
-if test -z "$ldapsdk_inc" -o -z "$ldapsdk_lib" -o -z "$ldapsdk_libdir" -o -z "$ldapsdk_bindir"; then
- AC_PATH_PROG(PKG_CONFIG, pkg-config)
- AC_MSG_CHECKING(for mozldap with pkg-config)
- if test -n "$PKG_CONFIG"; then
- if $PKG_CONFIG --exists mozldap6; then
- mozldappkg=mozldap6
- elif $PKG_CONFIG --exists mozldap; then
- mozldappkg=mozldap
- else
- AC_MSG_ERROR([LDAPSDK not found, specify with --with-ldapsdk[-inc|-lib|-bin].])
+if test "$with_ldapsdk" = yes ; then
+ if test -z "$ldapsdk_inc" -o -z "$ldapsdk_lib" -o -z "$ldapsdk_libdir" -o -z "$ldapsdk_bindir"; then
+ AC_PATH_PROG(PKG_CONFIG, pkg-config)
+ AC_MSG_CHECKING(for mozldap with pkg-config)
+ if test -n "$PKG_CONFIG"; then
+ if $PKG_CONFIG --exists mozldap6; then
+ mozldappkg=mozldap6
+ elif $PKG_CONFIG --exists mozldap; then
+ mozldappkg=mozldap
+ else
+ AC_MSG_ERROR([LDAPSDK not found, specify with --with-ldapsdk[-inc|-lib|-bin].])
+ fi
+ ldapsdk_inc=`$PKG_CONFIG --cflags-only-I $mozldappkg`
+ ldapsdk_lib=`$PKG_CONFIG --libs-only-L $mozldappkg`
+ ldapsdk_libdir=`$PKG_CONFIG --libs-only-L $mozldappkg | sed -e s/-L// | sed -e s/\ .*$//`
+ ldapsdk_bindir=`$PKG_CONFIG --variable=bindir $mozldappkg`
+ AC_MSG_RESULT([using system $mozldappkg])
fi
- ldapsdk_inc=`$PKG_CONFIG --cflags-only-I $mozldappkg`
- ldapsdk_lib=`$PKG_CONFIG --libs-only-L $mozldappkg`
- ldapsdk_libdir=`$PKG_CONFIG --libs-only-L $mozldappkg | sed -e s/-L// | sed -e s/\ .*$//`
- ldapsdk_bindir=`$PKG_CONFIG --variable=bindir $mozldappkg`
- AC_MSG_RESULT([using system $mozldappkg])
fi
fi
-if test -z "$ldapsdk_inc" -o -z "$ldapsdk_lib"; then
- AC_MSG_ERROR([LDAPSDK not found, specify with --with-ldapsdk[-inc|-lib|-bin].])
-fi
+
+if test "$with_ldapsdk" = yes ; then
+ if test -z "$ldapsdk_inc" -o -z "$ldapsdk_lib"; then
+ AC_MSG_ERROR([LDAPSDK not found, specify with --with-ldapsdk[-inc|-lib|-bin].])
+ fi
dnl default path for the ldap c sdk tools (see [210947] for more details)
-if test -z "$ldapsdk_bindir" ; then
- if [ -d $libdir/mozldap6 ] ; then
- ldapsdk_bindir=$libdir/mozldap6
- else
- ldapsdk_bindir=$libdir/mozldap
+ if test -z "$ldapsdk_bindir" ; then
+ if [ -d $libdir/mozldap6 ] ; then
+ ldapsdk_bindir=$libdir/mozldap6
+ else
+ ldapsdk_bindir=$libdir/mozldap
+ fi
fi
-fi
-dnl make sure the ldap sdk version is 6 or greater - we do not support
-dnl the old 5.x or prior versions - the ldap server code expects the new
-dnl ber types and other code used with version 6
-save_cppflags="$CPPFLAGS"
-CPPFLAGS="$ldapsdk_inc $nss_inc $nspr_inc"
-AC_CHECK_HEADER([ldap.h], [isversion6=1], [isversion6=],
-[#include <ldap-standard.h>
+ dnl make sure the ldap sdk version is 6 or greater - we do not support
+ dnl the old 5.x or prior versions - the ldap server code expects the new
+ dnl ber types and other code used with version 6
+ save_cppflags="$CPPFLAGS"
+ CPPFLAGS="$ldapsdk_inc $nss_inc $nspr_inc"
+ AC_CHECK_HEADER([ldap.h], [isversion6=1], [isversion6=],
+ [#include <ldap-standard.h>
#if LDAP_VENDOR_VERSION < 600
#error The LDAP C SDK version is not supported
#endif
-])
-CPPFLAGS="$save_cppflags"
+ ])
+ CPPFLAGS="$save_cppflags"
-if test -z "$isversion6" ; then
- AC_MSG_ERROR([The LDAPSDK version in $ldapsdk_inc/ldap-standard.h is not supported])
+ if test -z "$isversion6" ; then
+ AC_MSG_ERROR([The LDAPSDK version in $ldapsdk_inc/ldap-standard.h is not supported])
+ fi
+ AC_DEFINE([USE_MOZLDAP], [1], [If defined, using MozLDAP for LDAP SDK])
+ AC_DEFINE([HAVE_LDAP_URL_PARSE_NO_DEFAULTS], [1], [have the function ldap_url_parse_no_defaults])
fi
diff --git a/m4/openldap.m4 b/m4/openldap.m4
new file mode 100644
index 00000000..29dc1158
--- /dev/null
+++ b/m4/openldap.m4
@@ -0,0 +1,147 @@
+# BEGIN COPYRIGHT BLOCK
+# Copyright (C) 2009 Red Hat, Inc.
+# All rights reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# END COPYRIGHT BLOCK
+
+AC_CHECKING(for OpenLDAP)
+
+# check for --with-openldap
+AC_MSG_CHECKING(for --with-openldap)
+AC_ARG_WITH(openldap, AS_HELP_STRING([--with-openldap[=PATH]],[Use OpenLDAP - optional PATH is path to OpenLDAP SDK]),
+[
+ if test "$withval" = yes
+ then
+ AC_MSG_RESULT([using system OpenLDAP])
+ elif test -e "$withval"/include/ldap.h -a -d "$withval"/lib
+ then
+ AC_MSG_RESULT([using $withval])
+ OPENLDAPDIR=$withval
+ openldap_incdir="$OPENLDAPDIR/include"
+ openldap_inc="-I$openldap_incdir"
+ openldap_lib="-L$OPENLDAPDIR/lib"
+ openldap_libdir="$OPENLDAPDIR/lib"
+ openldap_bindir="$OPENLDAPDIR/bin"
+ with_openldap=yes
+ else
+ echo
+ AC_MSG_ERROR([$withval not found])
+ fi
+],
+AC_MSG_RESULT(no))
+
+# check for --with-openldap-inc
+AC_MSG_CHECKING(for --with-openldap-inc)
+AC_ARG_WITH(openldap-inc, [ --with-openldap-inc=PATH OpenLDAP SDK include directory],
+[
+ if test -e "$withval"/ldap.h
+ then
+ AC_MSG_RESULT([using $withval])
+ openldap_incdir="$withval"
+ openldap_inc="-I$withval"
+ with_openldap=yes
+ else
+ echo
+ AC_MSG_ERROR([$withval not found])
+ fi
+],
+AC_MSG_RESULT(no))
+
+# check for --with-openldap-lib
+AC_MSG_CHECKING(for --with-openldap-lib)
+AC_ARG_WITH(openldap-lib, [ --with-openldap-lib=PATH OpenLDAP SDK library directory],
+[
+ if test -d "$withval"
+ then
+ AC_MSG_RESULT([using $withval])
+ openldap_lib="-L$withval"
+ openldap_libdir="$withval"
+ with_openldap=yes
+ else
+ echo
+ AC_MSG_ERROR([$withval not found])
+ fi
+],
+AC_MSG_RESULT(no))
+
+# check for --with-openldap-bin
+AC_MSG_CHECKING(for --with-openldap-bin)
+AC_ARG_WITH(openldap-bin, [ --with-openldap-bin=PATH OpenLDAP SDK binary directory],
+[
+ if test -d "$withval"
+ then
+ AC_MSG_RESULT([using $withval])
+ openldap_bindir="$withval"
+ with_openldap=yes
+ else
+ echo
+ AC_MSG_ERROR([$withval not found])
+ fi
+],
+AC_MSG_RESULT(no))
+
+# if OPENLDAP is not found yet, try pkg-config
+
+if test -z "$openldap_inc" -o -z "$openldap_lib" -o -z "$openldap_libdir" -o -z "$openldap_bindir"; then
+ if test "$with_openldap" = yes ; then # user wants to use openldap, but didn't specify paths
+ AC_PATH_PROG(PKG_CONFIG, pkg-config)
+ AC_MSG_CHECKING(for OpenLDAP with pkg-config)
+ if test -n "$PKG_CONFIG" && $PKG_CONFIG --exists openldap; then
+ openldap_inc=`$PKG_CONFIG --cflags-only-I openldap`
+ openldap_lib=`$PKG_CONFIG --libs-only-L openldap`
+ openldap_libdir=`$PKG_CONFIG --libs-only-L openldap | sed -e s/-L// | sed -e s/\ .*$//`
+ openldap_bindir=`$PKG_CONFIG --variable=bindir openldap`
+ openldap_incdir=`$PKG_CONFIG --variable=includedir openldap`
+ AC_MSG_RESULT([using system OpenLDAP from pkg-config])
+ else
+ openldap_incdir="/usr/include"
+ openldap_inc="-I$openldap_incdir"
+ AC_MSG_RESULT([no OpenLDAP pkg-config files])
+ fi
+ fi
+fi
+
+dnl lets see if we can find the headers and libs
+
+if test "$with_openldap" = yes ; then
+ save_cppflags="$CPPFLAGS"
+ CPPFLAGS="$openldap_inc $nss_inc $nspr_inc"
+ AC_CHECK_HEADER([ldap_features.h], [],
+ [AC_MSG_ERROR([specified with-openldap but ldap_features.h not found])])
+ dnl figure out which version we're using from the header file
+ ol_ver_maj=`grep LDAP_VENDOR_VERSION_MAJOR $openldap_incdir/ldap_features.h | awk '{print $3}'`
+ ol_ver_min=`grep LDAP_VENDOR_VERSION_MINOR $openldap_incdir/ldap_features.h | awk '{print $3}'`
+ ol_ver_pat=`grep LDAP_VENDOR_VERSION_PATCH $openldap_incdir/ldap_features.h | awk '{print $3}'`
+ dnl full libname is libname-$maj.$min
+ ol_libver="-${ol_ver_maj}.${ol_ver_min}"
+ dnl look for ldap lib
+ save_ldflags="$LDFLAGS"
+ LDFLAGS="$openldap_lib $LDFLAGS"
+ AC_CHECK_LIB([ldap$ol_libver], [ldap_initialize], [have_ldap_lib=1])
+ if test -z "$have_ldap_lib" ; then
+ AC_CHECK_LIB([ldap], [ldap_initialize], [unset ol_libver],
+ [AC_MSG_ERROR([specified with-openldap but libldap not found])])
+ fi
+ dnl look for ldap_url_parse_ext
+ AC_CHECK_LIB([ldap$ol_libver], [ldap_url_parse_ext],
+ [AC_DEFINE([HAVE_LDAP_URL_PARSE_EXT], [1], [have the function ldap_url_parse_ext])])
+ LDFLAGS="$save_ldflags"
+ CPPFLAGS="$save_cppflags"
+
+ AC_DEFINE([USE_OPENLDAP], [1], [If defined, using OpenLDAP for LDAP SDK])
+ with_ldapsdk=no # using openldap not mozldap
+fi