Commit Graph

1523 Commits

Author SHA1 Message Date
Stefan Berger
e7194c6648 swtpm_setup.sh: Adapt od and echo usage for OpenBSD
On OpenBSD 6.2 we have an older version of od that does not support the
-w parameter. Also we have to use the bash echo there since /bin/echo
does not support the -e parameter. We are using /bin/echo on the other
systems since there was (once) a bug when \x0a had to be converted to a
hex number.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-26 16:03:53 -04:00
Stefan Berger
4b6a84190c swtpm_setup: OpenBSD: replace access to proc filesystem
OpenBSD does not have a proc file system from which we could
determine the path that swtpm_setup was run from and where we
expect swtpm_setup.sh to be located in as well. Using getenv("_")
seems to work as a replacement in the OpenBSD case.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-26 16:03:53 -04:00
Stefan Berger
e69423f277 swtpm_setup: Replace shuf usage with $RANDOM.
Replace usage of shuf with a get_random function that produces
a random number between an upper and lower bound.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-26 16:03:52 -04:00
Stefan Berger
da6ca6fab6 samples: OpenBSD scripting fixes
OpenBSD uses an older sed implementation that doesn't understand the
meaning of the '+' for getting one or multiple occurrences of a letter.
Work around this by not using it and trimming white spaces at the end
of a variable using bash.

Use 100 as file descriptor rather than 200 to accomodate OpenBSD,
which only support file descriptors <= 127.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-26 16:03:52 -04:00
Stefan Berger
f2458ef7d6 build-sys: Replace PKG_CHECK_VAR with direct call to $PKG_CONFIG
Older distros may not have PKG_CHECK_VAR due to usage of pkg-config
older than v0.28. So, replace the call to PKG_CHECK_VAR with a direct
call to $PKG_CONFIG. Also use PKG_PROG_PKG_CONFIG to determine the
location of pkg-config.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-24 17:08:05 -04:00
Stefan Berger
4f1912e8e8 tests: fix and enable test_tpm2_ctrlchannel2
test_tpm2_ctrlchannel2 was not active and was not complete. This
patch fixes the test case and activates it. It uses chardev, so
it needs to be gated by WITH_CHARDEV.

Signed-off-by: Stefran Berger <stefanb@linux.vnet.ibm.com>
2018-08-09 14:54:52 -04:00
Stefan Berger
e4405317b3 swtpm_ioctl: Fix number of bytes passed into and expect from ctrl channel
Fix the number of bytes passed into the control channel for commands
and expected for responses. The pointer to the memory is ok.
This fixes uninitialized memory errors reported by valgrind.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-09 11:28:08 -04:00
Stefan Berger
cd2f547d6a swtpm_ioctl: Fix memmory leak before process exit
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-09 11:28:08 -04:00
Stefan Berger
fc36ef35ea swtpm: fix memory leak related to tpmstate directory
This patch fixes a memory leak before process exit.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-09 11:27:48 -04:00
Stefan Berger
9c8202ed79 swtpm: free a CUSE related parameter upon exit
This patch fixes a memory leak before process exit.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-09 10:19:52 -04:00
Stefan Berger
321a22cc66 swtpm: Fix memory leak related to log prefix
This patch fixes a memory leak before process exit.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-09 10:19:31 -04:00
Stefan Berger
40185e481b swtpm: implement ptm_cleanup for cleanup before exit
Implement a common function for cleaning up before exit.
This should now always remove the pid file.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-09 10:19:01 -04:00
Stefan Berger
ccfe1b9654 swtpm: fix memory leak when freeing server struct upon exit
This patch fixes a memory leak before process exit.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-09 10:18:35 -04:00
Stefan Berger
8cafe9d1df swtpm: free pidfile when cleaning up
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-09 10:04:03 -04:00
Stefan Berger
9df216134f rpmbuild: Make build work in Copr and revise spec file
Make the build work in Copr and take a first pass at
revising the spec file.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-08 11:52:28 -04:00
Stefan Berger
dfd53161a7 buils-sys: Include autogen.sh in tarball and use for RPM build
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-08 10:29:19 -04:00
Marc-André Lureau
611a198637 build-sys: fix make distcheck
- fix paths
- ignore chmod issues (they are more package/distro issues)
- scripts are already executable

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2018-08-08 09:58:22 -04:00
Stefan Berger
28c4645454 tests: Activate test case for swtpm-localca
With the SAN data in the certificate properly generated and accepted by
certtool, we can now activate the test case for swtpm-localca.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 14:22:12 -04:00
Stefan Berger
e92942a8b0 tests: quirk for Cygwin
On Cygwin the swtpm_setup executable is located in src/swtpm_setup/.libs
dir and we need to copy the swtpm_setup.sh file there as well.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
64faf455fb build-sys: Build swtpm_setup on all supported platforms
Introduce compile-time variable HAVE_TCSD if the TCSD could
be found. It influences whether TPM 1.2 related swtpm_setup
test cases can be run. If it is set, they can be run.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
c50cb6cba9 tests: Run TPM 2 related swtpm_setup tests under less restrictions
Run TPM 2 related swtpm_setup tests under less restrictions.
For TPM 2 related tests only WITH_GNUTLS, which allows swtpm_cert
to be built, needs to be set since swtpm_setup is now being built
under all conditions.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
5d0136d07b tests: Remove root requirement for test_tpm2_swtpm_setup_create_cert
Remove the requirement to run the test_tpm2_swtpm_setup_create_cert
test with root rights. It's not necessary to run this as root.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
04e45e3cde swtpm_setup: get rid of netstat dependency
Get rid of the dependency on netstat so that we can at least support
swtpm_setup with TPM 2 on Cygwin and BSD later on. This is the first
step into this direction.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
db45e52d67 swtpm_setup: Only try to find tcsd in TPM 1.2 case
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
6da1e3c4a6 swtpm_setup: remove duplicate setting of ECHO variable
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
dbb399de05 build-sys: Make sure python is installed for test cases
Some test cases need either python 2 or 3. Make sure it is installed.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
5cd844d09e build-sys: require netstat to be available if swtpm_setup can be built
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
8579c6de36 swtpm_setup: also check availability of netstat tool in TPM 2 case
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
610cd51e5b tests: Make python test code independent of python 2 or 3
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
71ee437f7f swtpm_setup: check for availability of netstat tool
Check that the netstat tool, which may not be required to be installed,
is indeed installed and usable with a set of command line options.

If this tool is not installed it may end up causing swtpm_setup to
hang forever.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Marc-André Lureau
f9227dda91 build-sys: replace bootstrap with autogen
Follow more closely the https://github.com/cgwalters/build-api.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Marc-André Lureau
f52f56a5b9 git: remove install-sh from repository
It is installed and updated by autofoo.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2018-08-07 12:19:47 -04:00
Marc-André Lureau
7318ae5125 build-sys: use pkg-config variable to check libtpms cryptolib
We also have to move the Travis tests to xenail since PKG_CHECK_VAR
was not available in trusty (14.04).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
26320a82b2 tests: skip sha512 related test if pcrallocate does not support it
Older versions of pcrallocate do not support sha512. Skip the test
that needs it.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
47c7ea7783 tests: Make the killing of processes less noisy
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
313cf75c42 tests: Enable running tests in out-of-source builds
Pass the top_builddir and top_srcdir via TESTS_ENVIRONMENT
variable in Makefile.am.

Use TESTDIR for the path to the test directory and replace
previously used DIR in all occurences.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
430a39d335 build-sys: Use $(top_builddir) instead of $(top_srcdir) for include/swtpm.h
The include file include/swtpm.h will be generated from swtpm.h.in and
reside under the $(top_builddir) rather than the $(top_srcdir).

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
0550d91d52 tests: Check for approximate expected file size with a regex
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
e049a947a9 tests: Adapt loop to handle slow or busy systems
Adapt the loop that is polling for the authentication failure due
to lockout until a certain time. We run the tests also when $timeout
has been reached but don't care for the result if it failed. This
accomodates slow or busy systems that run some of the commands too
slowly and allow the TPM to release the lockout.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
be4bc80df0 tests: Add TPM 2 test for testing the DA timeouts with state suspend/resume
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
7f086ef946 swtpm_setup: Send TPM2_Shutdown(SU_CLEAR) at end of manufacturing
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
9f4d8af2f0 swtpm_setup: Enable allocation of initially active PCR banks
Implement --pcr-banks to allow a user to choose the set of active
PCR banks. We determine the PCR banks available and enable those
that the user chose and that are available.

The log will now print out the following:

Successfully activated PCR banks sha1,sha256 among sha1,sha256,sha384.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
5211d89dfb Update EXTRA_DIST files to be able to build RPM from tar
A few files were wrong in the EXTRA_DIST file list due to changes to
test cases. Add the proper files.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
55caf3716f manpages: Extend swtpm_setup man page with example for non-root user
Extend the swtpm_setup man page with an example for how a non-root
user can create a TPM 2 with an EK and platform certificate.

Document the default locations of the config file swtpm_setup uses.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
8a55b8ac08 swtpm-localca: Cleanse variable before running eval on it
Cleanse the tmp variable before running eval on it. This is to prevent
execution of commands that a hidden in variable values read from a config
file. We only need to resolve the values of variables and don't want
the execution of a subshell command initated by either $(...) or `...` .

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Marc-André Lureau
f9cbc39124 swtpm-localca: create directory for keys if needed
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2018-08-07 12:19:47 -04:00
Marc-André Lureau
a89f460d49 swtpm-localca: evaluate config variables
This will allow to expand environment variables in config files, such as:
statedir = $XDG_RUNTIME_DIR/swtpm-localca

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2018-08-07 12:19:47 -04:00
Marc-André Lureau
331d78dbca swtpm: use XDG_CONFIG_HOME to locate config files
This allows to run swtpm_setup as regular user.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
9e3fab9817 tests: Update test case due to SHA512 support in libtpms
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00
Stefan Berger
6833255094 man pages: add paragraph about --allow-signing to swtpm_setup.pod
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-07 12:19:47 -04:00