mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-30 05:47:59 +00:00
Fix race condition in loop device setup in mount regression test
Calling losetup -f first and passing its result to create the loop device creates a race condition in which the loop device might be claimed first in between the two losetup calls. Instead, create the device atomically and then obtain the loop device /dev/ handle afterwards. Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
This commit is contained in:
parent
5fb91616e3
commit
95f3bdf66b
@ -77,8 +77,8 @@ if [ ! -b /dev/loop0 ] ; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# find the next free loop device and mount it
|
# find the next free loop device and mount it
|
||||||
loop_device=$(losetup -f) || fatalerror 'Unable to find a free loop device'
|
/sbin/losetup -f ${mount_file} || fatalerror 'Unable to set up a loop device'
|
||||||
/sbin/losetup "$loop_device" ${mount_file} > /dev/null 2> /dev/null
|
loop_device="$(/sbin/losetup -n -O NAME -l -j ${mount_file})"
|
||||||
|
|
||||||
options=(
|
options=(
|
||||||
# default and non-default options
|
# default and non-default options
|
||||||
|
Loading…
x
Reference in New Issue
Block a user