diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-05-08 18:44:01 +0200 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-05-10 18:07:47 +0200 |
commit | e57b7020d2ee89d9c906bcefa091d31b067dedcc (patch) | |
tree | e16f23cbadb2ad96a69423c4fce51456d2f74439 /test | |
parent | 39a39f18f2bd2b1ef7b4fa4823472d129c514030 (diff) | |
download | systemd-e57b7020d2ee89d9c906bcefa091d31b067dedcc.tar.gz |
repart: Fix deny list logic
Until now, we always excluded the top level directories that were
covered by child partition mount points, regardless of the source
directory and the target directory of the copy files operation.
This means that even if we were populating a XBOOTLDR partition, if
there was an EFI partition in the image, we'd exclude /boot
unconditionally, leading to the XBOOTLDR partition to be empty.
Also, because of the same cause, if we were copying a nested source
directory (e.g. /abc/def) to the root directory in the root
partition, if /abc/def/usr existed and was populated with files and
directories, the root partition would have those files under /usr,
even if a /usr partition was defined.
To fix these issues, instead of unconditionally excluding the top
level partition mount points under <source>, let's make sure that
when we're copying files from any source directory to the root
directory of a root partition, that we exclude the partition mount
point directories under the source directory instead of the top
level ones.
Diffstat (limited to 'test')
-rwxr-xr-x | test/units/testsuite-58.sh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/units/testsuite-58.sh b/test/units/testsuite-58.sh index 7c05d8c71f..6cc699f151 100755 --- a/test/units/testsuite-58.sh +++ b/test/units/testsuite-58.sh @@ -855,11 +855,19 @@ test_exclude_files() { runas testuser touch "$root/usr/qed" runas testuser mkdir "$root/tmp" runas testuser touch "$root/tmp/prs" + runas testuser mkdir "$root/proc" + runas testuser touch "$root/proc/prs" + runas testuser mkdir "$root/zzz" + runas testuser mkdir "$root/zzz/usr" + runas testuser touch "$root/zzz/usr/prs" + runas testuser mkdir "$root/zzz/proc" + runas testuser touch "$root/zzz/proc/prs" runas testuser tee "$defs/00-root.conf" <<EOF [Partition] Type=root-${architecture} CopyFiles=/ +CopyFiles=/zzz:/ EOF runas testuser tee "$defs/10-usr.conf" <<EOF @@ -893,6 +901,10 @@ EOF assert_rc 0 ls "$imgs/mnt/usr" assert_rc 2 ls "$imgs/mnt/usr/def" + # Test that /zzz/usr/prs did not end up in the root partition under /usr but did end up in /zzz/usr/prs + assert_rc 2 ls "$imgs/mnt/usr/prs" + assert_rc 0 ls "$imgs/mnt/zzz/usr/prs" + # Test that /tmp/prs did not end up in the root partition but /tmp did. assert_rc 0 ls "$imgs/mnt/tmp" assert_rc 2 ls "$imgs/mnt/tmp/prs" @@ -902,6 +914,13 @@ EOF assert_rc 0 ls "$imgs/mnt/usr/def" assert_rc 2 ls "$imgs/mnt/usr/qed" + # Test that /zzz/proc/prs did not end up in the root partition but /proc did. + assert_rc 0 ls "$imgs/mnt/proc" + assert_rc 2 ls "$imgs/mnt/proc/prs" + + # Test that /zzz/usr/prs did not end up in the usr partition. + assert_rc 2 ls "$imgs/mnt/usr/prs" + umount -R "$imgs/mnt" losetup -d "$loop" } |