Skip to content

Commit fca625f

Browse files
croissanneallisonkarlitskaya
authored andcommitted
examples: test with fs-verity disabled
In run-repart there are three cases that need to be supported: - run systemd-repart with `fsverity=copy`; - run systemd-repart without fs-verity support (FS_VERITY_MODE=none); - run systemd-repart without fs-verity support, but fix it after (FS_VERITY_MODE=fix). Test with fs-verity disabled on both ext4 (no fs-verity on the root image, but supported by the sysroot filesystem) and xfs (no fs-verity supported). Signed-off-by: Sanne Raymaekers <[email protected]>
1 parent 0cacbc9 commit fca625f

File tree

7 files changed

+42
-24
lines changed

7 files changed

+42
-24
lines changed

.github/workflows/examples.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
- { dir: 'uki', os: 'fedora' }
2727
- { dir: 'unified', os: 'fedora' }
2828
- { dir: 'unified-secureboot', os: 'fedora' }
29+
- { dir: 'bls', os: 'arch', fsfmt: 'ext4', verity: 'none' }
30+
- { dir: 'bls', os: 'arch', fsfmt: 'xfs', verity: 'none' }
2931
fail-fast: false
3032

3133
steps:
@@ -71,4 +73,6 @@ jobs:
7173
- name: Run example tests
7274
run: |
7375
export PATH="${HOME}/bin:${PATH}"
76+
export FS_FORMAT=${{ matrix.example.fsfmt }}
77+
export FS_VERITY_MODE=${{ matrix.example.verity }}
7478
examples/test/run ${{ matrix.example.dir }} ${{ matrix.example.os }}

examples/bls/build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ podman build \
5656
BASE_ID="$(sed s/sha256:// tmp/base.iid)"
5757

5858
${CFSCTL} oci pull containers-storage:${BASE_ID}
59+
60+
if [ "${FS_VERITY_MODE:-repart}" = "none" ]; then
61+
CFSCTL="$CFSCTL --insecure"
62+
fi
63+
5964
${CFSCTL} oci prepare-boot "${BASE_ID}" --bootdir tmp/efi --cmdline console=ttyS0,115200 --entry-id=example --cmdline rw
6065

6166
../common/install-systemd-boot

examples/common/check-config

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ fi
4040
#
4141
# All the tests past this point can be skipped if we're doing after-the-fact
4242
# verity fixups using the fix-verity script.
43-
if [ "${FIX_VERITY:-}" = "1" ]; then
43+
if [ "${FS_VERITY_MODE:-repart}" = "fix" ] || [ "${FS_VERITY_MODE:-repart}" = "none" ]; then
4444
exit 0
4545
fi
4646

4747
if ! grep -sq 'fsverity=' "${systemd_repart}"; then
4848
echo "*** Your systemd-repart doesn't seem to have fs-verity support"
49-
echo "*** See the install-patched-tools script, or set FIX_VERITY=1..."
49+
echo "*** See the install-patched-tools script, or set FS_VERITY_MODE=fix..."
5050
exit 1
5151
fi
5252

5353
if ! grep -sq 'fs-verity support' "${mkfs_ext4}"; then
5454
echo "*** Your mkfs.ext4 doesn't seem to have fs-verity support"
55-
echo "*** See the install-patched-tools script, or set FIX_VERITY=1..."
55+
echo "*** See the install-patched-tools script, or set FS_VERITY_MODE=fix..."
5656
exit 1
5757
fi
5858

@@ -62,6 +62,6 @@ check_metadata() {
6262

6363
if check_metadata "$0"; then
6464
echo "*** Your working directory doesn't seem to support FS_IOC_READ_VERITY_METADATA"
65-
echo "*** You're probably using btrfs on an older kernel version. Try FIX_VERITY=1..."
65+
echo "*** You're probably using btrfs on an older kernel version. Try FS_VERITY_MODE=fix..."
6666
exit 1
6767
fi

examples/common/repart.d/01-esp.conf

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/common/repart.d/02-sysroot.conf

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/common/run-repart

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,33 @@ chcon -R system_u:object_r:usr_t:s0 tmp/sysroot/composefs
77
chcon system_u:object_r:var_t:s0 tmp/sysroot/state/*/var
88
chcon system_u:object_r:etc_t:s0 tmp/sysroot/state/*/etc/*
99

10-
definitions="${0%/*}/repart.d"
10+
definitions='tmp/repart.d'
11+
export SYSTEMD_REPART_MKFS_OPTIONS_EXT4='-O verity'
1112

12-
if [ "${FIX_VERITY:-}" = '1' ]; then
13-
export SYSTEMD_REPART_MKFS_OPTIONS_EXT4='-O verity'
14-
cp -r "${definitions}" tmp/repart.d
15-
sed -i 's/:fsverity=copy//' tmp/repart.d/02-sysroot.conf
16-
definitions='tmp/repart.d'
13+
mkdir -p "$definitions"
14+
15+
cat <<EOF > tmp/repart.d/01-esp.conf
16+
[Partition]
17+
Type=esp
18+
Format=vfat
19+
CopyFiles=/efi:/
20+
SizeMinBytes=512M
21+
SizeMaxBytes=512M
22+
EOF
23+
24+
if [ "${FS_VERITY_MODE:-repart}" = 'repart' ]; then
25+
COPY_FILES_FLAG="/sysroot:/:fsverity=copy"
1726
fi
1827

28+
cat <<EOF > tmp/repart.d/02-sysroot.conf
29+
[Partition]
30+
Type=root
31+
Format=${FS_FORMAT:-ext4}
32+
SizeMinBytes=10G
33+
SizeMaxBytes=10G
34+
CopyFiles=${COPY_FILES_FLAG:-/sysroot:/}
35+
EOF
36+
1937
# Setting TMPDIR here has a couple of advantages:
2038
# - we already have our own temporary directory
2139
# - systemd-repart can copy the files faster when they are in the same partition
@@ -30,6 +48,6 @@ TMPDIR="${PWD}/tmp" systemd-repart \
3048
--definitions="${definitions}" \
3149
"$1"
3250

33-
if [ "${FIX_VERITY:-}" = '1' ]; then
51+
if [ "${FS_VERITY_MODE:-repart}" = 'fix' ]; then
3452
"${0%/*}/fix-verity/fix-verity" "$1"
3553
fi

examples/test/run-tests

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ def test_basic(m: testvm.Machine):
1111
m.execute('! touch /a')
1212

1313
# the content of /sysroot is what we expect
14-
assert m.execute('ls /sysroot') == 'composefs\nlost+found\nstate\n'
14+
# lost+found is only available on ext4, and this also tests xfs
15+
assert [
16+
name for name in m.execute('ls /sysroot').splitlines() if name != 'lost+found'
17+
] == ['composefs', 'state']
1518

1619
# make sure /etc and /var persist across a reboot
1720
m.write('/etc/persists.conf', 'hihi conf')

0 commit comments

Comments
 (0)