Commit Graph

157 Commits

Author SHA1 Message Date
Christopher Byrne
83361e74d7 configure.ac: Use m4sh in autoconf variable checks
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-30 16:10:50 -04:00
Christopher Byrne
2190513dbf configure.ac: Remove debug option
The user can set it themselves in CFLAGS. Autoconf defaults to -O2 -g
if CFLAGS is not set.

Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-30 16:10:50 -04:00
Christopher Byrne
079d7e3b46 configure.ac: Use m4sh and pkgconf macros for openssl
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-30 08:39:36 -04:00
Christopher Byrne
7c8aa19ed8 configure.ac: Simplify SELinux checks
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-30 08:39:36 -04:00
Christopher Byrne
cf46ff2cc0 configure.ac: Use m4sh and pkgconf macros for gnutls
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-30 08:39:36 -04:00
Christopher Byrne
ccb7e1c2f4 configure.ac: Use pkgconf for gmp
pkgconf supports setting GMP_CFLAGS and GMP_LIBS if the pkgconf file
does not exist, for older (pre-2019) distributions.

Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-30 01:12:42 -04:00
Christopher Byrne
0d1bb323e3 configure.ac: Use m4sh and pkgconf for CUSE support
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-30 01:12:42 -04:00
Christopher Byrne
754e23e416 configure.ac: Use pkgconf and m4sh for libseccomp
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-30 01:12:42 -04:00
Christopher Byrne
21f697a788 configure.ac: Use pkgconf and m4sh for libtpms crypto
PKG_CHECK_VAR was been available since 2014

Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-30 01:12:42 -04:00
Christopher Byrne
f37ee0e843 configure.ac: Use m4sh for sanitizers
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-29 22:44:15 -04:00
Christopher Byrne
a371f75890 configure.ac: Use m4sh for test coverage
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-29 22:44:15 -04:00
Christopher Byrne
ab4ef15ef3 configure.ac: Use m4sh in hardening
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-29 22:44:15 -04:00
Christopher Byrne
03dd21b25d configure.ac: Use m4sh for tests
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-29 22:44:15 -04:00
Christopher Byrne
f8910312df configure.ac: Use m4sh for chardev
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-29 22:44:15 -04:00
Christopher Byrne
ae580c90c4 configure.ac: Use pkgconf for glib
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-29 22:44:15 -04:00
Christopher Byrne
b1a6b5fa61 configure.ac: Use pkgconf of json-glib
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-29 22:44:15 -04:00
Christopher Byrne
af6b2ce0cd configure.ac: Clean up libtpms checks
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-29 22:44:15 -04:00
Christopher Byrne
6c7f9cd07a configure.ac: Use pkgconf macros for libtasn1
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-29 22:44:15 -04:00
Christopher Byrne
a59486aee4 configure.ac: Use correct m4 comments
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
2025-06-29 22:44:15 -04:00
Leo
17fc25d48a cuse: add libfuse3 support
libfuse2 contains unaddressed security issue. (libfuse/libfuse#15)

libfuse3 is preferred over libfuse2, while libfuse2 support is kept as
fallback.

	- src/swtpm/cuse_tpm.c: fuse3 as default, add a macro `WITH_FUSE2` when fallback fuse library is linked against
	- configure.ac: check fuse3, if not found, check fuse2, if still not found, fail out; show LIBFUSE_CFLAGS and LIBFUSE_LIBS in `./configure` output

Signed-off-by: Leo <i@hardrain980.com>
2025-05-22 10:47:23 -04:00
Stefan Berger
62a5767f90 build-sys: Bump up version to 0.11.0 at beginning of dev cycle
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-12-02 15:24:57 -05:00
Sergei Trofimovich
599e2436d4 configure.ac: enable 64-bit file API on 32-bit systems
My local filesystem is btrfs with a long life. It's inodes ecxeed 32-bit
space and that causes test failures in `swtpm` on `i686-linux`
containers:

    FAIL: test_parameters
    FAIL: test_swtpm_setup_file_backend
    FAIL: test_swtpm_setup_overwrite
    FAIL: test_tpm2_swtpm_setup_create_cert
    FAIL: test_tpm2_swtpm_setup_overwrite
    FAIL: test_swtpm_setup_create_cert
    FAIL: test_tpm2_parameters

The example test failure log looks this way:

    FAIL: test_migration_key
    ========================

    Need to be root to run test with CUSE interface.
    Need to be root to run test with CUSE interface.
    ==== Starting swtpm with interfaces socket+socket ====
    Test 1: Ok
    ==== Starting swtpm with interfaces socket+socket ====
    Test 2: Ok
    ==== Starting swtpm with interfaces socket+socket ====
    swtpm: Missing migration key to decrypt volatilestate
    Test 3: Ok
    ==== Starting swtpm with interfaces socket+socket ====
    Could not stat file '/build/tests/data/migkey1/volatilestate.bin': Value too large for defined data type
    Error: Could not load encrypted volatile state into TPM.
    FAIL test_migration_key (exit status: 1)

The `stat()` fails because inode value exceeds 32-bit value:

    $ stat /build/tests/data/migkey1/volatilestate.bin
      File: /build/tests/data/migkey1/volatilestate.bin
      Size: 1290            Blocks: 8          IO Block: 4096   regular file
    Device: 0,30    Inode: 9639547569  Links: 1
    ...

The change fixes all the test failures. To fix
`test_tpm2_swtpm_setup_create_cert` I also had to include `config.h`
into `swtpm_backend_dir.c` to get 64-bit file open there as well.

Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
2024-11-04 14:14:09 -05:00
Stefan Berger
04ebf36775 build-sys: Add -Wshadow to the CFLAGS
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-09-24 13:22:56 -04:00
Stefan Berger
718714e9f2 build-sys: Require that libtpms v0.10 is available for TPMLIB_SetProfile
Libtpms v0.10 adds the TPMLIB_SetProfile call that swtpm needs to set a
profile. Check whether the API call is available in the local libtpms
installation.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-07-22 09:46:58 -04:00
Stefan Berger
1f857cf529 build-sys: Bump up version to 0.10.0 at beginning of dev cycle
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2024-06-27 09:37:21 -04:00
Stefan Berger
d258668d51 build-sys: Add support for --disable-tests to disable tests
Add support for --disable-tests to disable the tests and the checking
for tools that only need to be installed for the tests. Keep the tests
enabled as default as it was before.

Resolves: https://github.com/stefanberger/swtpm/issues/843
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-03-22 11:18:05 -04:00
Stefan Berger
63aae4d2a4 build-sys: Display GMP_LIBS and GMP_CFLAGS
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-08-29 18:59:13 -04:00
Stefan Berger
a61c08a4c7 build-sys: Only display warning if pkg-config for gmp fails
Since many older gmp development packages do not provide the pkg-config
file for gmp, just display a warning and fall back to default values.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-08-28 12:19:42 -04:00
Stefan Berger
605e0ce880 build-sys/rpm/debian: Add gmp library and devel package as dependency
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-08-22 21:21:03 -04:00
Stefan Berger
fd2c9fdeab utils: Consolidate compile time configuration variables in swtpm_conf.h
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-04-17 10:55:16 -04:00
ben-dav-lytle
546f2367d6 use PKG_CHECK_MODULES to check libtpms version
Signed-off-by: Ben Lytle <ben.dav.lytle@hpe.com>
2023-03-09 16:09:06 -05:00
Stefan Berger
6709a4ee54 build-sys: Bump up version to 0.9.0 at beginning of dev cycle
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-11-11 11:58:11 -05:00
William Roberts
b91fc6e610 configure: check for bash
PCR Bank verification needs bash, so check for bash. While at it use the
autoconf shell construct macros over raw shell syntax which is slightly
more portable.

Examples:
./configure --enable-default-pcr-banks=sha256,sha920
checking which PCR banks to activate by default... configure: error: sha256,sha920 is an invalid list of PCR banks

./configure --enable-default-pcr-banks=sha256,sha512
checking which PCR banks to activate by default... sha256,sha512

./configure
checking which PCR banks to activate by default... sha256

Signed-off-by: William Roberts <william.c.roberts@intel.com>
2022-07-12 13:47:36 -04:00
Stefan Berger
a772d48c0c selinux: Replace hardcoded install path with @prefix@
Replace the hardcoded install path in src/selinux/swtpm.fc and
src/selinux/swtpmcuse.fc with @prefix@ and append .in to these files so
that they are generated when running configure.

Add the selinux policy input files with their suffix to the CLEANFILES
variable so they get cleaned up and 'make distcheck' works.

Resolves: https://github.com/stefanberger/swtpm/issues/711
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-06-28 07:55:20 -04:00
Stefan Berger
a39c3792ba swtpm: Disable OpenSSL FIPS mode to avoid libtpms failures
While libtpms does not provide any means to disable FIPS-disabled crypto
algorithms from being used, work around the issue by simply disabling the
FIPS mode of OpenSSL if it is enabled. If it cannot be disabled, exit
swtpm with a failure message that it cannot be disabled. If FIPS mode
was successfully disabled, print out a message as well.

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2090219
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-06-16 07:36:12 -04:00
Stefan Berger
607f1f800a build-sys: Fix configure script to support _FORTIFY_SOURCE=3
gcc 12.1 supports _FORTIFY_SOURCE=3. Modify the existing check for whether
_FORTIFY_SOURCE=2 can be used to test compile with the user provided
CFLAGS and only add _D_FORTIFY_SOURCE=2 to the HARDENING_CFLAGS if the
user doesn't provide anything that's not compatible.

Following an online article _FORTIFY_SOURCE=3 may add more overhead, so
we only go up to level 2 for now and let build servers or user provide
the higher level via the CFLAGS.

https://developers.redhat.com/blog/2021/04/16/broadening-compiler-checks-for-buffer-overflows-in-_fortify_source#what_s_next_for__fortify_source

Resolves: https://github.com/stefanberger/swtpm/issues/688
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-04-04 11:45:36 -04:00
Stefan Berger
f4cdeb61b9 build-sys: Define __USE_LINUX_IOCTL_DEFS in header file (Cygwin)
To be able to test-compile with include/swtpm/tpm_ioctl.h in configure.ac
move the definition of __USE_LINUX_IOCTL_DEFS out of the configure script
into the header file so that the #define is there when needed. In the
configure.ac script the CFLAGS were extended only after the test-compiling
to determine the HARDENING_CFLAGS and the test-compilation failed on Cygwin
(only) since the tpm_ioctl.h didn't compile because of this missing
 #define.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-04-04 11:45:36 -04:00
Stefan Berger
2579038d76 build-sys: Move block with CUSE-related tests after initial CUSE tests
Mof the block with the CUSE-related tests further up to be following the
first set of CUSE-related tests.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-24 08:40:00 -04:00
Stefan Berger
b7f55fd041 build-sys: Show the value of with_chardev after test for chardev
Show the value of with_chardev after the test for whether to build
with chadev rather than with_cuse.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-24 08:40:00 -04:00
Stefan Berger
e735328e3c build-sys: Determine GNUTLS_LIBS using pkg-config [OS X]
Determine GNUTLS_LIBS using pkg-config rather than hard-coding
it. On OS X it may return a -L<path> to succeed the linking.

Resolves: https://github.com/stefanberger/swtpm/issues/676
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-24 08:40:00 -04:00
Stefan Berger
8a05e8fd52 build-sys: Add probing for -fstack-protector
Add probing for -fstack-protector to the existing
-fstack-protector-strong since not all platforms support either one
of them.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-02 21:20:26 -05:00
Seunghun Han
33aa135545 Move *.conf and *.options to man5
According to the man page sections guideline, man8 should be used
for system administration commands. So this commit moves *.conf and
*.options files to man5.

Signed-off-by: Seunghun Han <kkamagui@gmail.com>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-11-22 18:30:17 -05:00
Stefan Berger
3115dff02f build-sys: Bump up version to 0.8.0 at beginning of dev cycle
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-11-20 12:02:11 -05:00
Stefan Berger
9726af516f build-sys: Move regex to test PCR banks into configure script
Move the regex test for the PCR banks into the configure script.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-11-08 09:03:44 -05:00
Stefan Berger
df4046d0e4 build-sys: Add support for --enable-default-pcr-banks=list of PCR banks
Add an option that allows for the configuration of the default PCR bank
to use. This was currently hard coded to sha256 and now may be passed
via this option. The fallback is still sha256. Valid PCR bank names are
sha1, sha256, sha384, and sha512. The passed list must be a comma-
separated list of the valid PCR bank names.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-10-29 15:36:35 -04:00
Eiichi Tsukata
4e1ce73596 build-sys: Minor error message typo fix for glib
Signed-off-by: Eiichi Tsukata <eiichi.tsukata@nutanix.com>
2021-09-29 11:53:31 -04:00
Eiichi Tsukata
0b9c2a05da build-sys: Introduce --enable-sanitizers to configure
This enables address and undefined sanitizers.

Signed-off-by: Eiichi Tsukata <eiichi.tsukata@nutanix.com>
2021-09-29 11:53:31 -04:00
Stefan Berger
ca4ee25ce7 swtpm: Use EVP_CIPHER in SWTPM_SymmetricKeyData_Encrypt/Decrypt
Use the EVP_CIPHER implementation for the AES CBC computations. This
API has been supported already in OpenSSL 1.1.x for sure and is also
not deprecated in OpenSSL 3.0.

This now resolves issue #538.
We can build src/swtpm without having to suppress deprecated API warnings.
Since this is the last issue related to OpenSSL deprecated APIs, we don't
need to suppress any OpenSSL 3.0 deprecated API warnings anymore.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-09-21 11:52:07 -04:00
Stefan Berger
c50bc51f99 build-sys: Remove check for pip3 that was used by python swtpm_setup
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-09-20 07:25:53 -04:00
Stefan Berger
3b5d849eaf build-sys: Use -DOPENSSL_SUPPRESS_DEPRECATED (OSSL 3)
Use the (undocumented) OPENSSL_SUPPRESS_DEPRECATED to suppress the
deprecated API warnings when compiling swtpm and swtpm_setup with
OpenSSL 3.0.0 replacing the global -Wno-deprecated-declarations.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-09-18 18:57:31 -04:00