]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: Add roothash to output of all verity siblings
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 25 Jan 2023 14:56:30 +0000 (15:56 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 25 Jan 2023 19:50:44 +0000 (19:50 +0000)
This can be used to match verity partitions together using the repart
JSON output.

src/partition/repart.c
test/units/testsuite-58.sh

index c95b1d601df300bf049b5866e02f9d107fcd48e1..920b442316a014227c8813bd685f3815b13e4f4b 100644 (file)
@@ -2471,8 +2471,10 @@ static int context_dump_partitions(Context *context) {
                 if (p->new_padding != UINT64_MAX)
                         sum_padding += p->new_padding;
 
-                if (p->verity == VERITY_HASH) {
-                        rh = p->roothash ? hexmem(p->roothash, p->roothash_size) : strdup("TBD");
+                if (p->verity != VERITY_OFF) {
+                        Partition *hp = p->verity == VERITY_HASH ? p : p->siblings[VERITY_HASH];
+
+                        rh = hp->roothash ? hexmem(hp->roothash, hp->roothash_size) : strdup("TBD");
                         if (!rh)
                                 return log_oom();
                 }
index e83df97067ac650a01e4be0f0a8ede341309e487..8b52a435e6dab0c518a7844322aa76e63610ec2c 100755 (executable)
@@ -819,7 +819,12 @@ EOF
                                            --certificate="$defs/verity.crt" \
                                            "$imgs/verity")
 
-    roothash=$(jq -r ".[] | select(.type == \"root-${architecture}-verity\") | .roothash" <<< "$output")
+    drh=$(jq -r ".[] | select(.type == \"root-${architecture}\") | .roothash" <<< "$output")
+    hrh=$(jq -r ".[] | select(.type == \"root-${architecture}-verity\") | .roothash" <<< "$output")
+    srh=$(jq -r ".[] | select(.type == \"root-${architecture}-verity-sig\") | .roothash" <<< "$output")
+
+    assert_eq "$drh" "$hrh"
+    assert_eq "$hrh" "$srh"
 
     # Check that we can dissect, mount and unmount a repart verity image. (and that the image UUID is deterministic)
 
@@ -828,9 +833,9 @@ EOF
         return
     fi
 
-    systemd-dissect "$imgs/verity" --root-hash "$roothash"
-    systemd-dissect "$imgs/verity" --root-hash "$roothash" --json=short | grep -q '"imageUuid":"1d2ce291-7cce-4f7d-bc83-fdb49ad74ebd"'
-    systemd-dissect "$imgs/verity" --root-hash "$roothash" -M "$imgs/mnt"
+    systemd-dissect "$imgs/verity" --root-hash "$drh"
+    systemd-dissect "$imgs/verity" --root-hash "$drh" --json=short | grep -q '"imageUuid":"1d2ce291-7cce-4f7d-bc83-fdb49ad74ebd"'
+    systemd-dissect "$imgs/verity" --root-hash "$drh" -M "$imgs/mnt"
     systemd-dissect -U "$imgs/mnt"
 }