Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements for signing with engines #3157

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading