diff --git a/Makefile.am b/Makefile.am index 7947be768..a6573a3a1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,10 +1,5 @@ ACLOCAL_AMFLAGS = -I m4 -if P11_MODULE_FILE -p11moddir = $(pk_module_configs) -p11mod_DATA = softhsm2.module -endif - MAINTAINERCLEANFILES = \ config.log config.status softhsm2.module \ $(srcdir)/Makefile.in \ @@ -16,6 +11,11 @@ MAINTAINERCLEANFILES = \ SUBDIRS = src +if WITH_P11KIT +p11moddir = @P11KIT_PATH@ +p11mod_DATA = softhsm2.module +endif + EXTRA_DIST = $(srcdir)/aes_wrap_key_with_pad/botan-diff \ $(srcdir)/aes_wrap_key_with_pad/README \ $(srcdir)/FIPS-NOTES.md \ diff --git a/NEWS b/NEWS index c22c7f2f0..5fa7b804a 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,8 @@ SoftHSM develop (Patch from Lars Silvén) * Issue #223: Mark public key as non private by default. (Patch from Nikos Mavrogiannopoulos) +* Issue #230: Install p11-kit module, to disable use --disable-p11-kit. + (Patch from David Woodhouse) * Issue #237: Add windows continuous integration build. (Patch from Peter Polačko) diff --git a/README.md b/README.md index 6374196ff..eb3c35831 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ because of the PKCS#11 interface. ## Developers -- Rickard Bellgrim (.SE, The Internet Infrastructure Foundation, www.iis.se) +- Rickard Bellgrim (Knowit Secure AB, www.knowitgroup.com) - Francis Dupont (ISC, www.isc.org) - René Post (XPT Software and Consulting, www.xpt.nl) - Roland van Rijswijk (SURFnet bv, www.surfnet.nl) @@ -72,6 +72,9 @@ Options: --with-objectstore-backend-db Build with database object store (SQLite3) --with-sqlite3=PATH Specify prefix of path of SQLite3 + --disable-p11-kit Disable p11-kit integration (default enabled) + --with-p11-kit=PATH Specify install path of the p11-kit module, will + override path given by pkg-config For more options: diff --git a/configure.ac b/configure.ac index e3bf1d341..4317a454a 100644 --- a/configure.ac +++ b/configure.ac @@ -34,7 +34,7 @@ AC_INIT([SoftHSM],[SOFTHSM_VERSION_MAJOR.SOFTHSM_VERSION_MINOR.SOFTHSM_VERSION_F AC_CONFIG_HEADER([config.h]) AC_CONFIG_SRCDIR([src/Makefile.am]) AC_CONFIG_MACRO_DIR([m4]) -AM_INIT_AUTOMAKE(foreign) +AM_INIT_AUTOMAKE([foreign subdir-objects]) ACX_PREFIXHACK # Version info for the library @@ -113,6 +113,9 @@ fi # Set visibility flags so only PKCS#11 entry points are exported ACX_VISIBILITY +# If we should install the p11-kit module +ACX_P11KIT + # Set full directory paths full_sysconfdir=`eval eval eval eval eval echo "${sysconfdir}" | sed "s#NONE#${prefix}#" | sed "s#NONE#${ac_default_prefix}#"` full_localstatedir=`eval eval eval eval eval echo "${localstatedir}" | sed "s#NONE#${prefix}#" | sed "s#NONE#${ac_default_prefix}#"` @@ -123,19 +126,7 @@ softhsmtokendir=${full_localstatedir}/lib/softhsm/tokens/ # Install the library in a sub-directory full_libdir="$full_libdir/softhsm" libdir=$full_libdir - -AC_ARG_ENABLE([p11-kit], - AS_HELP_STRING([--disable-p11-kit], [Disable p11-kit integration]), - [use_p11kit=$enableval], [use_p11kit=yes]) - -pk_module_configs= -if test "x${use_p11kit}" != "xno"; then - AC_PATH_PROG(PKGCONFIG, [pkg-config]) - if test "x${PKGCONFIG}" != "x" && ${PKGCONFIG} --exists p11-kit-1; then - pk_module_configs=`${PKGCONFIG} --variable=p11_module_configs p11-kit-1` - fi -fi -AM_CONDITIONAL([P11_MODULE_FILE], [test "x${pk_module_configs}" != "x"]) +default_softhsm2_lib="$full_libdir/libsofthsm2.so" # For getConfigPath() AC_CHECK_FUNCS([getpwuid_r]) @@ -183,13 +174,13 @@ AC_DEFINE_UNQUOTED( ) AC_DEFINE_UNQUOTED( [DEFAULT_PKCS11_LIB], - ["$full_libdir/libsofthsm2.so"], + ["$default_softhsm2_lib"], [The default PKCS#11 library] ) -AC_SUBST([pk_module_configs]) AC_SUBST([softhsmtokendir]) AC_SUBST([default_softhsm2_conf]) +AC_SUBST([default_softhsm2_lib]) # Generate the libtool script and install script AC_PROG_INSTALL diff --git a/m4/acx_p11kit.m4 b/m4/acx_p11kit.m4 new file mode 100644 index 000000000..32effb04f --- /dev/null +++ b/m4/acx_p11kit.m4 @@ -0,0 +1,36 @@ +AC_DEFUN([ACX_P11KIT],[ + AC_ARG_ENABLE([p11-kit], + AC_HELP_STRING([--enable-p11-kit], + [Enable p11-kit integration (default enabled)] + ), + [enable_p11kit="${enableval}"], + [enable_p11kit="yes"] + ) + + AC_ARG_WITH(p11-kit, + AC_HELP_STRING([--with-p11-kit=PATH],[Specify install path of the p11-kit module, will override path given by pkg-config]), + [P11KIT_PATH="$withval"], + [P11KIT_PATH=""] + ) + + AC_MSG_CHECKING(for p11-kit integration) + if test "x${enable_p11kit}" = "xyes"; then + AC_MSG_RESULT(yes) + if test "x${P11KIT_PATH}" = "x"; then + AC_PATH_PROG(PKGCONFIG, [pkg-config]) + if test "x${PKGCONFIG}" != "x" && ${PKGCONFIG} --exists p11-kit-1; then + P11KIT_PATH=`${PKGCONFIG} --variable=p11_module_configs p11-kit-1` + fi + fi + AC_MSG_CHECKING(where to install the p11-kit module) + AC_MSG_RESULT($P11KIT_PATH) + if test "x${P11KIT_PATH}" = "x"; then + AC_MSG_ERROR([Missing install path for the p11-kit module]) + fi + else + AC_MSG_RESULT(no) + fi + + AC_SUBST(P11KIT_PATH) + AM_CONDITIONAL([WITH_P11KIT], [test "x${enable_p11kit}" = "xyes"]) +]) diff --git a/softhsm2.module.in b/softhsm2.module.in index c8e129143..fe88908f8 100644 --- a/softhsm2.module.in +++ b/softhsm2.module.in @@ -1,4 +1,4 @@ # This file describes how to load the pk11 module # See: http://p11-glue.freedesktop.org/doc/p11-kit/config.html -module: @libdir@/libsofthsm2.so +module: @default_softhsm2_lib@ diff --git a/testing/build-softhsm2.sh b/testing/build-softhsm2.sh index 94da79650..499e325a4 100644 --- a/testing/build-softhsm2.sh +++ b/testing/build-softhsm2.sh @@ -28,7 +28,7 @@ case "$DISTRIBUTION" in cd build && ../configure --prefix="$INSTALL_ROOT" \ --disable-non-paged-memory \ - --disable-p11-kit \ + --with-p11-kit="$INSTALL_ROOT/usr/local/share/p11-kit/modules" \ --with-migrate \ --with-crypto-backend=botan \ --with-botan="$INSTALL_ROOT" && @@ -46,7 +46,7 @@ case "$DISTRIBUTION" in cd build && ../configure --prefix="$INSTALL_ROOT" \ --disable-non-paged-memory \ - --disable-p11-kit \ + --with-p11-kit="$INSTALL_ROOT/usr/local/share/p11-kit/modules" \ --with-migrate \ --with-crypto-backend=botan \ --with-botan="$INSTALL_ROOT" \ @@ -66,6 +66,7 @@ case "$DISTRIBUTION" in cd build && ../configure --prefix="$INSTALL_ROOT" \ --disable-non-paged-memory \ + --with-p11-kit="$INSTALL_ROOT/usr/local/share/p11-kit/modules" \ --with-migrate \ --with-crypto-backend=botan \ --with-botan="$INSTALL_ROOT" \ @@ -85,7 +86,7 @@ case "$DISTRIBUTION" in cd build && ../configure --prefix="$INSTALL_ROOT" \ --disable-non-paged-memory \ - --disable-p11-kit \ + --with-p11-kit="$INSTALL_ROOT/usr/local/share/p11-kit/modules" \ --with-migrate \ --with-crypto-backend=botan \ --with-botan="$INSTALL_ROOT" &&