2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 10:07:12 +00:00

Merge regression tests: make loop device size more generous

Depending on the system, copying echo to the loop device fails because the echo binary is too large.
Especially on systems that have echo be just a symlink to coreutils (e.g. busybox) (as opposed to echo being its own binary) 16k is just not enough.
2M seems fine on my system, but this might need yet a higher value depending on what coreutils other people actually run.

The crash in question:
```
cp: error writing '/tmp/sdtest.3937422-31490-Bxvi6g/mount_target/echo': No space left on device
Fatal Error (file_unbindable_mount): Unexpected shell error. Run with -x to debug
rm: cannot remove '/tmp/sdtest.3937422-31490-Bxvi6g/mount_target': Device or resource busy
```

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1469
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
This commit is contained in:
John Johansen 2024-12-20 08:53:41 +00:00
commit 8e431ebcd9

View File

@ -22,14 +22,14 @@ backing_file="$tmpdir/loop_file"
mount_target="$tmpdir/mount_target" mount_target="$tmpdir/mount_target"
mkdir "${mount_target}" mkdir "${mount_target}"
fallocate -l 512K "${backing_file}" fallocate -l 4M "${backing_file}"
mkfs.fat -F 32 "${backing_file}" > /dev/null 2> /dev/null mkfs.fat -F 32 "${backing_file}" > /dev/null 2> /dev/null
losetup -f "${backing_file}" || fatalerror 'Unable to set up a loop device' losetup -f "${backing_file}" || fatalerror 'Unable to set up a loop device'
loop_device="$(/sbin/losetup -n -O NAME -l -j "${backing_file}")" loop_device="$(/sbin/losetup -n -O NAME -l -j "${backing_file}")"
mount --make-unbindable "${loop_device}" "${mount_target}" mount --make-unbindable "${loop_device}" "${mount_target}"
fallocate -l 16K "${mount_target}/a_file" fallocate -l 2M "${mount_target}/a_file"
# echo is also a builtin, making things a bit more complicated # echo is also a builtin, making things a bit more complicated
cp "$(type -P echo)" "${mount_target}/echo" cp "$(type -P echo)" "${mount_target}/echo"