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)
commit9fe4e68cabaf79681388d025d86bd14f5ae944a6
tree4868a95ea4d369b437ab62e7263de12c2696db8d
parentcbcf76b19371876292cb9176814da4f832dfec32
analyze: fix pcrs verb output without TPM support

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