]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
measure: print a helpful message if TPM2 PCR sysfs attributes are missing
authorLennart Poettering <lennart@poettering.net>
Thu, 8 Sep 2022 10:57:23 +0000 (12:57 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 8 Sep 2022 17:46:54 +0000 (19:46 +0200)
Prompted by:

https://github.com/systemd/systemd/pull/24351#pullrequestreview-1100418585

src/boot/measure.c

index 33117fe939684f7556a07a41a9696615b5852aa5..824a270ff25d949f74e98f15b31f544839ce198d 100644 (file)
@@ -279,6 +279,8 @@ static int measure_pcr(PcrState *pcr_states, size_t n) {
                                 return log_oom();
 
                         r = read_virtual_file(p, 4096, &s, NULL);
+                        if (r == -ENOENT && access("/sys/class/tpm/tpm0/", F_OK) >= 0)
+                                return log_error_errno(r, "TPM device exists, but cannot open '%s'; either the kernel is too old, or selected PCR bank is not supported: %m", p);
                         if (r < 0)
                                 return log_error_errno(r, "Failed to read '%s': %m", p);