| 1 |
AC_DEFUN([SUDO_CHECK_LDAP], [ |
| 2 |
if test ${with_ldap-'no'} != "no"; then |
| 3 |
O_LDFLAGS="$LDFLAGS" |
| 4 |
if test "$with_ldap" != "yes"; then |
| 5 |
SUDO_APPEND_LIBPATH(SUDOERS_LDFLAGS, [${with_ldap}/lib]) |
| 6 |
LDFLAGS="$LDFLAGS -L${with_ldap}/lib" |
| 7 |
if test -d "${with_ldap}/lib64"; then |
| 8 |
SUDO_APPEND_LIBPATH(SUDOERS_LDFLAGS, [${with_ldap}/lib64]) |
| 9 |
LDFLAGS="$LDFLAGS -L${with_ldap}/lib64" |
| 10 |
fi |
| 11 |
AX_APPEND_FLAG([-I${with_ldap}/include], [CPPFLAGS]) |
| 12 |
with_ldap=yes |
| 13 |
fi |
| 14 |
SUDOERS_OBJS="${SUDOERS_OBJS} ldap.lo ldap_conf.lo ldap_innetgr.lo" |
| 15 |
case "$SUDOERS_OBJS" in |
| 16 |
*ldap_util.lo*) ;; |
| 17 |
*) SUDOERS_OBJS="${SUDOERS_OBJS} ldap_util.lo";; |
| 18 |
esac |
| 19 |
LDAP="" |
| 20 |
|
| 21 |
_LIBS="$LIBS" |
| 22 |
LDAP_LIBS="" |
| 23 |
IBMLDAP_EXTRA="" |
| 24 |
found=no |
| 25 |
# On HP-UX, libibmldap has a hidden dependency on libCsup |
| 26 |
case "$host_os" in |
| 27 |
hpux*) AC_CHECK_LIB([Csup], [main], [IBMLDAP_EXTRA=" -lCsup"]);; |
| 28 |
esac |
| 29 |
AC_SEARCH_LIBS([ldap_init], ["ibmldap${IBMLDAP_EXTRA}" "ibmldap -lidsldif${IBMLDAP_EXTRA}" "ldap" "ldap -llber" "ldap -llber -lssl -lcrypto" "ibmldap${IBMLDAP_EXTRA}]", [ |
| 30 |
test "${ac_cv_search_ldap_init}" != "none required" && LDAP_LIBS="${ac_cv_search_ldap_init}" |
| 31 |
found=yes |
| 32 |
]) |
| 33 |
# If nothing linked, try -lldap and hope for the best |
| 34 |
if test "$found" = "no"; then |
| 35 |
LDAP_LIBS="-lldap" |
| 36 |
fi |
| 37 |
LIBS="${_LIBS} ${LDAP_LIBS}" |
| 38 |
|
| 39 |
AC_CHECK_DECL([LBER_OPT_DEBUG_LEVEL], [ |
| 40 |
case "$LDAP_LIBS" in |
| 41 |
*-llber*) |
| 42 |
# Already linking with -llber |
| 43 |
;; |
| 44 |
*) # Link with -llber for ber_set_option() if it exists |
| 45 |
AC_CHECK_LIB([lber], [ber_set_option], [found=yes], [found=no]) |
| 46 |
if test X"$found" = X"yes"; then |
| 47 |
LDAP_LIBS="$LDAP_LIBS -llber" |
| 48 |
fi |
| 49 |
;; |
| 50 |
esac |
| 51 |
], [], [AC_INCLUDES_DEFAULT |
| 52 |
#include <lber.h>]) |
| 53 |
AC_CACHE_CHECK([whether lber.h is needed when including ldap.h], [sudo_cv_header_lber_h], [ |
| 54 |
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
| 55 |
#include <ldap.h>]], [[return ldap_msgfree(NULL)]])], [ |
| 56 |
# No need to explicitly include lber.h when including ldap.h. |
| 57 |
sudo_cv_header_lber_h=no |
| 58 |
], [ |
| 59 |
sudo_cv_header_lber_h=yes |
| 60 |
]) |
| 61 |
]) |
| 62 |
if test X"$sudo_cv_header_lber_h" = X"yes"; then |
| 63 |
AC_DEFINE(HAVE_LBER_H) |
| 64 |
fi |
| 65 |
|
| 66 |
if test ${enable_sasl-'yes'} = "yes"; then |
| 67 |
found_sasl_h=no |
| 68 |
AC_CHECK_HEADERS([sasl/sasl.h] [sasl.h], [ |
| 69 |
found_sasl_h=yes |
| 70 |
AC_CHECK_FUNCS([ldap_sasl_interactive_bind_s]) |
| 71 |
break |
| 72 |
]) |
| 73 |
if test X${enable_sasl} = X"yes"; then |
| 74 |
if test X"$found_sasl_h" != X"yes"; then |
| 75 |
AC_MSG_ERROR([--enable-sasl specified but unable to locate SASL development headers.]) |
| 76 |
fi |
| 77 |
if test X"$ac_cv_func_ldap_sasl_interactive_bind_s" != X"yes"; then : |
| 78 |
AC_MSG_ERROR([--enable-sasl specified but SASL support is missing in your LDAP library]) |
| 79 |
fi |
| 80 |
fi |
| 81 |
fi |
| 82 |
AC_CHECK_HEADERS([ldapssl.h] [ldap_ssl.h] [mps/ldap_ssl.h], [break], [], [#include <ldap.h>]) |
| 83 |
AC_CHECK_FUNCS([ldap_initialize ldap_start_tls_s ldapssl_init ldapssl_set_strength ldap_unbind_ext_s ldap_str2dn ldap_create ldap_sasl_bind_s ldap_ssl_init ldap_ssl_client_init ldap_start_tls_s_np]) |
| 84 |
AC_CHECK_FUNCS([ldap_search_ext_s ldap_search_st], [break]) |
| 85 |
|
| 86 |
if test X"$check_gss_krb5_ccache_name" = X"yes"; then |
| 87 |
AC_CHECK_LIB([gssapi], [gss_krb5_ccache_name], [ |
| 88 |
AC_DEFINE(HAVE_GSS_KRB5_CCACHE_NAME) |
| 89 |
LDAP_LIBS="${LDAP_LIBS} -lgssapi" |
| 90 |
], [ |
| 91 |
AC_CHECK_LIB(gssapi_krb5, gss_krb5_ccache_name, [ |
| 92 |
AC_DEFINE(HAVE_GSS_KRB5_CCACHE_NAME) |
| 93 |
LDAP_LIBS="${LDAP_LIBS} -lgssapi_krb5" |
| 94 |
]) |
| 95 |
]) |
| 96 |
|
| 97 |
# gssapi headers may be separate or part of Kerberos V |
| 98 |
found=no |
| 99 |
O_CPPFLAGS="$CPPFLAGS" |
| 100 |
for dir in "" "kerberosV" "krb5" "kerberos5" "kerberosv5"; do |
| 101 |
test X"$dir" != X"" && CPPFLAGS="$O_CPPFLAGS -I/usr/include/${dir}" |
| 102 |
# Use AC_PREPROC_IFELSE to check existence to avoid caching |
| 103 |
# since we test with multiple values of CPPFLAGS |
| 104 |
AC_PREPROC_IFELSE([ |
| 105 |
AC_LANG_PROGRAM([[#include <gssapi/gssapi.h>]]) |
| 106 |
], [ |
| 107 |
AC_CHECK_HEADERS([gssapi/gssapi.h]) |
| 108 |
break |
| 109 |
], [ |
| 110 |
AC_PREPROC_IFELSE([ |
| 111 |
AC_LANG_PROGRAM([[#include <gssapi.h>]]) |
| 112 |
], [ |
| 113 |
AC_CHECK_HEADERS([gssapi.h]) |
| 114 |
break |
| 115 |
]) |
| 116 |
]) |
| 117 |
done |
| 118 |
if test X"$ac_cv_header_gssapi_gssapi_h" != X"no"; then |
| 119 |
AC_CHECK_HEADERS([gssapi/gssapi_krb5.h]) |
| 120 |
elif test X"$ac_cv_header_gssapi_h" = X"no"; then |
| 121 |
CPPFLAGS="$O_CPPFLAGS" |
| 122 |
AC_MSG_WARN([unable to locate gssapi.h, you will have to edit the Makefile and add -I/path/to/gssapi/includes to CPPFLAGS]) |
| 123 |
fi |
| 124 |
fi |
| 125 |
|
| 126 |
SUDOERS_LIBS="${SUDOERS_LIBS} ${LDAP_LIBS}" |
| 127 |
LIBS="$_LIBS" |
| 128 |
LDFLAGS="$O_LDFLAGS" |
| 129 |
fi |
| 130 |
]) |