Commit Graph

1332 Commits

Author SHA1 Message Date
Stefan Berger
2caa41bd15 build-sys: Bump up version to 0.6.0 at beginning of dev cycle
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-28 08:32:50 -04:00
наб
3dea271c67 debian: drop revision from version, illegal for native-format packages
$ dpkg-buildpackage -us -uc
dpkg-buildpackage: info: source package swtpm
dpkg-buildpackage: info: source version 0.5.0-1
dpkg-buildpackage: info: source distribution RELEASED
dpkg-buildpackage: info: source changed by Stefan Berger <stefanb@linux.ibm.com>
dpkg-source: error: can't build with source format '3.0 (native)':
native package version may not have a revision

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
2020-10-28 08:32:50 -04:00
наб
755881ba27 man: Fix enc[yr]ption typo in swtpm_setup manpage
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
2020-10-27 22:27:36 -04:00
Stefan Berger
ab40d27ab1 man: Extend man pages with --flags support for CUSE TPM
Also fix an error in the man page on the way. 'startup-deactivated'
can only be used with a TPM 1.2, not a TPM 2.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-13 17:08:05 -04:00
Stefan Berger
6559a90269 swtpm_cuse: Implement support for --flags startup-xyz options
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-13 17:08:05 -04:00
Stefan Berger
7eb2c29187 swtpm_cuse: Implement support for --flags not-need-init for CUSE TPM
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-13 17:08:05 -04:00
Stefan Berger
b931e10985 debian/rpm: Adjust changelog for 0.5.0 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-07 14:24:43 -04:00
Stefan Berger
611c589691 CHANGES: Add documentation for changes in 0.5.0
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-07 14:24:43 -04:00
Stefan Berger
5af35971b8 samples: Do not truncate logfile when testing write-access
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-06 15:05:08 -04:00
Stefan Berger
2ba2248351 swtpm_setup: Do not truncate logfile when testing write-access
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-06 15:05:08 -04:00
Stefan Berger
1d6a1554a6 swtpm_setup: Remove TPM state file in case error occurred
Remove the TPM state file in case an error occurred.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-06 15:05:08 -04:00
Stefan Berger
07ea18bc38 build-sys: Add python-install and python-uninstall targets
To force the installation of the python programs add a python-install
target. This solves an installation issue with non-standard prefix,
like not using /usr or /usr/local, as may be the case on OS X (Apple)
when using homebrew. It leaves the 'make distcheck' working, which also
uses a non-standard prefix and where we don't want to install the tools
due to issues with removing them afterwards where pip3 cannot be used.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-05 12:06:05 -04:00
Stefan Berger
9591808d18 tests: Fix path to swtpm-localca
This patch fixes the path to swtpm-localca to avoid this type of
error because of swtpm_localca_conf having been created in another
directory. This error occurred whan running

sudo bash -c "make -j32 distcheck"

Traceback (most recent call last):
  File "/home/stefanb/tmp/swtpm/swtpm-0.5.0/samples/swtpm-localca", line 5, in <
    from py_swtpm_localca.swtpm_localca import main
  File "/home/stefanb/tmp/swtpm/swtpm-0.5.0/samples/py_swtpm_localca/swtpm_local
    from py_swtpm_localca.swtpm_localca_conf import SYSCONFDIR
ModuleNotFoundError: No module named 'py_swtpm_localca.swtpm_localca_conf'

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-05 10:03:18 -04:00
Stefan Berger
3fde803eb6 swtpm: Write state files atomically using file renaming
To support writing state files atomically we first write into
a temporary file and then rename it.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-05 08:56:20 -04:00
Stefan Berger
d4c60e44ce tests: Allow 'ss' as an alternative to 'netstat'
Some distros (openSUSE) have deprecated the 'net-tools' package,
so we allow for 'ss' as an alternative tool from the
iproute/iproute2 package. This is only relevant for test cases.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-02 15:56:42 -04:00
Stefan Berger
3f2bde0891 swtpm_setup: Add missing --print-capabilities to help screen
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-02 15:15:04 -04:00
Stefan Berger
d437937f39 swtpm: Prefix debug print function with SWTPM rather than TPM
To avoid clashes with libtpms print functions, prefix the print function
in swtpm with SWTPM_ rather than TPM_. This may matter on older systems
where libtpms could call into swtpm's TPM_PrintAll function due to it
having the same name as libtpms's function.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-29 18:12:22 -04:00
Elms
8d086ee9de Use correct LDFLAGS for non-standard libtpms locations 2020-09-24 21:30:10 -04:00
Stefan Berger
48275746e3 samples: Use ${HOME}/.config if XDG_CONFIG_HOME is not set (RHEL)
When creating the user config files, fall back to using ${HOME}/.config
if XDG_CONFIG_HOME is not set on a system.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-23 18:14:23 -04:00
Stefan Berger
03c00c0247 swtpm_setup: Do not hardcode '/etc' but use SYSCONFDIR
Do not hardcode the /etc path but use the compile-time generated
SYSCONFDIR instead.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-23 09:42:38 -04:00
Stefan Berger
7419536fb9 rpm: Create swtpm-tools-pkcs11 package
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-22 12:27:16 -04:00
Stefan Berger
3a3e5661f0 debian/rpm: Adjust packaged files for swptm-localca in python
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-22 12:27:16 -04:00
Stefan Berger
8bac7cdf22 tests: start tpm2-abrmd for test case
Start tpm2-abrmd for the test case 'test_tpm2_samples_create_tpmca' rather than
expecting it to be already running.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-22 11:40:57 -04:00
Stefan Berger
7b72dfedec samples: swtpm-localca: Pass password via template file when possible
Pass the CA's private key password via the template file. Remove recently
added old GnuTLS support. Extend man page with a paragraph about short-
comings of certtool that doesn't seem to allow private key password being
passed either as environment variable or template file.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-21 16:01:20 -04:00
Stefan Berger
c73771b0c5 samples: Fix support for -h and -? options in swtpm-localca
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-21 13:17:39 -04:00
Stefan Berger
31ac728852 swtpm_setup: Fix support for -h and -? options
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-21 13:17:39 -04:00
Stefan Berger
3ed0744de0 samples: Add --password parameter for older GnuTLS versions
Older versions of GnuTLS need --password on the command line while
newer versions require GNUTLS_PIN to be set to pass the password.
So, this patch accomodates older versions of GnuTLS.

Older version of GnuTLS seem to NOT be able to handle a CA private
key needing a password and a signing key needing a password when
creating the intermediate CA. So this case of 2 passwords will
always fail.

The value of the local CA is not so high that passing passwords on
the command line would be an issue. Later on when using the CA the
password are set via environment variables, so not visible to other
users.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-18 20:12:01 -04:00
Stefan Berger
14d2d4381d samples: Add support for pkcs11 module environment variables to config file
Add support for pkcs11 module environment variables to the config file.
These variables may have the following format:

   env:VARNAME=VALUE

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-18 12:09:11 -04:00
Stefan Berger
cc592a0931 samples: Also allow signingkey_password to be used not just 'SWTPM_PKCS11_PIN'
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-18 12:09:11 -04:00
Stefan Berger
1ed75624a6 Travis: Run pylint on new swtpm-localca, remove flock on OS X
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-18 12:09:11 -04:00
Stefan Berger
b71da43026 samples: Rewrite swtpm-localca in python
Rewrite swtpm-localca in python and get rid of the bash file and the flock
dependency.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-18 12:09:11 -04:00
Stefan Berger
4cd9390bed man: Extend man pages with further locations of options and config files
Extend the man pages with further locations for the options and config
files in ${XDG_CONFIG_HOME} or ${HOME}/.confg.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-18 12:09:11 -04:00
Stefan Berger
ecabc015ae swtpm_setup: Add missing .config path when using ${HOME}
During the rewrite the additonal "/.config/" got dropped from the
path when using ${HOME} for locating he default config file.
Re-add it.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-17 13:05:37 -04:00
Stefan Berger
a73e9cb831 samples: Apply password for signing key when creating platform cert (bugfix)
Apply the password for the signing key and parent key when creating a
platform certificate. The bug was introduced in commit 961bb827
"samples: Use new pwd format option for secretly passing passwords"

Extend a test case to ensure that the passwords are always used.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-15 21:08:32 -04:00
Stefan Berger
79a0bdb483 samples: Properly apply passwords for localca signing key (bugfix)
When the local CA was create the signing key of the intermediate CA
was not properly protected by the passwords. This patch fixes this.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-15 21:08:32 -04:00
Jonas Witschel
fdaa6f1f1c build-sys: make pip dependency check non-fatal
The only place where pip is required is in src/swtpm_setup/Makefile.am, l. 48,
to uninstall a manually built package. Most people will have pip already
installed, since it comes bundled with Python by default. It might not be
installed by default in minimal build environments used for distribution
packaging, but these rely on the file tracking by a package manager instead of
using "make uninstall".

In conclusion, I think requiring pip is only helpful for a very limited number
of people, and is just a superfluous build dependency for distribution
packagers. Issuing a warning that the package cannot be uninstalled cleanly if
pip is not found seems enough.

Signed-off-by: Jonas Witschel <diabonas@archlinux.org>
2020-09-14 07:41:24 -04:00
Jonas Witschel
3dafa38eb7 build-sys: add configure option to disable installation of Python module
Distributions often have their own guidelines regarding installation of Python
modules (e.g. Arch Linux mandates using --optimize=1 for setup.py install,
which the Makefile in this project does not do). Add an option
"--disable-python-installation" (disabled by default) to allow skipping the
Python installation process entirely so that distributions can take care of
this process manually in their preferred way.

Signed-off-by: Jonas Witschel <diabonas@archlinux.org>
2020-09-14 07:40:31 -04:00
Stefan Berger
0586d2f55a build-sys: Use -Wl,-z,relro and -Wl,-z,now only when linking (clang)
Clang complains if eiher one of those linker flags are used during compilation:

clang-9: error: -Wl,-z,relro: 'linker' input unused [-Werror,-Wunused-command-line-argument]
clang-9: error: -Wl,-z,now: 'linker' input unused [-Werror,-Wunused-command-line-argument]

This patch applies those flags only when linking.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-12 10:55:32 -04:00
Stefan Berger
2ba23cee13 build-sys: Use AC_LINK_IFELSE to check whether support for hardening flags
Cygwin's linker does not support -Wl,-z,relro and -Wl,-z,now and
AC_COMPILE_IFELSE did only compile but not link, so it wouldn't detect
whether these flags are supported. So, use AC_LINK_IFELSE to detect
support for these flags.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-11 12:23:30 -04:00
Stefan Berger
3064a72ff0 swtpm_setup: Get rid of 'c' code and support changing user in python
Get rid of the 'c' code that only changed the user and add for support of
the --runas option to change to a different user in the python part.

To get 'make distcheck' to work I needed to name the swtpm_setup python
script with the suffix .in so that it gets copied to the build directory
as swtpm_setup. We need to change execute permissions on this file after
copying.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-09 09:53:05 -04:00
Stefan Berger
094dba930f swtpm_setup: Fix wrong variable name detected by pylint 2.4.4
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-09 09:53:05 -04:00
Stefan Berger
3bf8f4628c build-sys: Bump up version to 0.5.0 at beginning of dev cycle
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-09 06:49:50 -04:00
Stefan Berger
0c238a2c93 debian/rpm: Adjust changelog for 0.4.0 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-08-28 17:43:06 -04:00
Stefan Berger
2feefb2c04 CHANGES: Extend documentation for changes in 0.4.0
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-08-28 17:43:06 -04:00
Stefan Berger
7ebb501646 Travis: Check for clean python files and add new python dependencies
Check for clean python files under swtpm_setup.py using pylint3.
Add new python dependencies.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-08-28 16:27:15 -04:00
Stefan Berger
5d613001c1 debian/rpm: Adjust build and runtime dependencies and directory ownership
Remove tpm-tools from runtime dependencies. Keep trousers for the
creation of the 'tss' user for now. Add python related dependencies.

Adjust the directory ownership for /var/lib/swtpm-localca to tss:root and
the mode flags to 0750. The new CA now may still be created as tss:tss but
users in the tss group will not have access to it.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-08-28 16:27:15 -04:00
Stefan Berger
cc410ca91b swtpm_setup: Switch over to new python tool and get rid of the bash script
Switch over to the new python implementation of swtpm_setup. We need to
also adjust test cases that involved the tcsd that otherwise fail for
various reasons. For in-place testing we need to adjust the PYTHONPATH
and PATH so that swtpm_setup.py can be found and so that swtpm_setup.py
then finds swtpm if it is not explicitly passed as parameter.

Adjust the man page for swtpm_setup to reflect the changes.

We now can run swtpm_setup as any user. However, libvirt still runs it
as tss:tss (for example), which is then creating the signing key as tss:tss
as well. Ideally libvirt would run it as tss:root or any other combination
since the tss group may be used for user wanting to access /dev/tpmrm0 for
example. We at least change the directory ownership of /var/lib/swtpm-localca
to tss:root and keep the world out of this directory.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-08-28 16:27:15 -04:00
Stefan Berger
eee8cb5dfb swtpm_setup: Rewrite swtpm_setup.sh in python
Rewrite swtpm_setup.sh in python. Use a permanent connection from the
tool to swtpm via passing file descriptors of a unix socketpair. Implement
all functionality in python so that we don't rely on trousers and tpm-tools
for swtpm_setup. This now allows any user to setup a TPM 1.2 whereas before
it had to be root or the tss user.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-08-28 16:27:15 -04:00
Stefan Berger
83f4e96045 tests: Have softhsm_setup use the temporary directory now
Modify the pkcs11 related test case to set the environment variable for
softhsm_setup to use the temporary directory for config file and state
of softhsm. Also set the SOFTHSM2_CONF environment variable since
certtool also uses the pkcs11 module which in turn will look for its
config file.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-08-27 20:26:27 -04:00
Stefan Berger
9da72af4fc tests: Enable softhsm_setup to work with a temporary directory
Use softhsm's SOFTHSM2_CONF environment variable to set the directory
where the configration file is located so that we can now use a temporary
directory for the location of the directory. Use the environment variable
SOFTHSM_SETUP_CONFIGDIR to set the directory where softhsm_setup can
setup its temporary environment for the config file and state of softhsm.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-08-27 20:26:27 -04:00