tests: check for loopback module on pivot_root test

mount -o loop fails when the loopback module is not loaded with
permission denied. Add a check if /dev/loop0 exists. If not, load
the loop module.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/781
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
This commit is contained in:
Georgia Garcia 2021-08-02 14:24:53 -03:00
parent 3f46d96aca
commit 656a48b900

View file

@ -45,6 +45,11 @@ pivot_root_cleanup() {
}
do_onexit="pivot_root_cleanup"
# loopback module must be loaded for mount -o loop to work
if [ ! -b /dev/loop0 ] ; then
modprobe loop
fi
# systemd mounts / and everything under it MS_SHARED. This breaks
# pivot_root entirely, so attempt to detect it, and remount /
# MS_PRIVATE temporarily.