Skip to content

Commit

Permalink
samples: Replace swtpm_localca with script calling swtpm-localca (issue
Browse files Browse the repository at this point in the history
#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 <stefanb@linux.ibm.com>
  • Loading branch information
stefanberger committed Jul 16, 2021
1 parent 05f64f5 commit fd00c5f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions debian/swtpm-tools.install
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
7 changes: 3 additions & 4 deletions samples/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 $@)
Expand Down
10 changes: 10 additions & 0 deletions samples/swtpm-localca.in
Original file line number Diff line number Diff line change
@@ -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 $?
1 change: 1 addition & 0 deletions swtpm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
1 change: 1 addition & 0 deletions swtpm.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down

0 comments on commit fd00c5f

Please sign in to comment.