Commit Graph

1332 Commits

Author SHA1 Message Date
Stefan Berger
33be7be2a0 Replace tests with '==' through '='
On NetBSD configure.ac cannot have '==' in tests. So we have to replace
them with '='.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-29 12:59:29 +00:00
Stefan Berger
acdf48b0bd tests: Make test_ctrlchannel work on FreeBSD
To get /dev/ptmx on FreeBSD we need to run `kldload pty`.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-29 02:31:21 +00:00
Stefan Berger
91004268f0 swtpm_setup: Make work on FreeBSD; adapt echo -en
Make swtpm_setup.sh work on FreeBSD.
A common fix for the problem related to echo stopping to write
data into a socket after the first occurrence of \x0a sees to
write it into a pipe and cat the data from there.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-28 22:16:07 -04:00
Stefan Berger
401e670232 tools: Make compileable on FreeBSD
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-29 01:18:46 +00:00
Stefan Berger
f37f86c0dc swtpm_setup: Adapt NVRAM indices for ECC keys
A (draft) specification indicates the ECC key NVRAM indices to use.
Adapt the code to use them in case of EK ECC key.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-27 11:03:43 -04:00
Stefan Berger
2266da36d9 samples: create lock with name .lock.swtpm-localca rather than .lock
To avoid clashes with the lock files created by swtpm, have
swtpm-localca creata a lock file with the name .lock.swtpm-localca
so they can share directories if necessary.

This patch makes tests/test_tpm2_swtpm_setup_create_cert run on
OpenBSD since the swtpm and swtpm-localca then do not interfere
with the file locks. This doesn't seem to be an issue on Linux
or Cygwin, though, where probably the file locking is implemented
differently.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.om>
2018-08-26 16:03:53 -04:00
Stefan Berger
b096be2603 build-sys: explicitly adapt sysconfdir and datarootdir follow $prefix
When using --prefix=/usr never install into /etc/usr.
When using --prefix=/ never install into //share/.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-26 16:03:53 -04:00
Stefan Berger
571a8eed77 build-sys: Add GNUTLS_C/LDFLAGS to CFLAGS when checking for gnutls
On OpenBSD the gnutls library is in /usr/local/lib and AC_CHECK_LIB does
find it there without explicitly adding GNUTLS_CFLAGS and GNUTLS_LDFLAGS to
CFLAGS.

Also add the GNUTLS_CFLAGS to CFLAGS at the end.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-26 16:03:53 -04:00
Stefan Berger
6d462f2e06 swtpm_setup.sh: wrap stat in get_filesize
The OpenBSD stat tool uses -f%z to return the file size in bytes.
So we wrap stat in get_filesize and call it with different parameters
depending on the system.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-26 16:03:53 -04:00
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