From 5d76a2440ce442462f81a8671290e1e70fbc0a67 Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Mar 29 2019 01:39:47 +0000 Subject: [PATCH 1/12] Use PKG_CHECK_MODULES to detect the event library --- diff --git a/Makefile.am b/Makefile.am index ec65c1d..e06f7c0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,7 +32,6 @@ PROFILING_DEFINES = @profiling_defs@ NSPR_INCLUDES = @nspr_inc@ SASL_INCLUDES = @sasl_inc@ -EVENT_INCLUDES = @event_inc@ # Rust inclusions. if RUST_ENABLE @@ -146,7 +145,7 @@ DSINTERNAL_CPPFLAGS = -I$(srcdir)/include/ldaputil # Flags for Datastructure Library SDS_CPPFLAGS = $(SDS_INCLUDES) $(NSPR_INCLUDES) # Flags for nunc-stans -NUNCSTANS_CPPFLAGS = $(NSPR_INCLUDES) $(NUNCSTANS_INCLUDES) $(SDS_INCLUDES) $(EVENT_INCLUDES) +NUNCSTANS_CPPFLAGS = $(NSPR_INCLUDES) $(NUNCSTANS_INCLUDES) $(SDS_INCLUDES) $(EVENT_CFLAGS) #------------------------ # Linker Flags @@ -176,7 +175,7 @@ PCRE_LINK = @pcre_lib@ -lpcre NETSNMP_LINK = @netsnmp_lib@ @netsnmp_link@ PAM_LINK = -lpam KERBEROS_LINK = $(kerberos_lib) -EVENT_LINK = @event_lib@ +EVENT_LINK = $(EVENT_LIBS) PW_CRACK_LINK = -lcrack LIBSOCKET=@LIBSOCKET@ diff --git a/configure.ac b/configure.ac index 2e733e5..27b2944 100644 --- a/configure.ac +++ b/configure.ac @@ -816,7 +816,8 @@ AM_CONDITIONAL([FREEBSD],[test "$platform" = "freebsd"]) AM_CONDITIONAL([SPARC],[test "x$TARGET" = xSPARC]) # Check for library dependencies -m4_include(m4/event.m4) +PKG_CHECK_MODULES([EVENT], [libevent]) + m4_include(m4/nspr.m4) m4_include(m4/nss.m4) m4_include(m4/openldap.m4) diff --git a/m4/event.m4 b/m4/event.m4 deleted file mode 100644 index 8320459..0000000 --- a/m4/event.m4 +++ /dev/null @@ -1,51 +0,0 @@ -# BEGIN COPYRIGHT BLOCK -# Copyright (C) 2015 Red Hat -# see files 'COPYING' and 'COPYING.openssl' for use and warranty -# information -# -# 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 3 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, see . -# -# Additional permission under GPLv3 section 7: -# -# If you modify this Program, or any covered work, by linking or -# combining it with OpenSSL, or a modified version of OpenSSL licensed -# under the OpenSSL license -# (https://www.openssl.org/source/license.html), the licensors of this -# Program grant you additional permission to convey the resulting -# work. Corresponding Source for a non-source form of such a -# combination shall include the source code for the parts that are -# licensed under the OpenSSL license as well as that of the covered -# work. -# END COPYRIGHT BLOCK -AC_CHECKING(for EVENT) - -# Always use pkgconfig, because we know it's installed properly! - -AC_MSG_CHECKING(for event with pkg-config) -AC_PATH_PROG(PKG_CONFIG, pkg-config) -if test -n "$PKG_CONFIG"; then - if $PKG_CONFIG --exists libevent; then - event_inc=`$PKG_CONFIG --cflags libevent` - event_lib=`$PKG_CONFIG --libs libevent` - AC_MSG_RESULT([using system EVENT]) - else - AC_MSG_ERROR([EVENT not found, check with pkg-config libevent!]) - fi -fi - -AC_SUBST(event_inc) -AC_SUBST(event_lib) - - - From f56f78dbaeac7476c872e2b24eed34d9d738af23 Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Mar 29 2019 01:39:47 +0000 Subject: [PATCH 2/12] Use PKG_CHECK_MODULES to detect the nspr library --- diff --git a/Makefile.am b/Makefile.am index e06f7c0..e87f35e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -29,7 +29,7 @@ SYSTEMD_DEFINES = @systemd_defs@ CMOCKA_INCLUDES = @cmocka_inc@ PROFILING_DEFINES = @profiling_defs@ -NSPR_INCLUDES = @nspr_inc@ +NSPR_INCLUDES = $(NSPR_CFLAGS) SASL_INCLUDES = @sasl_inc@ @@ -154,7 +154,7 @@ SYSTEMD_LINK = @systemd_lib@ CMOCKA_LINKS = @cmocka_lib@ PROFILING_LINKS = @profiling_links@ -NSPR_LINK = @nspr_lib@ -lplc4 -lplds4 -lnspr4 +NSPR_LINK = $(NSPR_LIBS) NSS_LINK = @nss_lib@ -lssl3 -lnss3 if OPENLDAP @@ -1973,7 +1973,7 @@ libwhoami_plugin_la_LDFLAGS = -avoid-version #------------------------ dbscan_SOURCES = ldap/servers/slapd/tools/dbscan.c -dbscan_CPPFLAGS = @db_inc@ @nspr_inc@ $(AM_CPPFLAGS) +dbscan_CPPFLAGS = @db_inc@ $(NSPR_INCLUDES) $(AM_CPPFLAGS) dbscan_LDADD = $(NSPR_LINK) $(DB_LINK) #------------------------ @@ -2221,7 +2221,6 @@ fixupcmd = sed \ -e 's,@sbindir\@,$(sbindir),g' \ -e 's,@libdir\@,$(libdir),g' \ -e 's,@libexecdir\@,$(libexecdir),g' \ - -e 's,@nspr_libdir\@,$(nspr_libdir),g' \ -e 's,@nss_libdir\@,$(nss_libdir),g' \ -e 's,@ldapsdk_libdir\@,$(ldapsdk_libdir),g' \ -e 's,@ldapsdk_bindir\@,$(ldapsdk_bindir),g' \ diff --git a/configure.ac b/configure.ac index 27b2944..a7318ce 100644 --- a/configure.ac +++ b/configure.ac @@ -818,7 +818,12 @@ AM_CONDITIONAL([SPARC],[test "x$TARGET" = xSPARC]) # Check for library dependencies PKG_CHECK_MODULES([EVENT], [libevent]) -m4_include(m4/nspr.m4) +if $PKG_CONFIG --exists nspr; then + PKG_CHECK_MODULES([NSPR], [nspr]) +else + PKG_CHECK_MODULES([NSPR], [dirsec-nspr]) +fi + m4_include(m4/nss.m4) m4_include(m4/openldap.m4) m4_include(m4/mozldap.m4) diff --git a/m4/mozldap.m4 b/m4/mozldap.m4 index 8084ed8..40fdb88 100644 --- a/m4/mozldap.m4 +++ b/m4/mozldap.m4 @@ -145,7 +145,7 @@ dnl default path for the ldap c sdk tools (see [210947] for more details) 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" + CPPFLAGS="$ldapsdk_inc $nss_inc $NSPR_CFLAGS" AC_CHECK_HEADER([ldap.h], [isversion6=1], [isversion6=], [#include #if LDAP_VENDOR_VERSION < 600 diff --git a/m4/nspr.m4 b/m4/nspr.m4 deleted file mode 100644 index 503a87f..0000000 --- a/m4/nspr.m4 +++ /dev/null @@ -1,93 +0,0 @@ -# BEGIN COPYRIGHT BLOCK -# Copyright (C) 2007 Red Hat, Inc. -# All rights reserved. -# -# License: GPL (version 3 or any later version). -# See LICENSE for details. -# END COPYRIGHT BLOCK - -AC_CHECKING(for NSPR) - -# check for --with-nspr -AC_MSG_CHECKING(for --with-nspr) -AC_ARG_WITH(nspr, AS_HELP_STRING([--with-nspr@<:@=PATH@:>@],[Netscape Portable Runtime (NSPR) directory]), -[ - if test "$withval" = "yes" - then - AC_MSG_RESULT(yes) - elif test "$withval" = "no" - then - AC_MSG_RESULT(no) - AC_MSG_ERROR([NSPR is required.]) - elif test -e "$withval"/include/nspr.h -a -d "$withval"/lib - then - AC_MSG_RESULT([using $withval]) - NSPRDIR=$withval - nspr_inc="-I$NSPRDIR/include" - nspr_lib="-L$NSPRDIR/lib" - nspr_libdir="$NSPRDIR/lib" - else - echo - AC_MSG_ERROR([$withval not found]) - fi -], -AC_MSG_RESULT(yes)) - -# check for --with-nspr-inc -AC_MSG_CHECKING(for --with-nspr-inc) -AC_ARG_WITH(nspr-inc, AS_HELP_STRING([--with-nspr-inc=PATH],[Netscape Portable Runtime (NSPR) include directory]), -[ - if test -e "$withval"/nspr.h - then - AC_MSG_RESULT([using $withval]) - nspr_inc="-I$withval" - else - echo - AC_MSG_ERROR([$withval not found]) - fi -], -AC_MSG_RESULT(no)) - -# check for --with-nspr-lib -AC_MSG_CHECKING(for --with-nspr-lib) -AC_ARG_WITH(nspr-lib, AS_HELP_STRING([--with-nspr-lib=PATH],[Netscape Portable Runtime (NSPR) library directory]), -[ - if test -d "$withval" - then - AC_MSG_RESULT([using $withval]) - nspr_lib="-L$withval" - nspr_libdir="$withval" - else - echo - AC_MSG_ERROR([$withval not found]) - fi -], -AC_MSG_RESULT(no)) - -# if NSPR is not found yet, try pkg-config - -# last resort -if test -z "$nspr_inc" -o -z "$nspr_lib" -o -z "$nspr_libdir"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config) - AC_MSG_CHECKING(for nspr with pkg-config) - if test -n "$PKG_CONFIG"; then - if $PKG_CONFIG --exists nspr; then - nspr_inc=`$PKG_CONFIG --cflags-only-I nspr` - nspr_lib=`$PKG_CONFIG --libs-only-L nspr` - nspr_libdir=`$PKG_CONFIG --libs-only-L nspr | sed -e s/-L// | sed -e s/\ .*$//` - AC_MSG_RESULT([using system NSPR]) - elif $PKG_CONFIG --exists dirsec-nspr; then - nspr_inc=`$PKG_CONFIG --cflags-only-I dirsec-nspr` - nspr_lib=`$PKG_CONFIG --libs-only-L dirsec-nspr` - nspr_libdir=`$PKG_CONFIG --libs-only-L dirsec-nspr | sed -e s/-L// | sed -e s/\ .*$//` - AC_MSG_RESULT([using system dirsec NSPR]) - else - AC_MSG_ERROR([NSPR not found, specify with --with-nspr.]) - fi - fi -fi - -AC_SUBST(nspr_inc) -AC_SUBST(nspr_lib) -AC_SUBST(nspr_libdir) - diff --git a/m4/openldap.m4 b/m4/openldap.m4 index f3381ff..71a05b5 100644 --- a/m4/openldap.m4 +++ b/m4/openldap.m4 @@ -118,7 +118,7 @@ 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" + CPPFLAGS="$openldap_inc $nss_inc $NSPR_CFLAGS" 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 From a7f1dd0858248ab2b5ffafc34df980e6ee7f4898 Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Mar 29 2019 01:39:47 +0000 Subject: [PATCH 3/12] Use PKG_CHECK_MODULES to detect the nss library --- diff --git a/Makefile.am b/Makefile.am index e87f35e..57f42f8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -139,7 +139,7 @@ AM_CFLAGS = $(DEBUG_CFLAGS) $(GCCSEC_CFLAGS) $(ASAN_CFLAGS) $(MSAN_CFLAGS) $(TSA AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(GCCSEC_CFLAGS) $(ASAN_CFLAGS) $(MSAN_CFLAGS) $(TSAN_CFLAGS) $(UBSAN_CFLAGS) # Flags for Directory Server # WARNING: This needs a clean up, because slap.h is a horrible mess and is publically exposed! -DSPLUGIN_CPPFLAGS = $(DS_DEFINES) $(DS_INCLUDES) $(PATH_DEFINES) $(SYSTEMD_DEFINES) $(NUNCSTANS_INCLUDES) @openldap_inc@ @ldapsdk_inc@ @nss_inc@ $(NSPR_INCLUDES) @systemd_inc@ +DSPLUGIN_CPPFLAGS = $(DS_DEFINES) $(DS_INCLUDES) $(PATH_DEFINES) $(SYSTEMD_DEFINES) $(NUNCSTANS_INCLUDES) @openldap_inc@ @ldapsdk_inc@ $(NSS_CFLAGS) $(NSPR_INCLUDES) @systemd_inc@ # This should give access to internal headers only for tests!!! DSINTERNAL_CPPFLAGS = -I$(srcdir)/include/ldaputil # Flags for Datastructure Library @@ -155,7 +155,7 @@ CMOCKA_LINKS = @cmocka_lib@ PROFILING_LINKS = @profiling_links@ NSPR_LINK = $(NSPR_LIBS) -NSS_LINK = @nss_lib@ -lssl3 -lnss3 +NSS_LINK = $(NSS_LIBS) if OPENLDAP # with recent versions of openldap - if you link with both ldap_r and ldap, the diff --git a/configure.ac b/configure.ac index a7318ce..bd2b7bb 100644 --- a/configure.ac +++ b/configure.ac @@ -824,7 +824,15 @@ else PKG_CHECK_MODULES([NSPR], [dirsec-nspr]) fi -m4_include(m4/nss.m4) +if $PKG_CONFIG --exists nss; then + PKG_CHECK_MODULES([NSS], [nss]) + nss_libdir=`$PKG_CONFIG --libs-only-L nss | sed -e s/-L// | sed -e s/\ .*$//` +else + PKG_CHECK_MODULES([NSS], [dirsec-nss]) + nss_libdir=`$PKG_CONFIG --libs-only-L dirsec-nss | sed -e s/-L// | sed -e s/\ .*$//` +fi +AC_SUBST(nss_libdir) + m4_include(m4/openldap.m4) m4_include(m4/mozldap.m4) m4_include(m4/db.m4) diff --git a/m4/mozldap.m4 b/m4/mozldap.m4 index 40fdb88..255bd27 100644 --- a/m4/mozldap.m4 +++ b/m4/mozldap.m4 @@ -145,7 +145,7 @@ dnl default path for the ldap c sdk tools (see [210947] for more details) 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_CFLAGS" + CPPFLAGS="$ldapsdk_inc $NSS_CFLAGS $NSPR_CFLAGS" AC_CHECK_HEADER([ldap.h], [isversion6=1], [isversion6=], [#include #if LDAP_VENDOR_VERSION < 600 diff --git a/m4/nss.m4 b/m4/nss.m4 deleted file mode 100644 index 4465479..0000000 --- a/m4/nss.m4 +++ /dev/null @@ -1,93 +0,0 @@ -# BEGIN COPYRIGHT BLOCK -# Copyright (C) 2007 Red Hat, Inc. -# All rights reserved. -# -# License: GPL (version 3 or any later version). -# See LICENSE for details. -# END COPYRIGHT BLOCK - -AC_CHECKING(for NSS) - -# check for --with-nss -AC_MSG_CHECKING(for --with-nss) -AC_ARG_WITH(nss, AS_HELP_STRING([--with-nss@<:@=PATH@:>@],[Network Security Services (NSS) directory]), -[ - if test "$withval" = "yes" - then - AC_MSG_RESULT(yes) - elif test "$withval" = "no" - then - AC_MSG_RESULT(no) - AC_MSG_ERROR([NSS is required.]) - elif test -e "$withval"/include/nss.h -a -d "$withval"/lib - then - AC_MSG_RESULT([using $withval]) - NSSDIR=$withval - nss_inc="-I$NSSDIR/include" - nss_lib="-L$NSSDIR/lib" - nss_libdir="$NSSDIR/lib" - else - echo - AC_MSG_ERROR([$withval not found]) - fi -], -AC_MSG_RESULT(yes)) - -# check for --with-nss-inc -AC_MSG_CHECKING(for --with-nss-inc) -AC_ARG_WITH(nss-inc, AS_HELP_STRING([--with-nss-inc=PATH],[Network Security Services (NSS) include directory]), -[ - if test -e "$withval"/nss.h - then - AC_MSG_RESULT([using $withval]) - nss_inc="-I$withval" - else - echo - AC_MSG_ERROR([$withval not found]) - fi -], -AC_MSG_RESULT(no)) - -# check for --with-nss-lib -AC_MSG_CHECKING(for --with-nss-lib) -AC_ARG_WITH(nss-lib, AS_HELP_STRING([--with-nss-lib=PATH],[Network Security Services (NSS) library directory]), -[ - if test -d "$withval" - then - AC_MSG_RESULT([using $withval]) - nss_lib="-L$withval" - nss_libdir="$withval" - else - echo - AC_MSG_ERROR([$withval not found]) - fi -], -AC_MSG_RESULT(no)) - -# if NSS is not found yet, try pkg-config - -# last resort -if test -z "$nss_inc" -o -z "$nss_lib" -o -z "$nss_libdir"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config) - AC_MSG_CHECKING(for nss with pkg-config) - if test -n "$PKG_CONFIG"; then - if $PKG_CONFIG --exists nss; then - nss_inc=`$PKG_CONFIG --cflags-only-I nss` - nss_lib=`$PKG_CONFIG --libs-only-L nss` - nss_libdir=`$PKG_CONFIG --libs-only-L nss | sed -e s/-L// | sed -e s/\ .*$//` - AC_MSG_RESULT([using system NSS]) - elif $PKG_CONFIG --exists dirsec-nss; then - nss_inc=`$PKG_CONFIG --cflags-only-I dirsec-nss` - nss_lib=`$PKG_CONFIG --libs-only-L dirsec-nss` - nss_libdir=`$PKG_CONFIG --libs-only-L dirsec-nss | sed -e s/-L// | sed -e s/\ .*$//` - AC_MSG_RESULT([using system dirsec NSS]) - else - AC_MSG_ERROR([NSS not found, specify with --with-nss.]) - fi - fi -fi - -AC_SUBST(nss_inc) -AC_SUBST(nss_lib) -AC_SUBST(nss_libdir) - diff --git a/m4/openldap.m4 b/m4/openldap.m4 index 71a05b5..70e01f5 100644 --- a/m4/openldap.m4 +++ b/m4/openldap.m4 @@ -118,7 +118,7 @@ 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_CFLAGS" + CPPFLAGS="$openldap_inc $NSS_CFLAGS $NSPR_CFLAGS" 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 From d6a32479320e98de9662eb40c8bb970b3daae3cc Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Mar 29 2019 01:39:47 +0000 Subject: [PATCH 4/12] Use PKG_CHECK_MODULES to detect the cmocka library --- diff --git a/Makefile.am b/Makefile.am index 57f42f8..3b84de5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,7 +26,7 @@ UBSAN_CFLAGS = @ubsan_cflags@ SYSTEMD_DEFINES = @systemd_defs@ -CMOCKA_INCLUDES = @cmocka_inc@ +CMOCKA_INCLUDES = $(CMOCKA_CFLAGS) PROFILING_DEFINES = @profiling_defs@ NSPR_INCLUDES = $(NSPR_CFLAGS) @@ -151,7 +151,7 @@ NUNCSTANS_CPPFLAGS = $(NSPR_INCLUDES) $(NUNCSTANS_INCLUDES) $(SDS_INCLUDES) $(EV # Linker Flags #------------------------ SYSTEMD_LINK = @systemd_lib@ -CMOCKA_LINKS = @cmocka_lib@ +CMOCKA_LINKS = $(CMOCKA_LIBS) PROFILING_LINKS = @profiling_links@ NSPR_LINK = $(NSPR_LIBS) @@ -612,7 +612,7 @@ dist_noinst_HEADERS += \ src/libsds/external/liblfds711/src/lfds711_queue_unbounded_manyproducer_manyconsumer/lfds711_queue_unbounded_manyproducer_manyconsumer_internal.h endif -if WITH_CMOCKA +if ENABLE_CMOCKA dist_noinst_HEADERS += \ test/test_slapd.h \ src/libsds/test/test_sds.h \ @@ -2125,7 +2125,7 @@ rsearch_LDADD = $(NSPR_LINK) $(NSS_LINK) $(LDAPSDK_LINK) $(SASL_LINK) $(LIBSOCKE #------------------------- # CMOCKA TEST PROGRAMS #------------------------- -if WITH_CMOCKA +if ENABLE_CMOCKA check_PROGRAMS = test_slapd \ test_libsds \ diff --git a/configure.ac b/configure.ac index bd2b7bb..a5434bf 100644 --- a/configure.ac +++ b/configure.ac @@ -845,7 +845,18 @@ m4_include(m4/kerberos.m4) m4_include(m4/pcre.m4) m4_include(m4/selinux.m4) m4_include(m4/systemd.m4) -m4_include(m4/cmocka.m4) + +AC_MSG_CHECKING(whether to enable cmocka unit tests) +AC_ARG_ENABLE(cmocka, AS_HELP_STRING([--enable-cmocka], [Enable cmocka unit tests (default: no)])) +if test "x$enable_cmocka" = "xyes"; then + AC_MSG_RESULT(yes) + PKG_CHECK_MODULES([CMOCKA], [cmocka]) + AC_DEFINE([ENABLE_CMOCKA], [1], [Enable cmocka unit tests]) +else + AC_MSG_RESULT(no) +fi +AM_CONDITIONAL([ENABLE_CMOCKA], [test "x$enable_cmocka" = "xyes"]) + m4_include(m4/doxygen.m4) PACKAGE_BASE_VERSION=`echo $PACKAGE_VERSION | awk -F\. '{print $1"."$2}'` diff --git a/m4/cmocka.m4 b/m4/cmocka.m4 deleted file mode 100644 index bb7d4d3..0000000 --- a/m4/cmocka.m4 +++ /dev/null @@ -1,33 +0,0 @@ -## BEGIN COPYRIGHT BLOCK -## Copyright (c) 2016, William Brown -## All rights reserved. -## -## License: License: GPL (version 3 or any later version). -## See LICENSE for details. -## END COPYRIGHT BLOCK - -AC_MSG_CHECKING(for --enable-cmocka) -AC_ARG_ENABLE(cmocka, AS_HELP_STRING([--enable-cmocka], [Enable cmocka based tests (default: no)]), -[ - AC_MSG_RESULT(yes) - AC_DEFINE([WITH_CMOCKA], [1], [With cmocka unit tests]) - with_cmocka="yes" - AC_MSG_CHECKING(for cmocka) - if $PKG_CONFIG --exists cmocka; then - cmocka_inc=`$PKG_CONFIG --cflags cmocka` - cmocka_lib=`$PKG_CONFIG --libs cmocka` - AC_MSG_RESULT([using system cmocka]) - else - AC_MSG_ERROR([pkg-config could not find cmocka!]) - fi -], -[ - AC_MSG_RESULT(no) - with_cmocka="0" -]) - -AM_CONDITIONAL([WITH_CMOCKA], [test "$with_cmocka" = "yes"]) -AC_SUBST(cmocka_inc) -AC_SUBST(cmocka_lib) - - From 5203410ccddb022f1a212be4edce751de28b8176 Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Mar 29 2019 01:39:47 +0000 Subject: [PATCH 5/12] Use PKG_CHECK_MODULES to detect the pcre library --- diff --git a/Makefile.am b/Makefile.am index 3b84de5..f4beae8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -171,7 +171,6 @@ ldaplib_defs = @ldaplib_defs@ DB_LINK = @db_lib@ -ldb-@db_libver@ SASL_LINK = @sasl_lib@ -lsasl2 -PCRE_LINK = @pcre_lib@ -lpcre NETSNMP_LINK = @netsnmp_lib@ @netsnmp_link@ PAM_LINK = -lpam KERBEROS_LINK = $(kerberos_lib) @@ -1387,8 +1386,8 @@ libslapd_la_SOURCES = ldap/servers/slapd/add.c \ ldap/servers/slapd/slapi_pal.c \ $(libavl_a_SOURCES) -libslapd_la_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) $(SASL_INCLUDES) @db_inc@ @kerberos_inc@ @pcre_inc@ $(SDS_CPPFLAGS) $(SVRCORE_INCLUDES) -libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(NSS_LINK) $(NSPR_LINK) $(KERBEROS_LINK) $(PCRE_LINK) $(THREADLIB) $(SYSTEMD_LINK) libsds.la libsvrcore.la +libslapd_la_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) $(SASL_INCLUDES) @db_inc@ @kerberos_inc@ $(PCRE_CFLAGS) $(SDS_CPPFLAGS) $(SVRCORE_INCLUDES) +libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(NSS_LINK) $(NSPR_LINK) $(KERBEROS_LINK) $(PCRE_LIBS) $(THREADLIB) $(SYSTEMD_LINK) libsds.la libsvrcore.la libslapd_la_LDFLAGS = $(AM_LDFLAGS) $(SLAPD_LDFLAGS) diff --git a/configure.ac b/configure.ac index a5434bf..27354ef 100644 --- a/configure.ac +++ b/configure.ac @@ -842,7 +842,16 @@ PKG_CHECK_MODULES([ICU], [icu-i18n >= 60.2]) m4_include(m4/netsnmp.m4) m4_include(m4/kerberos.m4) -m4_include(m4/pcre.m4) + +if $PKG_CONFIG --exists pcre; then + PKG_CHECK_MODULES([PCRE], [pcre]) + pcre_libdir=`$PKG_CONFIG --libs-only-L pcre | sed -e s/-L// | sed -e s/\ .*$//` +else + PKG_CHECK_MODULES([PCRE], [libpcre]) + pcre_libdir=`$PKG_CONFIG --libs-only-L libpcre | sed -e s/-L// | sed -e s/\ .*$//` +fi +AC_SUBST(pcre_libdir) + m4_include(m4/selinux.m4) m4_include(m4/systemd.m4) @@ -885,9 +894,6 @@ AC_SUBST(sasl_inc) AC_SUBST(sasl_lib) AC_SUBST(sasl_libdir) AC_SUBST(sasl_path) -AC_SUBST(pcre_inc) -AC_SUBST(pcre_lib) -AC_SUBST(pcre_libdir) AC_SUBST(nunc_stans_inc) AC_SUBST(nunc_stans_lib) AC_SUBST(nunc_stans_libdir) diff --git a/m4/pcre.m4 b/m4/pcre.m4 deleted file mode 100644 index 71b8944..0000000 --- a/m4/pcre.m4 +++ /dev/null @@ -1,80 +0,0 @@ -# BEGIN COPYRIGHT BLOCK -# Copyright (C) 2007 Red Hat, Inc. -# All rights reserved. -# -# License: GPL (version 3 or any later version). -# See LICENSE for details. -# END COPYRIGHT BLOCK - -AC_CHECKING(for PCRE) - -dnl - check for --with-pcre -AC_MSG_CHECKING(for --with-pcre) -AC_ARG_WITH(pcre, AS_HELP_STRING([--with-pcre@<:@=PATH@:>@],[Perl Compatible Regular Expression directory]), -[ - if test "$withval" = "yes"; then - AC_MSG_RESULT(yes) - elif test "$withval" = "no"; then - AC_MSG_RESULT(no) - AC_MSG_ERROR([PCRE is required.]) - elif test -d "$withval"/include -a -d "$withval"/lib; then - AC_MSG_RESULT([using $withval]) - dnl - check the user provided location - PCREDIR=$withval - pcre_lib="-L$PCREDIR/lib" - pcre_libdir="$PCREDIR/lib" - pcre_incdir="$PCREDIR/include" - if ! test -e "$pcre_incdir/pcre.h" ; then - AC_MSG_ERROR([$withval include dir not found]) - fi - pcre_inc="-I$pcre_incdir" - else - echo - AC_MSG_ERROR([$withval not found]) - fi -], -AC_MSG_RESULT(yes)) - -# -# if PCRE is not found yet, try pkg-config -if test -z "$pcre_inc" -o -z "$pcre_lib" -o -z "$pcre_libdir"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config) - AC_MSG_CHECKING(for pcre with pkg-config) - if test -n "$PKG_CONFIG"; then - if $PKG_CONFIG --exists pcre; then - pcre_inc=`$PKG_CONFIG --cflags-only-I pcre` - pcre_lib=`$PKG_CONFIG --libs-only-L pcre` - pcre_libdir=`$PKG_CONFIG --libs-only-L pcre | sed -e s/-L// | sed -e s/\ .*$//` - AC_MSG_RESULT([using system PCRE]) - elif $PKG_CONFIG --exists libpcre; then - pcre_inc=`$PKG_CONFIG --cflags-only-I libpcre` - pcre_lib=`$PKG_CONFIG --libs-only-L libpcre` - pcre_libdir=`$PKG_CONFIG --libs-only-L libpcre | sed -e s/-L// | sed -e s/\ .*$//` - AC_MSG_RESULT([using system PCRE]) - else - AC_MSG_ERROR([PCRE not found, specify with --with-pcre.]) - fi - fi -fi - -dnl last resort -dnl - check in system locations -if test -z "$pcre_inc"; then - AC_MSG_CHECKING(for pcre.h) - if test -f "/usr/include/pcre/pcre.h"; then - AC_MSG_RESULT([using /usr/include/pcre/pcre.h]) - pcre_incdir="/usr/include/pcre" - pcre_inc="-I/usr/include/pcre" - pcre_lib='-L$(libdir)' - pcre_libdir='$(libdir)' - elif test -f "/usr/include/pcre.h"; then - AC_MSG_RESULT([using /usr/include/pcre.h]) - pcre_incdir="/usr/include" - pcre_inc="-I/usr/include" - pcre_lib='-L$(libdir)' - pcre_libdir='$(libdir)' - else - AC_MSG_RESULT(no) - AC_MSG_ERROR([PCRE not found, specify with --with-pcre.]) - fi -fi From 9f5f29a74b08b49278fa5bcd63890f4e650a33b9 Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Mar 29 2019 01:39:47 +0000 Subject: [PATCH 6/12] m4/doxygen.m4: Fix spelling of Doxygen in a message --- diff --git a/m4/doxygen.m4 b/m4/doxygen.m4 index a73c7fd..bb6ef78 100644 --- a/m4/doxygen.m4 +++ b/m4/doxygen.m4 @@ -11,7 +11,7 @@ if test -z "$DOXYGEN"; then AC_MSG_WARN([Doxygen not found - continuing without Doxygen support]) fi -AC_MSG_RESULT([using system dokygen]) +AC_MSG_RESULT([using system Doxygen]) AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([docs/slapi.doxy])]) From 40ca6e975a669ae13638e569540a5b64cd44d221 Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Mar 29 2019 01:39:47 +0000 Subject: [PATCH 7/12] configure.ac: Remove unpaired parentheses from two help strings --- diff --git a/configure.ac b/configure.ac index 27354ef..a848cae 100644 --- a/configure.ac +++ b/configure.ac @@ -505,7 +505,7 @@ defaultgroup=dirsrv AC_MSG_CHECKING(for --with-perldir) AC_ARG_WITH([perldir], AS_HELP_STRING([--with-perldir=PATH], - [Directory for perl)]) + [Directory for perl]) ) if test -n "$with_perldir"; then if test "$with_perldir" = yes ; then @@ -522,7 +522,7 @@ fi AC_MSG_CHECKING(for --with-pythonexec) AC_ARG_WITH([pythonexec], AS_HELP_STRING([--with-pythonexec=PATH], - [Path to executable for python)]) + [Path to executable for python]) ) if test -n "$with_pythonexec"; then if test "$with_pythonexec" = yes ; then From a2ebc6d57cf30d9162de8f30fb240a182adde2df Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Mar 29 2019 01:39:47 +0000 Subject: [PATCH 8/12] configure.ac: Add missing comma to an AC_ARG_ENABLE macro --- diff --git a/configure.ac b/configure.ac index a848cae..11a47cb 100644 --- a/configure.ac +++ b/configure.ac @@ -212,7 +212,7 @@ if test -z "$enable_perl" ; then enable_perl=no fi AC_MSG_CHECKING(for --enable-perl) -AC_ARG_ENABLE(perl, AS_HELP_STRING([--enable-perl], [Enable deprecated legacy perl and shell scripts (default: no)]) +AC_ARG_ENABLE(perl, AS_HELP_STRING([--enable-perl], [Enable deprecated legacy perl and shell scripts (default: no)]), [ AC_MSG_RESULT(yes) ], From e50466ee16d6401d965eae8ae72731961902cc8b Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Mar 29 2019 01:39:47 +0000 Subject: [PATCH 9/12] Use PKG_CHECK_MODULES to detect the libsasl2 library --- diff --git a/Makefile.am b/Makefile.am index f4beae8..2416305 100644 --- a/Makefile.am +++ b/Makefile.am @@ -31,8 +31,6 @@ CMOCKA_INCLUDES = $(CMOCKA_CFLAGS) PROFILING_DEFINES = @profiling_defs@ NSPR_INCLUDES = $(NSPR_CFLAGS) -SASL_INCLUDES = @sasl_inc@ - # Rust inclusions. if RUST_ENABLE RUST_ON = 1 @@ -170,7 +168,7 @@ ldaplib = @ldaplib@ ldaplib_defs = @ldaplib_defs@ DB_LINK = @db_lib@ -ldb-@db_libver@ -SASL_LINK = @sasl_lib@ -lsasl2 +SASL_LINK = $(SASL_LIBS) NETSNMP_LINK = @netsnmp_lib@ @netsnmp_link@ PAM_LINK = -lpam KERBEROS_LINK = $(kerberos_lib) @@ -1386,7 +1384,7 @@ libslapd_la_SOURCES = ldap/servers/slapd/add.c \ ldap/servers/slapd/slapi_pal.c \ $(libavl_a_SOURCES) -libslapd_la_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) $(SASL_INCLUDES) @db_inc@ @kerberos_inc@ $(PCRE_CFLAGS) $(SDS_CPPFLAGS) $(SVRCORE_INCLUDES) +libslapd_la_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) $(SASL_CFLAGS) @db_inc@ @kerberos_inc@ $(PCRE_CFLAGS) $(SDS_CPPFLAGS) $(SVRCORE_INCLUDES) libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(NSS_LINK) $(NSPR_LINK) $(KERBEROS_LINK) $(PCRE_LIBS) $(THREADLIB) $(SYSTEMD_LINK) libsds.la libsvrcore.la libslapd_la_LDFLAGS = $(AM_LDFLAGS) $(SLAPD_LDFLAGS) @@ -2012,7 +2010,7 @@ ldclt_SOURCES = ldap/servers/slapd/tools/ldaptool-sasl.c \ ldap/servers/slapd/tools/ldclt/version.c \ ldap/servers/slapd/tools/ldclt/workarounds.c -ldclt_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/ldap/servers/slapd/tools $(DSPLUGIN_CPPFLAGS) $(SASL_INCLUDES) +ldclt_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/ldap/servers/slapd/tools $(DSPLUGIN_CPPFLAGS) $(SASL_CFLAGS) ldclt_LDADD = $(NSPR_LINK) $(NSS_LINK) $(LDAPSDK_LINK) $(SASL_LINK) $(LIBNSL) $(LIBSOCKET) $(LIBDL) $(THREADLIB) #------------------------ @@ -2089,7 +2087,7 @@ ns_slapd_SOURCES = ldap/servers/slapd/abandon.c \ ldap/servers/slapd/unbind.c \ $(GETSOCKETPEER) -ns_slapd_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) $(SASL_INCLUDES) $(SVRCORE_INCLUDES) +ns_slapd_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) $(SASL_CFLAGS) $(SVRCORE_INCLUDES) ns_slapd_LDADD = libnunc-stans.la libslapd.la libldaputil.la libsvrcore.la $(LDAPSDK_LINK) $(NSS_LINK) $(LIBADD_DL) \ $(NSPR_LINK) $(SASL_LINK) $(LIBNSL) $(LIBSOCKET) $(THREADLIB) $(SYSTEMD_LINK) $(EVENT_LINK) ns_slapd_DEPENDENCIES = libslapd.la libnunc-stans.la libldaputil.la @@ -2228,8 +2226,6 @@ fixupcmd = sed \ -e 's,@plainldif_opts\@,$(plainldif_opts),g' \ -e 's,@db_libdir\@,$(db_libdir),g' \ -e 's,@db_bindir\@,$(db_bindir),g' \ - -e 's,@sasl_libdir\@,$(sasl_libdir),g' \ - -e 's,@sasl_path\@,@sasl_path@,g' \ -e 's,@netsnmp_libdir\@,$(netsnmp_libdir),g' \ -e 's,@pcre_libdir\@,$(pcre_libdir),g' \ -e 's,@propertydir\@,$(propertydir),g' \ diff --git a/configure.ac b/configure.ac index 11a47cb..26e81d5 100644 --- a/configure.ac +++ b/configure.ac @@ -836,7 +836,10 @@ AC_SUBST(nss_libdir) m4_include(m4/openldap.m4) m4_include(m4/mozldap.m4) m4_include(m4/db.m4) -m4_include(m4/sasl.m4) + +PKG_CHECK_MODULES([SASL], [libsasl2]) +# Workaround failure by Mozilla ldapsdk to #include +SASL_CFLAGS="$SASL_CFLAGS -I$includedir/sasl" PKG_CHECK_MODULES([ICU], [icu-i18n >= 60.2]) @@ -871,13 +874,6 @@ m4_include(m4/doxygen.m4) PACKAGE_BASE_VERSION=`echo $PACKAGE_VERSION | awk -F\. '{print $1"."$2}'` AC_SUBST(PACKAGE_BASE_VERSION) -# set sasl_path for wrapper scripts -if test -z "$sasl_libdir" ; then - sasl_path="$libdir/sasl2" -else - sasl_path="$sasl_libdir/sasl2" -fi - AM_CONDITIONAL(OPENLDAP,test "$with_openldap" = "yes") # write out paths for binary components @@ -890,10 +886,6 @@ AC_SUBST(ldaplib_defs) AC_SUBST(ldaptool_bindir) AC_SUBST(ldaptool_opts) AC_SUBST(plainldif_opts) -AC_SUBST(sasl_inc) -AC_SUBST(sasl_lib) -AC_SUBST(sasl_libdir) -AC_SUBST(sasl_path) AC_SUBST(nunc_stans_inc) AC_SUBST(nunc_stans_lib) AC_SUBST(nunc_stans_libdir) diff --git a/m4/sasl.m4 b/m4/sasl.m4 deleted file mode 100644 index 4f1aad8..0000000 --- a/m4/sasl.m4 +++ /dev/null @@ -1,95 +0,0 @@ -# BEGIN COPYRIGHT BLOCK -# Copyright (C) 2007 Red Hat, Inc. -# All rights reserved. -# -# License: GPL (version 3 or any later version). -# See LICENSE for details. -# END COPYRIGHT BLOCK -# -*- tab-width: 4; -*- -# Configure paths for SASL - -dnl ======================================================== -dnl = sasl is used to support various authentication mechanisms -dnl = such as DIGEST-MD5 and GSSAPI. -dnl ======================================================== -dnl ======================================================== -dnl = Use the sasl libraries on the system (assuming it exists) -dnl ======================================================== -AC_CHECKING(for SASL) - -AC_MSG_CHECKING(for --with-sasl) -AC_ARG_WITH(sasl, - AS_HELP_STRING([--with-sasl@<:@=PATH@:>@],[Use SASL from supplied path]), - dnl = Look in the standard system locations - [ - if test "$withval" = "yes"; then - AC_MSG_RESULT(yes) - - elif test "$withval" = "no"; then - AC_MSG_RESULT(no) - AC_MSG_ERROR([SASL is required.]) - - dnl = Check the user provided location - elif test -d "$withval" -a -d "$withval/lib" -a -d "$withval/include" ; then - AC_MSG_RESULT([using $withval]) - - if test -f "$withval/include/sasl/sasl.h"; then - sasl_inc="-I$withval/include/sasl" - elif test -f "$withval/include/sasl.h"; then - sasl_inc="-I$withval/include" - else - AC_MSG_ERROR(sasl.h not found) - fi - - sasl_lib="-L$withval/lib" - sasl_libdir="$withval/lib" - else - AC_MSG_RESULT(yes) - AC_MSG_ERROR([SASL not found in $withval]) - fi - ], - AC_MSG_RESULT(yes)) - -AC_MSG_CHECKING(for --with-sasl-inc) -AC_ARG_WITH(sasl-inc, - AS_HELP_STRING([--with-sasl-inc=PATH],[SASL include file directory]), - [ - if test -f "$withval"/sasl.h; then - AC_MSG_RESULT([using $withval]) - sasl_inc="-I$withval" - else - echo - AC_MSG_ERROR([$withval/sasl.h not found]) - fi - ], - AC_MSG_RESULT(no)) - -AC_MSG_CHECKING(for --with-sasl-lib) -AC_ARG_WITH(sasl-lib, - AS_HELP_STRING([--with-sasl-lib=PATH],[SASL library directory]), - [ - if test -d "$withval"; then - AC_MSG_RESULT([using $withval]) - sasl_lib="-L$withval" - sasl_libdir="$withval" - else - echo - AC_MSG_ERROR([$withval not found]) - fi - ], - AC_MSG_RESULT(no)) - -if test -z "$sasl_inc"; then - AC_MSG_CHECKING(for sasl.h) - dnl - Check for sasl in standard system locations - if test -f /usr/include/sasl/sasl.h; then - AC_MSG_RESULT([using /usr/include/sasl/sasl.h]) - sasl_inc="-I/usr/include/sasl" - elif test -f /usr/include/sasl.h; then - AC_MSG_RESULT([using /usr/include/sasl.h]) - sasl_inc="-I/usr/include" - else - AC_MSG_RESULT(no) - AC_MSG_ERROR([SASL not found, specify with --with-sasl.]) - fi -fi From 9d6531aa5e5f7322ae6df10f18dd64561bd5599a Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Mar 29 2019 01:39:47 +0000 Subject: [PATCH 10/12] Use pkg-config from the host system to better support cross-compiling --- diff --git a/m4/mozldap.m4 b/m4/mozldap.m4 index 255bd27..76d3300 100644 --- a/m4/mozldap.m4 +++ b/m4/mozldap.m4 @@ -109,7 +109,6 @@ AC_MSG_RESULT(no)) # last resort 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 diff --git a/m4/openldap.m4 b/m4/openldap.m4 index 70e01f5..58533d6 100644 --- a/m4/openldap.m4 +++ b/m4/openldap.m4 @@ -97,7 +97,6 @@ AC_MSG_RESULT(no)) if test "$with_openldap" = yes ; then # user wants to use openldap, but didn't specify paths if test -z "$openldap_inc" -o -z "$openldap_lib" -o -z "$openldap_libdir" -o -z "$openldap_bindir"; then - 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` From 773e89898d995f4dfecbe872dd6679f4ae2e542d Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Mar 29 2019 01:39:47 +0000 Subject: [PATCH 11/12] Use PKG_CHECK_MODULES to detect the kerberos library --- diff --git a/Makefile.am b/Makefile.am index 2416305..83bd1c9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -171,7 +171,6 @@ DB_LINK = @db_lib@ -ldb-@db_libver@ SASL_LINK = $(SASL_LIBS) NETSNMP_LINK = @netsnmp_lib@ @netsnmp_link@ PAM_LINK = -lpam -KERBEROS_LINK = $(kerberos_lib) EVENT_LINK = $(EVENT_LIBS) PW_CRACK_LINK = -lcrack @@ -1384,8 +1383,8 @@ libslapd_la_SOURCES = ldap/servers/slapd/add.c \ ldap/servers/slapd/slapi_pal.c \ $(libavl_a_SOURCES) -libslapd_la_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) $(SASL_CFLAGS) @db_inc@ @kerberos_inc@ $(PCRE_CFLAGS) $(SDS_CPPFLAGS) $(SVRCORE_INCLUDES) -libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(NSS_LINK) $(NSPR_LINK) $(KERBEROS_LINK) $(PCRE_LIBS) $(THREADLIB) $(SYSTEMD_LINK) libsds.la libsvrcore.la +libslapd_la_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) $(SASL_CFLAGS) @db_inc@ $(KERBEROS_CFLAGS) $(PCRE_CFLAGS) $(SDS_CPPFLAGS) $(SVRCORE_INCLUDES) +libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(NSS_LINK) $(NSPR_LINK) $(KERBEROS_LIBS) $(PCRE_LIBS) $(THREADLIB) $(SYSTEMD_LINK) libsds.la libsvrcore.la libslapd_la_LDFLAGS = $(AM_LDFLAGS) $(SLAPD_LDFLAGS) diff --git a/configure.ac b/configure.ac index 26e81d5..8845894 100644 --- a/configure.ac +++ b/configure.ac @@ -844,7 +844,18 @@ SASL_CFLAGS="$SASL_CFLAGS -I$includedir/sasl" PKG_CHECK_MODULES([ICU], [icu-i18n >= 60.2]) m4_include(m4/netsnmp.m4) -m4_include(m4/kerberos.m4) + +PKG_CHECK_MODULES([KERBEROS], [krb5]) +krb5_vendor=`$PKG_CONFIG --variable=vendor krb5` +if test "$krb5_vendor" = "MIT"; then + AC_DEFINE(HAVE_KRB5, 1, [Define if you have Kerberos V]) + save_LIBS="$LIBS" + LIBS="$KERBEROS_LIBS" + AC_CHECK_FUNCS([krb5_cc_new_unique]) + LIBS="$save_LIBS" +elif test "$krb5_vendor" = "Heimdal"; then + AC_DEFINE(HAVE_HEIMDAL_KERBEROS, 1, [Define if you have Heimdal Kerberos]) +fi if $PKG_CONFIG --exists pcre; then PKG_CHECK_MODULES([PCRE], [pcre]) diff --git a/m4/kerberos.m4 b/m4/kerberos.m4 deleted file mode 100644 index a82f57a..0000000 --- a/m4/kerberos.m4 +++ /dev/null @@ -1,187 +0,0 @@ -# BEGIN COPYRIGHT BLOCK -# Copyright (C) 2008 Red Hat, Inc. -# All rights reserved. -# -# License: GPL (version 3 or any later version). -# See LICENSE for details. -# END COPYRIGHT BLOCK -# -*- tab-width: 4; -*- -# Configure paths for Kerberos - -dnl ======================================================== -dnl = Kerberos is used directly for server to server SASL/GSSAPI -dnl = authentication (replication, chaining, etc.) -dnl = This allows us to authenticate using a keytab without -dnl = having to call kinit outside the process -dnl ======================================================== -AC_CHECKING(for Kerberos) - -if test -z "$with_kerberos" ; then - with_kerberos=yes # if not set on cmdline, set default -fi - -AC_MSG_CHECKING(for --with-kerberos) -AC_ARG_WITH(kerberos, - AS_HELP_STRING([--with-kerberos@<:@=PATH@:>@], [Use the kerberos API in the server directly - allows the server to authenticate directly with a keytab - otherwise, SASL/GSSAPI auth depends on underlying SASL libraries and external kinit with a keytab - if PATH is not specified, look for kerberos in the system locations. This will attempt to use krb5-config from the PATH to find the libs and include dirs - you can specify KRB5_CONFIG_BIN to specify a different filename or absolute path. If krb5-config does not work, this will attempt to look in various system directories]), - [ - if test "x$withval" = "xyes"; then - AC_MSG_RESULT(yes) - elif test "x$withval" = "xno"; then - AC_MSG_RESULT(no) - with_kerberos= - elif test -d "$withval" -a -d "$withval/lib" -a -d "$withval/include" ; then - AC_MSG_RESULT([using $withval]) - kerberos_incdir="$withval/include" - kerberos_libdir="$withval/lib" - else - AC_MSG_RESULT(yes) - AC_MSG_ERROR([kerberos not found in $withval]) - fi - ], - [ - AC_MSG_RESULT(no) - with_kerberos= - ] -) - -AC_MSG_CHECKING(for --with-kerberos-inc) -AC_ARG_WITH(kerberos-inc, - AS_HELP_STRING([--with-kerberos-inc=PATH], [Allows you to explicitly set the directory containing the kerberos include files - implies use of kerberos]), - [ - if test -f "$withval"/krb5.h; then - AC_MSG_RESULT([using $withval]) - kerberos_incdir="$withval" - with_kerberos=yes # implies use of kerberos - else - echo - AC_MSG_ERROR([$withval/krb5.h not found]) - fi - ], - AC_MSG_RESULT(no) -) - -AC_MSG_CHECKING(for --with-kerberos-lib) -AC_ARG_WITH(kerberos-lib, - AS_HELP_STRING([--with-kerberos-lib=PATH], [Allows you to explicitly set the directory containing the kerberos libraries - implies use of kerberos]), - [ - if test -d "$withval"; then - AC_MSG_RESULT([using $withval]) - kerberos_libdir="$withval" - with_kerberos=yes # implies use of kerberos - else - echo - AC_MSG_ERROR([$withval not found]) - fi - ], - AC_MSG_RESULT(no) -) - -if test -n "$with_kerberos" ; then - if test -z "$kerberos_incdir" -o -z "$kerberos_libdir" ; then - dnl look for these using the krb5-config script - dnl user can define KRB5_CONFIG_BIN to the full path - dnl and filename of the script if it cannot or will not - dnl be found in PATH - if test -z "$KRB5_CONFIG_BIN" ; then - AC_PATH_PROG(KRB5_CONFIG_BIN, krb5-config) - fi - if test -n "$KRB5_CONFIG_BIN" ; then - AC_MSG_CHECKING(for kerberos with $KRB5_CONFIG_BIN) - if test -z "$kerberos_libdir" ; then - kerberos_lib=`$KRB5_CONFIG_BIN --libs krb5` - fi - if test -z "$kerberos_incdir" ; then - kerberos_inc=`$KRB5_CONFIG_BIN --cflags krb5` - fi - dnl if using system includes, inc will be empty - ok - if test -n "$kerberos_lib" ; then - AC_MSG_RESULT([using kerberos found with $KRB5_CONFIG_BIN]) - have_krb5=yes - fi - fi - fi -fi - -if test -n "$with_kerberos" -a -z "$kerberos_lib" ; then - # save these in order to set them to use the check macros below - # like AC_CHECK_HEADERS, AC_CHECK_LIB, and AC_CHECK_FUNCS - save_CPPFLAGS="$CPPFLAGS" - if test -n "$kerberos_incdir" ; then - CPPFLAGS="-I$kerberos_incdir $CPPFLAGS" - fi - save_LDFLAGS="$LDFLAGS" - if test -n "$kerberos_libdir" ; then - LDFLAGS="-L$kerberos_libdir $LDFLAGS" - fi - krb5_impl=mit - - dnl check for Heimdal Kerberos - AC_CHECK_HEADERS(heim_err.h) - if test $ac_cv_header_heim_err_h = yes ; then - krb5_impl=heimdal - fi - - if test "x$krb5_impl" = "xmit"; then - AC_CHECK_LIB(k5crypto, main, - [krb5crypto=k5crypto], - [krb5crypto=crypto]) - - AC_CHECK_LIB(krb5, main, - [have_krb5=yes - kerberos_lib="-lkrb5 -l$krb5crypto -lcom_err"], - [have_krb5=no], - [-l$krb5crypto -lcom_err]) - - elif test "x$krb5_impl" = "xheimdal"; then - AC_CHECK_LIB(des, main, - [krb5crypto=des], - [krb5crypto=crypto]) - - AC_CHECK_LIB(krb5, main, - [have_krb5=yes - kerberos_lib="-lkrb5 -l$krb5crypto -lasn1 -lroken -lcom_err"], - [have_krb5=no], - [-l$krb5crypto -lasn1 -lroken -lcom_err]) - - AC_DEFINE(HAVE_HEIMDAL_KERBEROS, 1, - [define if you have HEIMDAL Kerberos]) - - else - have_krb5=no - AC_MSG_WARN([Unrecognized Kerberos5 Implementation]) - fi - - # reset to original values - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - if test -n "$kerberos_incdir" ; then - kerberos_inc="-I$kerberos_incdir" - fi - if test -n "$kerberos_libdir" ; then - kerberos_lib="-L$kerberos_libdir $kerberos_lib" - fi -fi - -dnl at this point kerberos_lib and kerberos_inc should be set - -if test -n "$with_kerberos" ; then - if test "x$have_krb5" = "xyes" ; then - AC_DEFINE(HAVE_KRB5, 1, - [define if you have Kerberos V]) - else - AC_MSG_ERROR([Required Kerberos 5 support not available]) - fi - - dnl look for the wonderfully time saving function krb5_cc_new_unique - save_LIBS="$LIBS" - LIBS="$kerberos_lib" - save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$kerberos_inc $CPPFLAGS" - AC_CHECK_FUNCS([krb5_cc_new_unique]) - LIBS="$save_LIBS" - CPPFLAGS="$save_CPPFLAGS" -fi - -AC_SUBST(kerberos_inc) -AC_SUBST(kerberos_lib) -AC_SUBST(kerberos_libdir) From 11309bf323544b3c693c3fb6b239abd9ae2505f7 Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Mar 29 2019 01:39:47 +0000 Subject: [PATCH 12/12] Use PKG_CHECK_MODULES to detect the systemd library --- diff --git a/Makefile.am b/Makefile.am index 83bd1c9..86425da 100644 --- a/Makefile.am +++ b/Makefile.am @@ -137,7 +137,7 @@ AM_CFLAGS = $(DEBUG_CFLAGS) $(GCCSEC_CFLAGS) $(ASAN_CFLAGS) $(MSAN_CFLAGS) $(TSA AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(GCCSEC_CFLAGS) $(ASAN_CFLAGS) $(MSAN_CFLAGS) $(TSAN_CFLAGS) $(UBSAN_CFLAGS) # Flags for Directory Server # WARNING: This needs a clean up, because slap.h is a horrible mess and is publically exposed! -DSPLUGIN_CPPFLAGS = $(DS_DEFINES) $(DS_INCLUDES) $(PATH_DEFINES) $(SYSTEMD_DEFINES) $(NUNCSTANS_INCLUDES) @openldap_inc@ @ldapsdk_inc@ $(NSS_CFLAGS) $(NSPR_INCLUDES) @systemd_inc@ +DSPLUGIN_CPPFLAGS = $(DS_DEFINES) $(DS_INCLUDES) $(PATH_DEFINES) $(SYSTEMD_DEFINES) $(NUNCSTANS_INCLUDES) @openldap_inc@ @ldapsdk_inc@ $(NSS_CFLAGS) $(NSPR_INCLUDES) $(SYSTEMD_CFLAGS) # This should give access to internal headers only for tests!!! DSINTERNAL_CPPFLAGS = -I$(srcdir)/include/ldaputil # Flags for Datastructure Library @@ -148,7 +148,6 @@ NUNCSTANS_CPPFLAGS = $(NSPR_INCLUDES) $(NUNCSTANS_INCLUDES) $(SDS_INCLUDES) $(EV #------------------------ # Linker Flags #------------------------ -SYSTEMD_LINK = @systemd_lib@ CMOCKA_LINKS = $(CMOCKA_LIBS) PROFILING_LINKS = @profiling_links@ @@ -1384,7 +1383,7 @@ libslapd_la_SOURCES = ldap/servers/slapd/add.c \ $(libavl_a_SOURCES) libslapd_la_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) $(SASL_CFLAGS) @db_inc@ $(KERBEROS_CFLAGS) $(PCRE_CFLAGS) $(SDS_CPPFLAGS) $(SVRCORE_INCLUDES) -libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(NSS_LINK) $(NSPR_LINK) $(KERBEROS_LIBS) $(PCRE_LIBS) $(THREADLIB) $(SYSTEMD_LINK) libsds.la libsvrcore.la +libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(NSS_LINK) $(NSPR_LINK) $(KERBEROS_LIBS) $(PCRE_LIBS) $(THREADLIB) $(SYSTEMD_LIBS) libsds.la libsvrcore.la libslapd_la_LDFLAGS = $(AM_LDFLAGS) $(SLAPD_LDFLAGS) @@ -2088,7 +2087,7 @@ ns_slapd_SOURCES = ldap/servers/slapd/abandon.c \ ns_slapd_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) $(SASL_CFLAGS) $(SVRCORE_INCLUDES) ns_slapd_LDADD = libnunc-stans.la libslapd.la libldaputil.la libsvrcore.la $(LDAPSDK_LINK) $(NSS_LINK) $(LIBADD_DL) \ - $(NSPR_LINK) $(SASL_LINK) $(LIBNSL) $(LIBSOCKET) $(THREADLIB) $(SYSTEMD_LINK) $(EVENT_LINK) + $(NSPR_LINK) $(SASL_LINK) $(LIBNSL) $(LIBSOCKET) $(THREADLIB) $(SYSTEMD_LIBS) $(EVENT_LINK) ns_slapd_DEPENDENCIES = libslapd.la libnunc-stans.la libldaputil.la # We need to link ns-slapd with the C++ compiler on HP-UX since we load # some C++ shared libraries (such as icu). diff --git a/m4/systemd.m4 b/m4/systemd.m4 index 42bcea1..f402346 100644 --- a/m4/systemd.m4 +++ b/m4/systemd.m4 @@ -37,15 +37,7 @@ if test "$with_systemd" = yes; then ], AC_MSG_RESULT(no)) - AC_PATH_PROG(PKG_CONFIG, pkg-config) - AC_MSG_CHECKING(for Systemd with pkg-config) - - if test -n "$PKG_CONFIG" && $PKG_CONFIG --exists libsystemd ; then - systemd_inc=`$PKG_CONFIG --cflags-only-I libsystemd` - systemd_lib=`$PKG_CONFIG --libs-only-l libsystemd` - else - AC_MSG_ERROR([no Systemd pkg-config files]) - fi + PKG_CHECK_MODULES([SYSTEMD], [libsystemd]) if test "$with_journald" = yes; then systemd_defs="-DWITH_SYSTEMD -DHAVE_JOURNALD" @@ -141,11 +133,6 @@ AM_CONDITIONAL([with_systemd],[test -n "$with_systemd"]) AM_CONDITIONAL([JOURNALD],[test -n "$with_journald"]) AM_CONDITIONAL([with_systemd_journald],[test -n "$with_journald"]) - -AC_SUBST(systemd_inc) -AC_SUBST(systemd_lib) AC_SUBST(systemd_defs) - AC_SUBST(tmpfiles_d) -