From 54b4daa19fa04d513d0ee9baf8e253d05f6c08cb Mon Sep 17 00:00:00 2001 From: Radoslaw Korzeniewski Date: Thu, 24 Sep 2020 17:00:46 +0200 Subject: [PATCH] Add LDAP lib detection to configure --- bacula/autoconf/config.h.in | 16 +++-- bacula/autoconf/configure.in | 118 ++++++++++++++++++++++++++++++++++- 2 files changed, 128 insertions(+), 6 deletions(-) diff --git a/bacula/autoconf/config.h.in b/bacula/autoconf/config.h.in index 3be2873d4..5b057b119 100644 --- a/bacula/autoconf/config.h.in +++ b/bacula/autoconf/config.h.in @@ -7,7 +7,7 @@ * Copyright (C) 2000-2020 Kern Sibbald * License: BSD 2-Clause; see file LICENSE-FOSS */ - + /* Define if you want to use MySQL as Catalog database */ #undef USE_MYSQL_DB @@ -97,13 +97,13 @@ #undef HAVE_U_INT64_T #undef HAVE_INTMAX_T #undef HAVE_U_INTMAX_T - + /* Define if you want TCP Wrappers support */ #undef HAVE_LIBWRAP /* Define if you have sys/bitypes.h */ #undef HAVE_SYS_BITYPES_H - + /* Directory for PID files */ #undef _PATH_BACULA_PIDDIR @@ -155,7 +155,7 @@ #undef lld #undef llu -#undef HAVE_READLINE +#undef HAVE_READLINE #undef HAVE_GMP @@ -182,7 +182,7 @@ #undef HAVE_OLD_SOCKOPT #undef USE_THR_SETCONCURRENCY - + /* Defined if Gtk+-2.4 or greater is present */ #undef HAVE_GTK_2_4 @@ -1116,6 +1116,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_ZLIB_H +/* Define to 1 if you have working ldap libraries */ +#undef HAVE_LDAP + +/* Define to 1 if you have ldap_start_tls() in ldap libraries */ +#undef HAVE_LDAP_START_TLS + /* Define to 1 if you have the `__argz_count' function. */ #undef HAVE___ARGZ_COUNT diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 8fffc1f22..a780e0b9c 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -210,6 +210,7 @@ if test x$use_libtool != xno; then LIBTOOL_CLEAN_TARGET="libtool-clean" QMAKE_LIBTOOL="${BUILD_DIR}/libtool" FD_PLUGIN_DIR="src/plugins/fd" + DIR_PLUGIN_DIR="src/plugins/dir" have_plugins=yes else DEFAULT_OBJECT_TYPE=".o" @@ -221,6 +222,7 @@ else LIBTOOL_CLEAN_TARGET="" QMAKE_LIBTOOL="# ${BUILD_DIR}/libtool" FD_PLUGIN_DIR="" + DIR_PLUGIN_DIR="" have_plugins=no fi @@ -618,9 +620,19 @@ AC_ARG_ENABLE(build-dird, DIRD_DIR="src/dird" DIR_TOOLS="DIRTOOLS" +DIR_PLUGIN_DIR="src/plugins/dir" + +if test x$build_dird = xyes; then + DIRD_DIR="src/dird" + DIR_TOOLS="DIRTOOLS" +else + DIRD_DIR="" + DIR_TOOLS="NODIRTOOLS" +fi AC_SUBST(DIRD_DIR) AC_SUBST(DIR_TOOLS) +AC_SUBST(DIR_PLUGIN_DIR) dnl ------------------------------------------- dnl stored (default on) @@ -3256,6 +3268,108 @@ fi AC_SUBST(FD_PLUGIN_DIR) dnl +dnl Check for LDAP libraries +dnl +LDAP_LIBS="" +LDAP_LDFLAGS="" +LDAP_INC="" +LDAP_TARGET="" +LDAP_TARGET_INSTALL="" +ldap_support=no +ldap_start_tls_support=no +AC_ARG_WITH(ldap, + AC_HELP_STRING([--with-ldap@<:@=DIR@:>@], [enable LDAP support]), + [ + case "$with_ldap" in + no) + : + ;; + yes|*) + if test -f ${with_ldap}/include/ldap.h; then + LDAP_INC="-I${with_ldap}/include" + LDAP_LDFLAGS="-L${with_ldap}/lib" + with_ldap="${with_ldap}/include" + else + with_ldap="/usr/include" + fi + AC_CHECK_HEADER(${with_ldap}/ldap.h, + [ + AC_DEFINE(HAVE_LDAP, 1, [Define to 1 if you have ldap]) + AC_CHECK_LIB(ldap, ldap_init, + [ AC_CHECK_LIB(lber, ber_bvfree, + [ + ldap_support=yes + LDAP_LIBS="-lldap -llber" + ], + [ AC_CHECK_FUNC(ber_bvfree, + [ + ldap_support=yes + LDAP_LIBS="-lldap -llber" + ] + )] + )], [ AC_CHECK_FUNC(ldap_init) ]) + AC_CHECK_FUNC(ldap_start_tls, + [ ldap_start_tls_support=yes ], + [ AC_CHECK_LIB(ldap, ldap_start_tls, + [ + ldap_start_tls_support=yes + AC_DEFINE(HAVE_LDAP_START_TLS, 1, [Define to 1 if you have ldap_start_tls]) + ]) + ]) + ], [ AC_MSG_NOTICE("ldap.h not found. LDAP turned off ...") ]) + ;; + esac + ] +) +AC_SUBST(LDAP_LDFLAGS) +AC_SUBST(LDAP_INC) +AC_SUBST(LDAP_LIBS) + +dnl + +dnl Enable/Disable plugin support +dnl + +PLUGCONFILES="" + +dnl +dnl Bacula Pluggable Authentication Modules - Director Plugins +dnl + +dnl Director LDAP Auth Plugin +support_ldap_bpam=auto +AC_ARG_ENABLE(ldap-bpam, + AC_HELP_STRING([--disable-ldap-bpam], [disable LDAP BPAM support @<:@default=auto@:>@]), + [ + if test x$enableval = xyes; then + support_ldap_bpam=yes + elif test x$enableval = xno; then + support_ldap_bpam=disabled + fi + ] +) +if test x$support_ldap_bpam = xyes -o x$support_ldap_bpam = xauto; then + if test x$ldap_support = xyes; then + support_ldap_bpam=yes + BPAM_LDAP_TARGET="ldap-dir.la ldaptest" + BPAM_LDAP_TARGET_INSTALL="all install-ldap install-ldaptest" + else + if test x$support_ldap_bpam = xyes; then + AC_MSG_ERROR("Director LDAP Plugin enabled but no required libraries found. Please check for LDAP library support and set a proper --with-ldap=... parameter.") + fi + support_ldap_bpam=no + fi +fi +if test x$support_ldap_bpam = xyes; then + DIR_PLUGIN_DIR="$DIR_PLUGIN_DIR src/plugins/dir/ldap/src" + PLUGCONFILES="${PLUGCONFILES} src/plugins/dir/ldap/src/Makefile" +fi + +AC_SUBST(BPAM_LDAP_TARGET) +AC_SUBST(BPAM_LDAP_TARGET_INSTALL) + +AC_SUBST(DIR_PLUGIN_DIR) + dnl Check for headers, functions and libraries required to support dnl keeping readall capabilities dnl @@ -3949,6 +4063,8 @@ Configuration on `date`: build-dird: ${build_dird} build-stored: ${build_stored} Plugin support: ${have_plugins} + LDAP support: ${ldap_support} + LDAP StartTLS support: ${ldap_start_tls_support} AFS support: ${have_afs} ACL support: ${have_acl} XATTR support: ${have_xattr} @@ -3958,7 +4074,7 @@ Configuration on `date`: Plugins: - Docker: ${support_docker} - + - LDAP BPAM: ${support_ldap_bpam} " > config.out # create a small shell script useful for support with -- 2.47.3