Commit Graph

1755 Commits

Author SHA1 Message Date
Stefan Berger
673ee421d2 rpm: Set BSD-3-Clause for the License on each subpackage
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-08-16 16:29:05 -04:00
Stefan Berger
b9e6d7c686 rpm: Split off SELinux files to build an selinux package
Follow the changes in Fedora to build a separate swtpm-selinux package
so that swtpm can also be installed without SELinux on the system.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-08-15 12:36:31 -04:00
Stefan Berger
63825b296c SELinux: Add rules for user_tpm_t:sockfile to allow unlink
With a memoryBacking node added to the libvirt domain XML, the unlink
permission on user_tmp_t:sockfile becomes necessary to avoid an avc
denial.

  <currentMemory unit='KiB'>2097152</currentMemory>
  <memoryBacking>
    <hugepages>
      <page size='2048' unit='KiB'/>
    </hugepages>
  </memoryBacking>

Also add the unlink permission to the other occurrences of sock_file.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2165142
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-08-15 10:30:08 -04:00
Stefan Berger
7dac1dbf6f SELinux: Add rules for sock_file on user_tmp_t
The following command line did not function on an x86_64 host due to missing
SELinux rules:

virt-install -v \
 --name fedora-38-aarch64 \
 --ram 4096 \
 --disk path=fedora-38.img,cache=none \
 --nographics \
 --os-variant fedora38 \
 --import \
 --virt-type=qemu \
 --arch aarch64 \
 --check all=off

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2228423
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-08-15 10:30:08 -04:00
Lena Voytek
f732f489c2 debian: Allow apparmor access to qemu session bus swtpm files
When running a VM connected to qemu:///session, swtpm needs access to its own
process id and socket files in /run/user/<UID>/libvirt/qemu/run/swtpm/. Add
permissions to access them in the apparmor profile.

Signed-off-by: Lena Voytek <lena.voytek@canonical.com>
2023-08-10 20:03:06 -04:00
Ross Lagerwall
51ccd2378b Make stdout unbuffered in swtpm_{setup,localca}
swtpm_setup and swtpm_localca may be run by a toolstack with log
messages going to a pipe via stdout. Set stdout to be unbuffered to
avoid log messages being lost if the process terminates unexpectedly.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
2023-08-02 10:05:07 -04:00
Stefan Berger
67152d3e18 tests: Fix spelling mistakes
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-07-17 20:46:43 -04:00
Stefan Berger
f954e3b9d2 Fix a few spelling errors in code
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-07-17 20:46:43 -04:00
Stefan Berger
004aa538dd man: Fix a few spelling mistakes
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-07-17 20:46:43 -04:00
Stefan Berger
34f1e2a1b0 swtpm_setup: Exit with '0' upon --version rather than '1'.
The --version option was using the wrong goto label error rather than
out to now also exit with exitcode 0.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-07-12 21:03:28 -04:00
Stefan Berger
2f86ffbac0 swtpm_setup: Close file descriptors passed to swtpm process on parent side
Close the file descriptors passed to the swtpm process on the parent
side for faster detection of errors in the swtpm process that can
occur if swtpm was passed a profile that it cannot run with.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-07-01 10:26:27 -04:00
Stefan Berger
bb2c7ed14e tests: Remove stray \ in front of - after already escaped '\-'
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-06-26 20:50:01 -04:00
Stefan Berger
1fa820468f tests: Fix newly detected shellcheck issues SC2086 by quoting
Shellcheck v0.9 detected more SC2086 issues.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-06-26 20:50:01 -04:00
Stefan Berger
a464c649e2 tests: Disable shellcheck SC2317
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-06-26 20:50:01 -04:00
Stefan Berger
1daa80d239 swtpm_setup: Use medium duration on TSC_PhysicalPresence to avoid timeouts
On busy systems TSC_PhysicalPresence may time out when used with short
duration, so use medium duration instead.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-06-26 18:36:35 -04:00
Stefan Berger
cfeea1b1c0 swtpm_setup: Add poll() after write() and before read() to detect errors
In case swtpm does not start properly the write() to it may work but
then the read() gets stuck. Detect a failed swtpm by adding a poll()
before the read(). Use some extended durations considering possibly
busy systems.

A terminating swtpm instance can be caused when an unacceptable
profile is passed.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-06-24 16:01:33 -04:00
Stefan Berger
48dffac182 swtpm_ioctl: Repeatedly call PTM_GET_INFO for long responses
Fix the display of long responses that require calling PTM_GET_INFO
multiple times to get parts of the response from increasing offsets
until the whole response has been received.

Long responses are only returned when libtpms has profiles support and
several flags are passed to PTM_GET_INFO.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-06-23 18:30:01 -04:00
Stefan Berger
9a154fa45f tests: ibmtss2: Add patch to disable x509 test with older libtpms
Older versions of libtpms need to have another patch applied that disables
x509 certificate creation (0013-Disable-x509-test-cases-part2.patch).

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-05-15 14:21:37 -04:00
Stefan Berger
3095011412 tests: Upgrade to ibmtss2 v2.0.1
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-05-11 09:24:54 -04:00
Stefan Berger
ee0bce1bdf utils: Implement find_program() to try BINDIR path before PATH
To support install paths that are not covered by $PATH, and still allow
swtpm_setup and swtpm_localca to find swtpm and swtpm_cert executables,
implement find_program() to prepend the install path if only the program
name is given and otherwise fall back to g_find_program_in_path().

Update the man page stating that swtpm from the installation directory
(BINDIR) is tried to be used before one is attempted to be found in
the PATH.

Resolves: https://github.com/stefanberger/swtpm/issues/795
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-04-17 10:55:16 -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
459f4e7dea Travis: Update from focal to jammy and from bionic to focal
Since the tss2 package is commonly available in focal and jammy
move it into to the general list of packages to installed.

libtpm2-pkcs11-tools is available since jammy, so installed it
there to enable the TPM 2 pkcs11 tests.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-02-27 07:10:10 -05:00
Stefan Berger
5e6e13802d Travis: Update from bionic to focal and from xenial to bionic
Since the package libasan2 does not exist in focal anymore, remove. The
bionic builds do not seem to require this package to be installed (maybe
it's already there), so there's no need to install it in a before_script.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-02-23 11:13:56 -05:00
Stefan Berger
29ceff5c33 swtpm_localca: Add missing NULL option to end of array
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-02-22 17:27:05 -05:00
Stefan Berger
1cd2dc6049 samples: swtpm-create-tpmca: Fix shellcheck issues and add to syntax-check target
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-02-22 17:27:05 -05:00
Stefan Berger
036fd75b1f samples: swtpm-create-tpmca: Check for missing tpmtool
Recent GnuTLS does not package tpmtool anymore. Check for
the missing tpmtool and report an error as appropriate.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-02-22 17:27:05 -05:00
Stefan Berger
dbcb69d0ee man8: Update swtpm-create-tpmca with missing TPM 2 reference
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-02-22 17:27:05 -05:00
Stefan Berger
346b3d6265 tests: Fix shellcheck issue SC2148 by adding missing shell directive
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-01-31 10:37:31 -05:00
Stefan Berger
c2b54e6ab5 tests: Fix shellcheck issue SC2148 by adding a shell directive
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-01-30 18:25:45 -05:00
Stefan Berger
b40fc82700 tests: Fix 2 cases of shellcheck SC2001 using bash search-replace
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-01-30 18:25:45 -05:00
Stefan Berger
c8699ccd1b tests: Disable shellcheck SC2010 in two cases
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-01-30 18:25:45 -05:00
Stefan Berger
e5ccc7bb37 tests: Fix shellcheck issue SC2115 by using "${var:?}"
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-01-29 15:04:00 -05:00
Stefan Berger
5704342aa8 tests: Fix shellcheck issue SC2181 by if cmd; ...
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-01-27 11:58:54 -05:00
Stefan Berger
4cad2bb32e tests: Fix shellcheck issue SC2143 by using grep -q
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-01-26 08:12:59 -05:00
Stefan Berger
20655646c6 tests: Fix shellcheck issue SC2126 by using 'grep -c'
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-01-14 13:31:53 -05:00
Stefan Berger
5b51dc6a58 tests: Fix issues related to SC2164
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-01-13 21:02:51 -05:00
Stefan Berger
fd7a812b24 tests: Fix code to pass shellcheck with some errors disabled
Fix the test cases to pass shellcheck with some of the errors
disable.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-01-13 13:59:02 -05:00
Michal Privoznik
72d9c031a0 swtpm_setup: Initialized @argv in get_swtpm_capabilities()
The compiler (though wrongly) identifies that the @argv variable
inside of get_swtpm_capabilities() function cam be used
uninitialized. While this is a spurious warning, it's common
practice to initialize g_autofree variables to NULL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2022-12-21 13:54:38 -05:00
Michal Privoznik
a78d02ceec man: Install swtpm_cuse.8 iff WITH_CUSE
Users have option to disable CUSE interface (just pass
--without-cuse argument to the configure script). But the
swtpm_cuse.8 man page is installed regardless of the argument.
This leaves distros having to remove the file before packing
builddir into packages.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2022-12-21 13:54:38 -05:00
Michal Privoznik
c6b78f49f5 swtpm: Restore logging to stderr on log open failure
When opening a log file fails (--log file=/some/path) for
whatever reason the @logfd variable is left set to -1 (the retval
of open()). And due to how _logprintf() is written, the
subsequent attempt to log this failure (logprintf()) returns too
early not printing the useful error.

Therefore, restore the original (CONSOLE_LOGGING) value.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2022-12-02 11:08:46 -05:00
Michal Privoznik
dcd1b575e6 swtpm.spec: Reflect minimal gnutls version
The configure script requires at least gnutls-3.4.0 but this is
not reflected in the spec file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2022-11-11 11:58:29 -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
Stefan Berger
2ae7b01937 debian/rpm: Adjust changelog for 0.8.0 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-11-10 12:24:08 -05:00
Stefan Berger
441d8839d2 CHANGES: Add more documentation for changes in 0.8.0
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-11-10 12:24:08 -05:00
Stefan Berger
22e975dc05 tests: Pass --verify-profile=medium to certtool if supported
certtool emits the following message if --verify-profile is not
passed:

Note that no verification profile was selected. In the future the medium profile will be enabled by default.
Use --verify-profile low to apply the default verification of NORMAL priority string.

Pass the --verify-profile option if certtool supports it (since ~3.6.12).

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-11-02 11:14:19 -04:00
Ross Lagerwall
a2abd3b67d swtpm_setup: Configure swtpm to log to stdout/err if needed
If swtpm_setup is configured with a log file, it launches swtpm
configured with the same log file. If not, swtpm_setup logs will go to
stdout/stderr and it should configure swtpm to do the same.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
2022-11-01 18:01:47 -04:00
Stefan Berger
66117eefa8
Update bug_report.md
Make exact steps to recreate the issue a requirement for the bug report.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-10-10 07:53:26 -04:00
Stefan Berger
87ce53ffc4 swtpm: Add another exit label to avoid gcc -fanalyzer false positive
Move existing exit label before the return statement and add another
label that includes the free(filebuffer). This avoids a false positive
by 'gcc -fanalyzer' that seems to think that free(filebuffer)
would double-free filebuffer after filebuffer = realloc(tmp, ..)
failure.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-10-05 07:37:14 -04:00
Stefan Berger
7d79ecd694 swtpm: Return TPM_FAIL if SWTPM_NVRAM_DecrytpData is called without key
Return TPM_FAIL if SWTPM_NVRAM_DecryptData() is called without a key or
if an unhandle type of encryption mode is encountered. Previously this
function would return no error but also would not do any decryption if
no key was provided. Consequently, it would then also not return a byte
array with decrypted data which in turn could led to potential NULL
pointer accesses in subsequent calls. However, all current callers check
whether they have a valid key before they call this function. So the
change is primarily done for static analyzers, such as gcc -fanalyzer,
to ease code analysis.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-09-30 13:12:06 -04:00