/usr/share/cgmanager/tests/test09.sh is in cgmanager-tests 0.24-0ubuntu5.
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 | #!/bin/bash
# Create a new directory and chown it to calling user; then try to have
# calling user movepid to the new directory
echo "Test 9 (Chown)"
if [ -n "$SUDO_USER" ]; then
gid=$SUDO_GID
uid=$SUDO_UID
else
gid=1000
uid=1000
fi
mnt=`mktemp -d`
cleanup() {
umount $mnt || true
rmdir $mnt
}
trap cleanup EXIT
# We can't readily verify if we can't mount cgroups
cantmount=0
mount -t cgroup -o memory cgroup $mnt || cantmount=1
if [ $cantmount -eq 0 ]; then
myc=`cat /proc/$$/cgroup | grep memory | awk -F: '{ print $3 }'`
rmdir "${mnt}/${myc}/zzz/b" || true
rmdir "${mnt}/${myc}/zzz" || true
fi
dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock --type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.Create string:'memory' string:"zzz" > /dev/null 2>&1
dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock --type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.Chown string:'memory' string:"zzz" int32:$uid int32:$gid > /dev/null 2>&1
if [ $cantmount -eq 1 ]; then
echo "Chowned zzz, but cannot verify the result"
exit 0
fi
o1=`stat --format="%u:%g" ${mnt}/${myc}/zzz`
o2=`stat --format="%u:%g" ${mnt}/${myc}/zzz/tasks`
o3=`stat --format="%u:%g" ${mnt}/${myc}/zzz/cgroup.procs`
o4=`stat --format="%u:%g" ${mnt}/${myc}/zzz/memory.limit_in_bytes`
if [ "$o1" != "$uid:$gid" ]; then
exit 1
fi
if [ "$o2" != "$uid:$gid" ]; then
exit 1
fi
if [ "$o3" != "$uid:$gid" ]; then
exit 1
fi
if [ "$o4" = "$uid:$gid" ]; then
exit 1
fi
exit 0
|