Files
Pigeon/init.sh
T

40 lines
1002 B
Bash
Raw Normal View History

2026-10-15 20:33:59 -04:00
#!/bin/sh
export PATH=/bin TMPDIR=/tmp
trap 'sync ; echo 1 >/proc/sys/kernel/sysrq ; echo b >/proc/sysrq-trigger' EXIT
mount -t proc proc /proc
mount -t devtmpfs devtmpfs /dev
mount -t tmpfs tmp /tmp
mount -t ext4 -r /dev/vdb /root/student
mount -t ext4 -r /dev/vdc /root/project
mount -t ext4 /dev/vdd /root/results
cp -a /root/student/. /tmp/
cp -a --remove-destination /root/project/build/. /tmp/
chmod -R 777 /tmp
2026-10-23 18:16:37 -04:00
cd /tmp || exit 1
2026-10-15 20:33:59 -04:00
2026-10-23 18:16:37 -04:00
sandbox() {
LIMIT="$1" ; shift
(
ulimit -t "$LIMIT" -u 256 -n 256 -f 2048
2026-10-15 20:33:59 -04:00
setpriv --reuid=1 --regid=1 --clear-groups --no-new-privs --inh-caps=-all \
2026-10-23 18:16:37 -04:00
timeout -s 9 "$LIMIT" "$@"
)
}
sandbox 30 make >/root/results/build.log 2>&1
echo $? >/root/results/build.status
2026-10-15 20:33:59 -04:00
2026-10-23 12:36:36 -04:00
for TEST in /root/project/tests/* ; do
2026-10-23 18:16:37 -04:00
[ -f "$TEST" ] || continue
NAME="$(basename "$TEST")"
ARGS="/root/project/args/$NAME"
[ -f "$ARGS" ] || ARGS=/dev/null
sandbox 2 "$TEST" <"$ARGS" >"/root/results/$NAME" 2>/dev/null
echo $? >"/root/results/$NAME.status"
2026-10-15 20:33:59 -04:00
done