]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pcrextend: fix varlink API to match what we actually take
authorLennart Poettering <lennart@amutable.com>
Thu, 5 Feb 2026 15:01:08 +0000 (16:01 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 6 Feb 2026 06:08:51 +0000 (15:08 +0900)
(Change test case slightly, to ensure we don't regress on this)

src/shared/varlink-io.systemd.PCRExtend.c
test/units/TEST-70-TPM2.nvpcr.sh

index 84ee2e731ba324337687cffff4e466c07f82a2e1..87783f1ee9f2e7a2601970995aacce26241e3f0d 100644 (file)
@@ -4,9 +4,10 @@
 
 static SD_VARLINK_DEFINE_METHOD(
                 Extend,
-                SD_VARLINK_FIELD_COMMENT("PCR number to extend, in range of 0…23"),
-                SD_VARLINK_DEFINE_INPUT(pcr, SD_VARLINK_INT, 0),
-                SD_VARLINK_DEFINE_INPUT(nvpcr, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
+                SD_VARLINK_FIELD_COMMENT("PCR number to extend, in range of 0…23. Either this or 'nvpcr' must be specified, not both, not neither."),
+                SD_VARLINK_DEFINE_INPUT(pcr, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
+                SD_VARLINK_FIELD_COMMENT("NvPCR to extend, identified by a string. Either this or 'pcr' must be specified, not both, not neither."),
+                SD_VARLINK_DEFINE_INPUT(nvpcr, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
                 SD_VARLINK_FIELD_COMMENT("Text string to measure. (Specify either this, or the 'data' field below, not both)"),
                 SD_VARLINK_DEFINE_INPUT(text, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
                 SD_VARLINK_FIELD_COMMENT("Binary data to measure, encoded in Base64. (Specify either this, or the 'text' field above, not both)"),
index 8827acc6ed53a2d480b668e4bab82611856db2ed..1539d056a4dea169b3c100d126bea96c072a3a2f 100755 (executable)
@@ -43,8 +43,8 @@ DIGEST_EXPECTED="$(echo "$DIGEST_BASE$DIGEST_MEASURED" | xxd -r -p | openssl dgs
 DIGEST_ACTUAL="$(systemd-analyze nvpcrs test --json=pretty | jq -r '.[] | select(.name=="test") | .value')"
 test "$DIGEST_ACTUAL" = "$DIGEST_EXPECTED"
 
-# Now "destroy" the value via another measurement
-/usr/lib/systemd/systemd-pcrextend --nvpcr=test schnurz
+# Now "destroy" the value via another measurement (this time we use Varlink, to test the API)
+varlinkctl call /usr/lib/systemd/systemd-pcrextend io.systemd.PCRExtend.Extend '{"nvpcr":"test","text":"schnurz"}'
 DIGEST_ACTUAL2="$(systemd-analyze nvpcrs test --json=pretty | jq -r '.[] | select(.name=="test") | .value')"
 test "$DIGEST_ACTUAL2" != "$DIGEST_EXPECTED"