summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2024-05-02 18:41:36 +0200
committerLennart Poettering <lennart@poettering.net>2024-05-06 16:15:14 +0200
commite6ca81d43422e6ea7b1a99c15d21b71f1628f32f (patch)
treec32ecd5ce646c9c0b3ae2dd69785d5f3bf0d48eb /src
parentcryptenroll: do not combine pcrlock and signed PCR policies in TPM mode (diff)
downloadsystemd-e6ca81d43422e6ea7b1a99c15d21b71f1628f32f.tar.xz
systemd-e6ca81d43422e6ea7b1a99c15d21b71f1628f32f.zip
cryptenroll: determine TPM enrollment parmaeters only if we actually do TPM enrollments
Otherwise we'll do work (and possibly generate fatal errors) where we really shouldn't.
Diffstat (limited to 'src')
-rw-r--r--src/cryptenroll/cryptenroll.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/src/cryptenroll/cryptenroll.c b/src/cryptenroll/cryptenroll.c
index 6e700d3014..04352bfec6 100644
--- a/src/cryptenroll/cryptenroll.c
+++ b/src/cryptenroll/cryptenroll.c
@@ -637,31 +637,33 @@ static int parse_argv(int argc, char *argv[]) {
}
}
- if (auto_pcrlock) {
- assert(!arg_tpm2_pcrlock);
-
- r = tpm2_pcrlock_search_file(NULL, NULL, &arg_tpm2_pcrlock);
- if (r < 0) {
- if (r != -ENOENT)
- log_warning_errno(r, "Search for pcrlock.json failed, assuming it does not exist: %m");
- } else
- log_info("Automatically using pcrlock policy '%s'.", arg_tpm2_pcrlock);
- }
+ if (arg_enroll_type == ENROLL_TPM2) {
+ if (auto_pcrlock) {
+ assert(!arg_tpm2_pcrlock);
+
+ r = tpm2_pcrlock_search_file(NULL, NULL, &arg_tpm2_pcrlock);
+ if (r < 0) {
+ if (r != -ENOENT)
+ log_warning_errno(r, "Search for pcrlock.json failed, assuming it does not exist: %m");
+ } else
+ log_info("Automatically using pcrlock policy '%s'.", arg_tpm2_pcrlock);
+ }
- if (auto_public_key_pcr_mask) {
- assert(arg_tpm2_public_key_pcr_mask == 0);
- arg_tpm2_public_key_pcr_mask = INDEX_TO_MASK(uint32_t, TPM2_PCR_KERNEL_BOOT);
- }
+ if (auto_public_key_pcr_mask) {
+ assert(arg_tpm2_public_key_pcr_mask == 0);
+ arg_tpm2_public_key_pcr_mask = INDEX_TO_MASK(uint32_t, TPM2_PCR_KERNEL_BOOT);
+ }
- if (auto_hash_pcr_values && !arg_tpm2_pcrlock) { /* Only lock to PCR 7 by default if no pcrlock policy is around (which is a better replacement) */
- assert(arg_tpm2_n_hash_pcr_values == 0);
+ if (auto_hash_pcr_values && !arg_tpm2_pcrlock) { /* Only lock to PCR 7 by default if no pcrlock policy is around (which is a better replacement) */
+ assert(arg_tpm2_n_hash_pcr_values == 0);
- if (!GREEDY_REALLOC_APPEND(
- arg_tpm2_hash_pcr_values,
- arg_tpm2_n_hash_pcr_values,
- &TPM2_PCR_VALUE_MAKE(TPM2_PCR_INDEX_DEFAULT, /* hash= */ 0, /* value= */ {}),
- 1))
- return log_oom();
+ if (!GREEDY_REALLOC_APPEND(
+ arg_tpm2_hash_pcr_values,
+ arg_tpm2_n_hash_pcr_values,
+ &TPM2_PCR_VALUE_MAKE(TPM2_PCR_INDEX_DEFAULT, /* hash= */ 0, /* value= */ {}),
+ 1))
+ return log_oom();
+ }
}
return 1;