Move swtpm_localca sources from samples/ to src/

- Move swtpm_localca's sources out of samples/ (where they no longer
  belong now that swtpm_localca is a binary) to src/swtpm_localca/.
- Tests now call the swtpm_localca binary directly at the location
  where it was built, as they do with all other compiled programs.
- Simplify samples/swtpm-localca.in and delete swtpm-localca.2inst,
  removing the now-unnecessary logic to selectively call swtpm_localca
  from different locations (samples/ when running tests vs. /usr/bin/
  post-installation).

Signed-off-by: Nick Chevsky <nchevsky@users.noreply.github.com>
This commit is contained in:
Nick Chevsky 2021-07-24 13:54:40 -05:00 committed by Stefan Berger
parent edfb8d8ad9
commit ddc7521653
19 changed files with 48 additions and 59 deletions

5
.gitignore vendored
View File

@ -39,11 +39,8 @@ Makefile
/man/man3/*.3
/man/man8/*.8
/samples/swtpm-create-user-config-files
/samples/swtpm_localca
/samples/swtpm-localca
/samples/swtpm-localca.2inst
/samples/swtpm-localca.conf
/samples/swtpm_localca_conf.h
/samples/swtpm_setup.conf
/src/selinux/*.pp.bz2
/src/selinux/swtpm.pp
@ -57,6 +54,8 @@ Makefile
/src/swtpm_bios/swtpm_bios
/src/swtpm_cert/swtpm_cert
/src/swtpm_ioctl/swtpm_ioctl
/src/swtpm_localca/swtpm_localca
/src/swtpm_localca/swtpm_localca_conf.h
src/swtpm_setup/swtpm_setup
src/swtpm_setup/swtpm_setup_conf.h
/test-driver

View File

@ -541,10 +541,8 @@ AC_CONFIG_FILES([Makefile \
debian/swtpm-tools.postinst \
swtpm.spec \
samples/Makefile \
samples/swtpm-localca.2inst \
samples/swtpm-localca.conf \
samples/swtpm-create-user-config-files \
samples/swtpm_localca_conf.h \
samples/swtpm_setup.conf \
include/Makefile \
include/swtpm/Makefile \
@ -555,6 +553,8 @@ AC_CONFIG_FILES([Makefile \
src/swtpm_bios/Makefile \
src/swtpm_cert/Makefile \
src/swtpm_ioctl/Makefile \
src/swtpm_localca/Makefile \
src/swtpm_localca/swtpm_localca_conf.h \
src/swtpm_setup/Makefile \
src/swtpm_setup/swtpm_setup_conf.h \
src/utils/Makefile \

View File

@ -9,43 +9,17 @@ samplessysconfdir = $(sysconfdir)
samplesconf_SCRIPTS = \
swtpm-create-tpmca \
swtpm-create-user-config-files
swtpm-create-user-config-files \
swtpm-localca
samplessysconf_DATA = \
swtpm-localca.conf \
swtpm-localca.options \
swtpm_setup.conf
noinst_HEADERS = \
swtpm_localca.h \
swtpm_localca_utils.h
bin_PROGRAMS = \
swtpm_localca
$(top_builddir)/src/utils/libswtpm_utils.la:
$(MAKE) -C$(dir $@)
swtpm_localca_DEPENDENCIES = \
$(top_builddir)/src/utils/libswtpm_utils.la
swtpm_localca_SOURCES = \
swtpm_localca.c \
swtpm_localca_utils.c
swtpm_localca_LDADD = \
$(top_builddir)/src/utils/libswtpm_utils.la
swtpm_localca_LDFLAGS = \
-L$(top_builddir)/src/utils -lswtpm_utils \
$(HARDENING_LDFLAGS) \
$(GLIB_LIBS)
swtpm_localca_CFLAGS = \
-I$(top_srcdir)/src/utils \
$(HARDENING_CFLAGS) \
$(GLIB_CFLAGS)
install-data-local:
$(MKDIR_P) $(DESTDIR)$(localstatedir)/lib/swtpm-localca
if test -z $(DESTDIR); then \
@ -53,13 +27,6 @@ install-data-local:
chmod 0750 $(DESTDIR)$(localstatedir)/lib/swtpm-localca || true; \
fi
install-exec-local:
$(MKDIR_P) $(DESTDIR)$(samplesconfdir)
$(INSTALL_SCRIPT) swtpm-localca.2inst $(DESTDIR)$(samplesconfdir)/swtpm-localca
uninstall-local:
rm -f $(DESTDIR)$(samplesconfdir)/swtpm-localca
EXTRA_DIST= \
swtpm-create-tpmca \
swtpm-create-user-config-files \

View File

@ -1,5 +0,0 @@
#!/usr/bin/env sh
@BINDIR@/swtpm_localca "$@"
exit $?

View File

@ -1,10 +1,5 @@
#!/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 "$@"
@BINDIR@/swtpm_localca "$@"
exit $?

View File

@ -10,6 +10,7 @@ SUBDIRS = \
swtpm_bios \
swtpm_cert \
swtpm_ioctl \
swtpm_localca \
swtpm_setup
if WITH_SELINUX

View File

@ -0,0 +1,32 @@
#
# src/swtpm_localca/Makefile.am
#
# For the license, see the LICENSE file in the root directory.
#
bin_PROGRAMS = \
swtpm_localca
noinst_HEADERS = \
swtpm_localca.h \
swtpm_localca_utils.h
swtpm_localca_CFLAGS = \
-I$(top_srcdir)/src/utils \
$(GLIB_CFLAGS) \
$(HARDENING_CFLAGS)
swtpm_localca_DEPENDENCIES = \
$(top_builddir)/src/utils/libswtpm_utils.la
swtpm_localca_LDADD = \
$(top_builddir)/src/utils/libswtpm_utils.la
swtpm_localca_LDFLAGS = \
-L$(top_builddir)/src/utils -lswtpm_utils \
$(GLIB_LIBS) \
$(HARDENING_LDFLAGS)
swtpm_localca_SOURCES = \
swtpm_localca.c \
swtpm_localca_utils.c

View File

@ -80,10 +80,10 @@ TESTS += \
test_swtpm_cert \
test_swtpm_setup_create_cert \
test_tpm2_parameters \
test_tpm2_samples_swtpm_localca \
test_tpm2_samples_swtpm_localca_pkcs11 \
test_tpm2_swtpm_cert \
test_tpm2_swtpm_cert_ecc \
test_tpm2_swtpm_localca \
test_tpm2_swtpm_localca_pkcs11 \
test_tpm2_swtpm_setup_create_cert
if HAVE_TCSD
TESTS += \

View File

@ -24,7 +24,7 @@ source ${abs_top_builddir:-$(dirname "$0")/..}/tests/test_config
SWTPM_SETUP=${ROOT}/src/swtpm_setup/swtpm_setup
SWTPM_CREATE_TPMCA=${SRCDIR}/samples/swtpm-create-tpmca
SWTPM_LOCALCA=${ROOT}/samples/swtpm-localca
SWTPM_LOCALCA=${ROOT}/src/swtpm_localca/swtpm_localca
SWTPM=${ROOT}/src/swtpm/swtpm
SWTPM_IOCTL=${ROOT}/src/swtpm_ioctl/swtpm_ioctl

View File

@ -8,7 +8,7 @@ SRCDIR=${abs_top_srcdir:-$(dirname "$0")/..}
source ${TESTDIR}/common
SWTPM_LOCALCA=${ROOT}/samples/swtpm-localca
SWTPM_LOCALCA=${ROOT}/src/swtpm_localca/swtpm_localca
workdir=$(mktemp -d)

View File

@ -42,7 +42,7 @@ SRCDIR=${abs_top_srcdir:-$(dirname "$0")/..}
SWTPM_SETUP=${ROOT}/src/swtpm_setup/swtpm_setup
SWTPM_CREATE_TPMCA=${SRCDIR}/samples/swtpm-create-tpmca
SWTPM_LOCALCA=${SRCDIR}/samples/swtpm-localca
SWTPM_LOCALCA=${ROOT}/src/swtpm_localca/swtpm_localca
SWTPM=${ROOT}/src/swtpm/swtpm
SWTPM_IOCTL=${ROOT}/src/swtpm_ioctl/swtpm_ioctl

View File

@ -7,7 +7,7 @@ TOPBUILD=${abs_top_builddir:-$(dirname "$0")/..}
TOPSRC=${abs_top_srcdir:-$(dirname "$0")/..}
TESTDIR=${abs_top_testdir:-$(dirname "$0")}
SWTPM_LOCALCA=${TOPBUILD}/samples/swtpm-localca
SWTPM_LOCALCA=${TOPBUILD}/src/swtpm_localca/swtpm_localca
workdir=$(mktemp -d "/tmp/path with spaces.XXXXXX")

View File

@ -7,7 +7,7 @@ TOPBUILD=${abs_top_builddir:-$(dirname "$0")/..}
TOPSRC=${abs_top_srcdir:-$(dirname "$0")/..}
TESTDIR=${abs_top_testdir:-$(dirname "$0")}
SWTPM_LOCALCA=${TOPBUILD}/samples/swtpm-localca
SWTPM_LOCALCA=${TOPBUILD}/src/swtpm_localca/swtpm_localca
workdir=$(mktemp -d)
if [ $? -ne 0 ]; then

View File

@ -9,7 +9,7 @@ TESTDIR=${abs_top_testdir:-$(dirname "$0")}
source ${TESTDIR}/common
SWTPM_LOCALCA=${TOPBUILD}/samples/swtpm-localca
SWTPM_LOCALCA=${TOPBUILD}/src/swtpm_localca/swtpm_localca
workdir=$(mktemp -d "/tmp/path with spaces.XXXXXX")