]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
analyze: fix pcrs verb output without TPM support
authorFrantisek Sumsal <frantisek@sumsal.cz>
Sat, 29 Jul 2023 19:04:44 +0000 (21:04 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 29 Jul 2023 23:57:37 +0000 (08:57 +0900)
If we don't have TPM support then `alg` is NULL and passing this to
table_new() means we'd get a table with only two columns instead of
three, leading up to a very confusing output:

$ build/systemd-analyze pcrs
System lacks full TPM2 support, not showing PCR state.
                 NR NAME
                  0 platform-code
                  - 1
    platform-config -
                  2 external-code
                  - 3
    external-config -
                  4 boot-loader-code
                  - 5
 boot-loader-config -
                  6 -
                  - 7
...

Let's name the header in this case with a simple dash, as it's going
to be hidden anyway, to make the table nice again:

$ build/systemd-analyze pcrs
System lacks full TPM2 support, not showing PCR state.
NR NAME
 0 platform-code
 1 platform-config
 2 external-code
 3 external-config
 4 boot-loader-code
 5 boot-loader-config
 6 -
 7 secure-boot-policy
...

src/analyze/analyze-pcrs.c

index 82f0f3928807c97b97d9916721ed63033df8c1ce..c081ffef017ea72b27757184829e4459ca1775df 100644 (file)
@@ -104,7 +104,7 @@ int verb_pcrs(int argc, char *argv[], void *userdata) {
                         return r;
         }
 
-        table = table_new("nr", "name", alg);
+        table = table_new("nr", "name", alg ?: "-");
         if (!table)
                 return log_oom();