Skip to content

Commit

Permalink
Merge pull request #3157 from DaanDeMeyer/engine
Browse files Browse the repository at this point in the history
Improvements for signing with engines
  • Loading branch information
behrmann authored Oct 31, 2024
2 parents 8319338 + 05015b5 commit fe66c0e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
21 changes: 18 additions & 3 deletions mkosi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ def run_ukify(
] # fmt: skip
if context.config.secure_boot_key_source.type == KeySourceType.engine:
cmd += ["--signing-engine", context.config.secure_boot_key_source.source]
opt += ["--bind-try", "/run/pcscd", "/run/pcscd"]
opt += ["--bind", "/run", "/run"]
if context.config.secure_boot_key.exists():
cmd += ["--secureboot-private-key", workdir(context.config.secure_boot_key)]
opt += ["--ro-bind", context.config.secure_boot_key, workdir(context.config.secure_boot_key)]
Expand All @@ -1551,6 +1551,11 @@ def run_ukify(

run(
cmd,
stdin=(
sys.stdin
if context.config.secure_boot_key_source.type != KeySourceType.file
else subprocess.DEVNULL
),
sandbox=context.sandbox(
binary=ukify,
options=[*opt, *options],
Expand Down Expand Up @@ -1609,7 +1614,7 @@ def build_uki(
] # fmt: skip
options += [
"--ro-bind", context.config.sign_expected_pcr_certificate, workdir(context.config.sign_expected_pcr_certificate), # noqa: E501
"--bind-try", "/run/pcscd", "/run/pcscd",
"--bind", "/run", "/run",
] # fmt: skip

if context.config.sign_expected_pcr_key.exists():
Expand Down Expand Up @@ -3074,7 +3079,7 @@ def make_image(

if context.config.verity_key_source.type != KeySourceType.file:
cmdline += ["--private-key-source", str(context.config.verity_key_source)]
opts += ["--bind-try", "/run/pcscd", "/run/pcscd"]
opts += ["--bind", "/run", "/run"]
if context.config.verity_key.exists():
cmdline += ["--private-key", workdir(context.config.verity_key)]
opts += ["--ro-bind", context.config.verity_key, workdir(context.config.verity_key)]
Expand Down Expand Up @@ -3105,6 +3110,11 @@ def make_image(
output = json.loads(
run(
cmdline,
stdin=(
sys.stdin
if context.config.verity_key_source.type != KeySourceType.file
else subprocess.DEVNULL
),
stdout=subprocess.PIPE,
env=context.config.environment,
sandbox=context.sandbox(
Expand Down Expand Up @@ -3428,6 +3438,11 @@ def make_extension_image(context: Context, output: Path) -> None:
j = json.loads(
run(
cmdline,
stdin=(
sys.stdin
if context.config.verity_key_source.type != KeySourceType.file
else subprocess.DEVNULL
),
stdout=subprocess.PIPE,
env=context.config.environment,
sandbox=context.sandbox(
Expand Down
19 changes: 17 additions & 2 deletions mkosi/bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def sign_efi_binary(context: Context, input: Path, output: Path) -> Path:
] # fmt: skip
if context.config.secure_boot_key_source.type == KeySourceType.engine:
cmd += ["--engine", context.config.secure_boot_key_source.source]
options += ["--bind-try", "/run/pcscd", "/run/pcscd"]
options += ["--bind", "/run", "/run"]
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)]
Expand All @@ -527,6 +527,11 @@ def sign_efi_binary(context: Context, input: Path, output: Path) -> Path:
cmd += [workdir(input)]
run(
cmd,
stdin=(
sys.stdin
if context.config.secure_boot_key_source.type != KeySourceType.file
else subprocess.DEVNULL
),
sandbox=context.sandbox(
binary="sbsign",
options=options,
Expand All @@ -549,6 +554,11 @@ def sign_efi_binary(context: Context, input: Path, output: Path) -> Path:
"--in", workdir(input),
"--out", workdir(output),
],
stdin=(
sys.stdin
if context.config.secure_boot_key_source.type != KeySourceType.file
else subprocess.DEVNULL
),
sandbox=context.sandbox(
binary="pesign",
options=[
Expand Down Expand Up @@ -753,7 +763,7 @@ def install_systemd_boot(context: Context) -> None:
] # fmt: skip
if context.config.secure_boot_key_source.type == KeySourceType.engine:
cmd += ["--engine", context.config.secure_boot_key_source.source]
options += ["--bind-try", "/run/pcscd", "/run/pcscd"]
options += ["--bind", "/run", "/run"]
if context.config.secure_boot_key.exists():
cmd += ["--key", workdir(context.config.secure_boot_key)]
options += [
Expand All @@ -764,6 +774,11 @@ def install_systemd_boot(context: Context) -> None:
cmd += [db, workdir(context.workspace / "mkosi.esl")]
run(
cmd,
stdin=(
sys.stdin
if context.config.secure_boot_key_source.type != KeySourceType.file
else subprocess.DEVNULL
),
sandbox=context.sandbox(
binary="sbvarsign",
options=options,
Expand Down

0 comments on commit fe66c0e

Please sign in to comment.