diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-01-24 22:45:25 +0100 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2023-01-24 23:07:21 +0000 |
commit | 2f6c52b919dcc4a52e597ada11af9267e3550029 (patch) | |
tree | 0fdfdbfa485ab2319704d96bf3d1fe6dce8cbd3b /src/gpt-auto-generator | |
parent | 1d62f3a7a112c30399698dc76221f5e0e5b27ab5 (diff) | |
download | systemd-2f6c52b919dcc4a52e597ada11af9267e3550029.tar.gz |
shared/efi-loader: fix compilation with !ENABLE_EFI, improve messages
When compiled without ENABLE_EFI, efi_stub_measured() was not defined, so
compilation would fail. But it's not enough to add a stub that returns
-EOPNOTSUPP. We call this function in various places and usually print the error
at warning or error level, so we'd print a confusing message. We also can't add
a stub that always returns 0, because then we'd print a message like "Kernel
stub did not measure", which would be confusing too. Adding special handling for
-EOPNOTSUPP in every caller is also unattractive. So instead efi_stub_measured()
is reworked to log the warning or error internally, and such logging is removed
from the callers, and a stub is added that logs a custom message.
Diffstat (limited to 'src/gpt-auto-generator')
-rw-r--r-- | src/gpt-auto-generator/gpt-auto-generator.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index dcf95a3ee1..21b9284f8a 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -102,13 +102,13 @@ static int add_cryptsetup( * assignment, under the assumption that people who are fine to use sd-stub with its PCR * assignments are also OK with our PCR 15 use here. */ - r = efi_stub_measured(); - if (r < 0) - log_warning_errno(r, "Failed to determine whether booted via systemd-stub with measurements enabled, ignoring: %m"); - else if (r == 0) + r = efi_stub_measured(LOG_WARNING); + if (r == 0) log_debug("Will not measure volume key of volume '%s', because not booted via systemd-stub with measurements enabled.", id); - else if (!strextend_with_separator(&options, ",", "tpm2-measure-pcr=yes")) - return log_oom(); + else if (r > 0) { + if (!strextend_with_separator(&options, ",", "tpm2-measure-pcr=yes")) + return log_oom(); + } } r = generator_write_cryptsetup_service_section(f, id, what, NULL, options); |