]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add SecureBootAutoEnroll= option
authorCornelius Hoffmann <coding@hoffmn.de>
Wed, 13 Dec 2023 00:22:17 +0000 (01:22 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 13 Dec 2023 06:22:15 +0000 (07:22 +0100)
Closes https://github.com/systemd/mkosi/issues/2169

NEWS.md
mkosi/__init__.py
mkosi/config.py
mkosi/resources/mkosi.md
tests/test_json.py

diff --git a/NEWS.md b/NEWS.md
index d9f487eee79b43bd7bbb38f2d198b2b237423454..f287e1f1b1662fcf8fc8ae61e3290f538d8eeceb 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -48,6 +48,8 @@
 - A passwordless root account may now be created by specifying `hashed:`
 - On `arm64` we now add an autologin dropin for `ttyAMA0` if autologin
   is enabled.
+- Added `SecureBootAutoEnroll=` to control automatic enrollment of secureboot
+  keys separately from signing `systemd-boot` and generated UKIs.
 
 ## v19
 
index 46cfc6ce77ac5dad3c7c5efbe48c3f50f33687e6..5f7f4d567314e379f9aeb6dd56d996df3ac62497 100644 (file)
@@ -807,7 +807,7 @@ def install_systemd_boot(state: MkosiState) -> None:
                 state.root / shim_second_stage_binary(state),
             )
 
-    if state.config.secure_boot:
+    if state.config.secure_boot and state.config.secure_boot_auto_enroll:
         assert state.config.secure_boot_key
         assert state.config.secure_boot_certificate
 
index cbbb07b3efd910d88093ff8da19dae6b9fc729b8..79323ba6ee1a611a991854a556d7d7c594176858 100644 (file)
@@ -969,6 +969,7 @@ class MkosiConfig:
     ssh: bool
 
     secure_boot: bool
+    secure_boot_auto_enroll: bool
     secure_boot_key: Optional[Path]
     secure_boot_certificate: Optional[Path]
     secure_boot_sign_tool: SecureBootSignTool
@@ -1874,6 +1875,14 @@ SETTINGS = (
         parse=config_parse_boolean,
         help="Sign the resulting kernel/initrd image for UEFI SecureBoot",
     ),
+    MkosiConfigSetting(
+        dest="secure_boot_auto_enroll",
+        metavar="BOOL",
+        section="Validation",
+        parse=config_parse_boolean,
+        default=True,
+        help="Automatically enroll the secureboot signing key on first boot",
+    ),
     MkosiConfigSetting(
         dest="secure_boot_key",
         metavar="PATH",
@@ -3089,6 +3098,7 @@ def summary(config: MkosiConfig) -> str:
 
     {bold("VALIDATION")}:
                UEFI SecureBoot: {yes_no(config.secure_boot)}
+    UEFI SecureBoot AutoEnroll: {yes_no(config.secure_boot_auto_enroll)}
         SecureBoot Signing Key: {none_to_none(config.secure_boot_key)}
         SecureBoot Certificate: {none_to_none(config.secure_boot_certificate)}
           SecureBoot Sign Tool: {config.secure_boot_sign_tool}
index e0018f4891fbb98b073d855241b490164b995310..b9dcdab752632ea6e6385937b6b0ff6b929c7bbf 100644 (file)
@@ -1171,17 +1171,21 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`,
 `SecureBoot=`, `--secure-boot`
 
 : Sign systemd-boot (if it is not signed yet) and any generated
-  unified kernel images for UEFI SecureBoot. Also set up automatic
-  enrollment of the secure boot keys in virtual machines as documented
-  in the systemd-boot
-  [man page](https://www.freedesktop.org/software/systemd/man/systemd-boot.html).
+  unified kernel images for UEFI SecureBoot.
+
+`SecureBootAutoEnroll=`, `--secure-boot-auto-enroll=`
+
+: Set up automatic enrollment of the secure boot keys in virtual machines as
+  documented in the systemd-boot
+  [man page](https://www.freedesktop.org/software/systemd/man/systemd-boot.html)
+  if `SecureBoot=` is used.
   Note that systemd-boot will only do automatic secure boot key
   enrollment in virtual machines starting from systemd v253. To do auto
   enrollment on systemd v252 or on bare metal machines, write a
   systemd-boot configuration file to `/efi/loader/loader.conf` using an
   extra tree with `secure-boot-enroll force` or
   `secure-boot-enroll manual` in it. Auto enrollment is not supported on
-  systemd versions older than v252.
+  systemd versions older than v252. Defaults to `yes`.
 
 `SecureBootKey=`, `--secure-boot-key=`
 
index 8e30eb1a1b2582941198b8d72ec219a81b36fe14..660d0a97dacfd54aa205e1cec9b0fdd6ac39e78d 100644 (file)
@@ -247,6 +247,7 @@ def test_config() -> None:
             ],
             "SectorSize": null,
             "SecureBoot": true,
+            "SecureBootAutoEnroll": true,
             "SecureBootCertificate": null,
             "SecureBootKey": "/path/to/keyfile",
             "SecureBootSignTool": "pesign",
@@ -376,6 +377,7 @@ def test_config() -> None:
         runtime_trees = [ConfigTree(Path("/foo/bar"), Path("/baz")), ConfigTree(Path("/bar/baz"), Path("/qux"))],
         sector_size = None,
         secure_boot = True,
+        secure_boot_auto_enroll = True,
         secure_boot_certificate = None,
         secure_boot_key = Path("/path/to/keyfile"),
         secure_boot_sign_tool = SecureBootSignTool.pesign,