/usr/share/cgmanager/tests/test24.sh is in cgmanager-tests 0.39-2ubuntu5.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | #!/bin/bash
echo "Test 24: prune"
if [ -n "$SUDO_USER" ]; then
gid=$SUDO_GID
uid=$SUDO_UID
else
gid=1000
uid=1000
fi
cgm create freezer prune0/prune1/prune2
# Test that non-root cannot prune root-owned dir
if sudo -u \#$uid cgm prune freezer prune0; then
echo "unpriv user was able to prune a root-owned cgroup"
exit 1
fi
# Test that root can recursively prune
if ! cgm prune freezer prune0; then
echo "root failed to prune a directory"
exit 1
fi
sleep 1 # give buggy kernels a chance
if cgm listchildren freezer prune0 2>/dev/null; then
echo "root failed to prune a directory"
exit 1
fi
if ! grep -q cgm-release-agent /proc/$(pidof cgmanager)/root/run/cgmanager/fs/freezer/release_agent; then
echo "freezer was pre-mounted; skipping prune test requiring release agent"
exit 0
fi
# Test that prune effects after all tasks die
cgm create freezer prune1
sleep 3 &
pid=$!
cgm movepid freezer prune1 $pid
cgm prune freezer prune1
wait $!
sleep 1 # give buggy kernels a chance
if cgm listchildren freezer prune1 2>/dev/null; then
echo "prune failed to effect remove-on-empty"
exit 1
fi
# Same, but recursive
# This will fail if cgroup has been premounted.
cgm create freezer prune1/prune2
sleep 3 &
pid=$!
cgm movepid freezer prune1/prune2 $pid
cgm prune freezer prune1
wait $!
sleep 1 # give buggy kernels a chance
if cgm listchildren freezer prune1 2>/dev/null; then
echo "prune failed to recursively remove-on-empty"
echo "if freezer was not premounted, this is a bug"
exit 1
fi
echo PASS
|