Skip to content

Commit

Permalink
Make sure we only use workdir() for keys if they're a path on disk
Browse files Browse the repository at this point in the history
Fixes #3033
  • Loading branch information
DaanDeMeyer authored and bluca committed Sep 17, 2024
1 parent ce171dc commit d372eff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions mkosi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2692,12 +2692,13 @@ def make_image(
cmdline += ["--key-file", workdir(context.config.passphrase)]
options += ["--ro-bind", context.config.passphrase, workdir(context.config.passphrase)]
if context.config.verity_key:
key = workdir(context.config.verity_key) if context.config.verity_key.exists() else context.config.verity_key
cmdline += ["--private-key", str(key)]
if context.config.verity_key_source.type != KeySourceType.file:
cmdline += ["--private-key-source", str(context.config.verity_key_source)]
if context.config.verity_key.exists():
cmdline += ["--private-key", workdir(context.config.verity_key)]
options += ["--ro-bind", context.config.verity_key, workdir(context.config.verity_key)]
else:
cmdline += ["--private-key", context.config.verity_key]
if context.config.verity_certificate:
cmdline += ["--certificate", workdir(context.config.verity_certificate)]
options += ["--ro-bind", context.config.verity_certificate, workdir(context.config.verity_certificate)]
Expand Down
8 changes: 6 additions & 2 deletions mkosi/bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ def sign_efi_binary(context: Context, input: Path, output: Path) -> Path:
):
cmd: list[PathString] = [
"sbsign",
"--key", workdir(context.config.secure_boot_key),
"--cert", workdir(context.config.secure_boot_certificate),
"--output", workdir(output),
]
Expand All @@ -518,7 +517,10 @@ def sign_efi_binary(context: Context, input: Path, output: Path) -> Path:
if context.config.secure_boot_key_source.type == KeySourceType.engine:
cmd += ["--engine", context.config.secure_boot_key_source.source]
if context.config.secure_boot_key.exists():
cmd += ["--key", workdir(context.config.secure_boot_key)]
options += ["--ro-bind", context.config.secure_boot_key, workdir(context.config.secure_boot_key)]
else:
cmd += ["--key", workdir(context.config.secure_boot_key)]
cmd += [workdir(input)]
run(
cmd,
Expand Down Expand Up @@ -732,7 +734,6 @@ def install_systemd_boot(context: Context) -> None:
"sbvarsign",
"--attr",
"NON_VOLATILE,BOOTSERVICE_ACCESS,RUNTIME_ACCESS,TIME_BASED_AUTHENTICATED_WRITE_ACCESS",
"--key", workdir(context.config.secure_boot_key),
"--cert", workdir(context.config.secure_boot_certificate),
"--output", workdir(keys / f"{db}.auth"),
]
Expand All @@ -746,9 +747,12 @@ def install_systemd_boot(context: Context) -> None:
if context.config.secure_boot_key_source.type == KeySourceType.engine:
cmd += ["--engine", context.config.secure_boot_key_source.source]
if context.config.secure_boot_key.exists():
cmd += ["--key", workdir(context.config.secure_boot_key),]
options += [
"--ro-bind", context.config.secure_boot_key, workdir(context.config.secure_boot_key),
]
else:
cmd += ["--key", context.config.secure_boot_key]
cmd += [db, workdir(context.workspace / "mkosi.esl")]
run(
cmd,
Expand Down

0 comments on commit d372eff

Please sign in to comment.