From fd00c5ff87cdf084b5eb9807df3ef1852527098d Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Tue, 13 Jul 2021 11:03:18 -0400 Subject: [PATCH] samples: Replace swtpm_localca with script calling swtpm-localca (issue #482) Replace the binary swtpm_localca with a script that now calls the binary swtpm-localca, which is to be installed in $bindir. So that we can use this for script for calling swtpm-localca during testing (when it is not installed), write the script in such a way that it de- termines whether there's swtpm-localca in the same directory and if not call it from ${bindir}/swtpm-localca. Signed-off-by: Stefan Berger --- .gitignore | 1 + configure.ac | 7 +++++++ debian/swtpm-tools.install | 1 + samples/Makefile.am | 7 +++---- samples/swtpm-localca.in | 10 ++++++++++ swtpm.spec | 1 + swtpm.spec.in | 1 + 7 files changed, 24 insertions(+), 4 deletions(-) create mode 100755 samples/swtpm-localca.in diff --git a/.gitignore b/.gitignore index 187d10220..702860515 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ Makefile /man/man3/*.3 /man/man8/*.8 /samples/swtpm-create-user-config-files +/samples/swtpm_localca /samples/swtpm-localca /samples/swtpm-localca.conf /samples/swtpm_localca_conf.h diff --git a/configure.ac b/configure.ac index dbca451c7..64ef44ada 100644 --- a/configure.ac +++ b/configure.ac @@ -125,12 +125,17 @@ fi if test "x$prefix" = "xNONE"; then prefix="/usr/local" fi +if test "x$exec_prefix" = "xNONE"; then + exec_prefix=$prefix +fi SYSCONFDIR=`eval echo $sysconfdir` DATAROOTDIR=`eval echo $datarootdir` LOCALSTATEDIR=`eval echo $localstatedir` +BINDIR=`eval echo $bindir` AC_SUBST([SYSCONFDIR]) AC_SUBST([DATAROOTDIR]) AC_SUBST([LOCALSTATEDIR]) +AC_SUBST([BINDIR]) cryptolib=openssl @@ -559,6 +564,8 @@ AC_CONFIG_FILES([Makefile \ tests/Makefile \ tests/test_config \ ]) +AC_CONFIG_FILES([samples/swtpm-localca], + [chmod 755 samples/swtpm-localca]) AC_OUTPUT echo diff --git a/debian/swtpm-tools.install b/debian/swtpm-tools.install index 137da701e..848276c42 100755 --- a/debian/swtpm-tools.install +++ b/debian/swtpm-tools.install @@ -3,6 +3,7 @@ cat <<_EOF_ /usr/bin/swtpm_bios /usr/bin/swtpm_setup /usr/bin/swtpm_ioctl +/usr/bin/swtpm_localca /usr/share/man/man8/swtpm_bios.8* /usr/share/man/man8/swtpm_cert.8* /usr/share/man/man8/swtpm_ioctl.8* diff --git a/samples/Makefile.am b/samples/Makefile.am index dcbc9b633..7341747e0 100644 --- a/samples/Makefile.am +++ b/samples/Makefile.am @@ -6,12 +6,11 @@ samplesconfdir = $(datadir)/@PACKAGE@ samplessysconfdir = $(sysconfdir) -# swtpm-localca was always installed in /usr/samples/swtpm-localca -bindir = $(samplesconfdir) samplesconf_SCRIPTS = \ swtpm-create-tpmca \ - swtpm-create-user-config-files + swtpm-create-user-config-files \ + swtpm-localca samplessysconf_DATA = \ swtpm-localca.conf \ @@ -22,7 +21,7 @@ noinst_HEADERS = \ swtpm_localca_utils.h bin_PROGRAMS = \ - swtpm-localca + swtpm_localca $(top_builddir)/src/utils/libswtpm_utils.la: $(MAKE) -C$(dir $@) diff --git a/samples/swtpm-localca.in b/samples/swtpm-localca.in new file mode 100755 index 000000000..ca882e537 --- /dev/null +++ b/samples/swtpm-localca.in @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +swtpm_localca_exe="$(dirname "$0")/swtpm_localca" +if ! [ -x "$swtpm_localca_exe" ]; then + swtpm_localca_exe=@BINDIR@/swtpm_localca +fi + +$swtpm_localca_exe "$@" + +exit $? diff --git a/swtpm.spec b/swtpm.spec index b0bfcafa3..5c38989f0 100644 --- a/swtpm.spec +++ b/swtpm.spec @@ -150,6 +150,7 @@ fi %endif %{_bindir}/swtpm_setup %{_bindir}/swtpm_ioctl +%{_bindir}/swtpm_localca %{_mandir}/man8/swtpm_bios.8* %{_mandir}/man8/swtpm_cert.8* %{_mandir}/man8/swtpm_ioctl.8* diff --git a/swtpm.spec.in b/swtpm.spec.in index c54b0a905..4fe60f068 100644 --- a/swtpm.spec.in +++ b/swtpm.spec.in @@ -150,6 +150,7 @@ fi %endif %{_bindir}/swtpm_setup %{_bindir}/swtpm_ioctl +%{_bindir}/swtpm_localca %{_mandir}/man8/swtpm_bios.8* %{_mandir}/man8/swtpm_cert.8* %{_mandir}/man8/swtpm_ioctl.8*