]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Only enable sha256 PCR bank for swtpm
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 2 Mar 2024 10:38:45 +0000 (11:38 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 3 Mar 2024 14:22:55 +0000 (15:22 +0100)
Mimicks the same change in systemd-vmspawn
(https://github.com/systemd/systemd/commit/519bad6c2c23d3c2dc9558878becb485f3ae9057)

mkosi/qemu.py
mkosi/resources/mkosi-tools/mkosi.conf.d/10-centos-fedora/mkosi.conf
mkosi/resources/mkosi-tools/mkosi.conf.d/10-debian-ubuntu.conf

index be22721d4f54c34abfadfb8cef305acbd8d9a7a0..4339c554f5ab8267927352ab92b81d6497ab6443 100644 (file)
@@ -34,7 +34,7 @@ from mkosi.config import (
     systemd_tool_version,
     want_selinux_relabel,
 )
-from mkosi.log import die
+from mkosi.log import ARG_DEBUG, die
 from mkosi.partition import finalize_root, find_partitions
 from mkosi.run import AsyncioThread, find_binary, fork_and_wait, run, spawn
 from mkosi.tree import copy_tree, rmtree
@@ -286,6 +286,11 @@ def find_ovmf_vars(config: Config) -> Path:
 @contextlib.contextmanager
 def start_swtpm(config: Config) -> Iterator[Path]:
     with tempfile.TemporaryDirectory(prefix="mkosi-swtpm") as state:
+        # swtpm_setup is noisy and doesn't have a --quiet option so we pipe it's stdout to /dev/null.
+        run(["swtpm_setup", "--tpm-state", state, "--tpm2", "--pcr-banks", "sha256", "--config", "/dev/null"],
+            sandbox=config.sandbox(options=["--bind", state, state]),
+            stdout=None if ARG_DEBUG.get() else subprocess.DEVNULL)
+
         cmdline = ["swtpm", "socket", "--tpm2", "--tpmstate", f"dir={state}"]
 
         # We create the socket ourselves and pass the fd to swtpm to avoid race conditions where we start qemu before
index dd78d62c2dac0c3e0615a795fc7814d44b4fa2f4..c7502c201f56f57766fcca746f30cf4880e47e80 100644 (file)
@@ -23,6 +23,7 @@ Packages=
         qemu-kvm-core
         shadow-utils
         squashfs-tools
+        swtpm-tools
         systemd-container
         systemd-udev
         ubu-keyring
index eb5e98ee7635feb43f4291f2c20c1ad0725dda26..1f1b7f23f63dbdad9e4d01669c29de39a681abf7 100644 (file)
@@ -29,6 +29,7 @@ Packages=
         qemu-system
         sbsigntool
         squashfs-tools
+        swtpm-tools
         systemd-boot
         systemd-container
         systemd-coredump