diff options
| author | cassiopc <cassiopc@gmail.com> | 2012-08-08 17:52:19 +0000 |
|---|---|---|
| committer | cassiopc <cassiopc@gmail.com> | 2012-08-08 17:52:19 +0000 |
| commit | 5d4eca5257a60c5f1de043fdf3f67e0a9df011f4 (patch) | |
| tree | 6d4ec6ffe1b6490be4120c0f06ae6cdabca41dd8 | |
| parent | f8c7c32e3ea6417ccf04309ec521b39a0c20414d (diff) | |
| download | boca-5d4eca5257a60c5f1de043fdf3f67e0a9df011f4.tar.gz boca-5d4eca5257a60c5f1de043fdf3f67e0a9df011f4.zip | |
many small bug fixes
97 files changed, 533 insertions, 5452 deletions
diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/compare b/boca-1.5.0/doc/problemexamples/abacaxi/compare new file mode 120000 index 0000000..934e331 --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/abacaxi/compare @@ -0,0 +1 @@ +../problemtemplate/compare
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/compare/c b/boca-1.5.0/doc/problemexamples/abacaxi/compare/c deleted file mode 100755 index 4998be3..0000000 --- a/boca-1.5.0/doc/problemexamples/abacaxi/compare/c +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -# // Last modified 21/jul/2012 by cassio@ime.usp.br -# -# This script receives: -# $1 team_output -# $2 sol_output -# $3 problem_input (might be used by some specific checkers, here it is not) -# -# BOCA reads the last line of the standard output -# and pass it to judges -# -if [ ! -r "$1" -o ! -r "$2" ]; then - echo "Parameter problem" - exit 43 -fi - -# Next lines of this script just compares team_output and sol_output, -# although it is possible to change them to more complex evaluations. - -diff -q "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff \"$1\" \"$2\" # files match" - echo "Files match exactly" - exit 4 -fi -diff -q -b "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b \"$1\" \"$2\" # files match" - echo -e "diff -c \"$1\" \"$2\" # files dont match - see output" - diff -c "$1" "$2" - echo "Files match with differences in the amount of white spaces" - exit 5 -fi -diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output" - diff -c -b "$1" "$2" - echo "Files match with differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B "$1" "$2" - echo "Files match if we ignore case and differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B "$1" "$2" - echo "Files match if we discard all white spaces" - exit 5 -fi -diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B -w "$1" "$2" - echo "Files match if we ignore case and discard all white spaces" - exit 5 -fi -wd=`which wdiff` -if [ "$wd" != "" ]; then - wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null - if [ "$?" == "0" ]; then - echo -e "wdiff \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B -w "$1" "$2" - echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff" - echo "diff has a bug that, if a line contains a single space, this is not discarded by -w" - exit 5 - fi -fi -echo -e "### files dont match - see output" -diff -c -i -b -B -w "$1" "$2" -echo "Differences found" -exit 6 diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/compare/cpp b/boca-1.5.0/doc/problemexamples/abacaxi/compare/cpp deleted file mode 100755 index 4998be3..0000000 --- a/boca-1.5.0/doc/problemexamples/abacaxi/compare/cpp +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -# // Last modified 21/jul/2012 by cassio@ime.usp.br -# -# This script receives: -# $1 team_output -# $2 sol_output -# $3 problem_input (might be used by some specific checkers, here it is not) -# -# BOCA reads the last line of the standard output -# and pass it to judges -# -if [ ! -r "$1" -o ! -r "$2" ]; then - echo "Parameter problem" - exit 43 -fi - -# Next lines of this script just compares team_output and sol_output, -# although it is possible to change them to more complex evaluations. - -diff -q "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff \"$1\" \"$2\" # files match" - echo "Files match exactly" - exit 4 -fi -diff -q -b "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b \"$1\" \"$2\" # files match" - echo -e "diff -c \"$1\" \"$2\" # files dont match - see output" - diff -c "$1" "$2" - echo "Files match with differences in the amount of white spaces" - exit 5 -fi -diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output" - diff -c -b "$1" "$2" - echo "Files match with differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B "$1" "$2" - echo "Files match if we ignore case and differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B "$1" "$2" - echo "Files match if we discard all white spaces" - exit 5 -fi -diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B -w "$1" "$2" - echo "Files match if we ignore case and discard all white spaces" - exit 5 -fi -wd=`which wdiff` -if [ "$wd" != "" ]; then - wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null - if [ "$?" == "0" ]; then - echo -e "wdiff \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B -w "$1" "$2" - echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff" - echo "diff has a bug that, if a line contains a single space, this is not discarded by -w" - exit 5 - fi -fi -echo -e "### files dont match - see output" -diff -c -i -b -B -w "$1" "$2" -echo "Differences found" -exit 6 diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/compare/java b/boca-1.5.0/doc/problemexamples/abacaxi/compare/java deleted file mode 100755 index 4998be3..0000000 --- a/boca-1.5.0/doc/problemexamples/abacaxi/compare/java +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -# // Last modified 21/jul/2012 by cassio@ime.usp.br -# -# This script receives: -# $1 team_output -# $2 sol_output -# $3 problem_input (might be used by some specific checkers, here it is not) -# -# BOCA reads the last line of the standard output -# and pass it to judges -# -if [ ! -r "$1" -o ! -r "$2" ]; then - echo "Parameter problem" - exit 43 -fi - -# Next lines of this script just compares team_output and sol_output, -# although it is possible to change them to more complex evaluations. - -diff -q "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff \"$1\" \"$2\" # files match" - echo "Files match exactly" - exit 4 -fi -diff -q -b "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b \"$1\" \"$2\" # files match" - echo -e "diff -c \"$1\" \"$2\" # files dont match - see output" - diff -c "$1" "$2" - echo "Files match with differences in the amount of white spaces" - exit 5 -fi -diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output" - diff -c -b "$1" "$2" - echo "Files match with differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B "$1" "$2" - echo "Files match if we ignore case and differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B "$1" "$2" - echo "Files match if we discard all white spaces" - exit 5 -fi -diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B -w "$1" "$2" - echo "Files match if we ignore case and discard all white spaces" - exit 5 -fi -wd=`which wdiff` -if [ "$wd" != "" ]; then - wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null - if [ "$?" == "0" ]; then - echo -e "wdiff \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B -w "$1" "$2" - echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff" - echo "diff has a bug that, if a line contains a single space, this is not discarded by -w" - exit 5 - fi -fi -echo -e "### files dont match - see output" -diff -c -i -b -B -w "$1" "$2" -echo "Differences found" -exit 6 diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/compile b/boca-1.5.0/doc/problemexamples/abacaxi/compile new file mode 120000 index 0000000..83641d6 --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/abacaxi/compile @@ -0,0 +1 @@ +../problemtemplate/compile
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/compile/c b/boca-1.5.0/doc/problemexamples/abacaxi/compile/c deleted file mode 100644 index 04a08e9..0000000 --- a/boca-1.5.0/doc/problemexamples/abacaxi/compile/c +++ /dev/null @@ -1,159 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 source_file -# $2 exe_file (default run.exe) -# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition) -# $4 maximum allowed memory (in MBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 - -if [ "$1" == "" ]; then - echo "parameter problem" - exit 43 -fi -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -name="$1" -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -mkdir -p src -if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then - unzip "$name" -d src - name="*.c" -else - mv $name src -fi -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi -maxm=512000 -if [ "$4" != "" -a "$4" -gt "0" ]; then -maxm=${4}000 -fi - -# setting up the timelimit according to the problem -if [ "$3" == "" ]; then -time=5 -else -time=$3 -fi -let ttime=$time+30 - -if [ "$2" == "" ]; then - exe=run.exe -else - exe=$2 -fi - -rm -f ../$exe 2>/dev/null -cat <<EOF > compileit.sh -#!/bin/bash -cc=\`which gcc\` -[ -x "\$cc" ] || cc=/usr/bin/gcc -if [ ! -x "\$cc" ]; then - echo "\$cc not found or it's not executable" - exit 47 -fi -cd src -"\$cc" -static -O2 -lm -o ../$exe "$name" -echo \$? > compileit.retcode -exit 0 -EOF -chmod 755 compileit.sh - -cdir=`pwd` -echo "Current directory is $cdir" >&2 -echo $cdir | grep -q "/bocajail" -if [ $? == 0 ]; then - cdir=`echo $cdir | sed "s/.*\/bocajail//"` - cat <<EOF > runit.sh -#!/bin/bash -[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc -#/bin/mount --bind /dev /dev -[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys -$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh -echo \$? > runit.retcode -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null -EOF - chmod 755 runit.sh - chroot /bocajail "$cdir/runit.sh" - ret=`cat runit.retcode` -else - echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING" - $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh - ret=$? -fi -rm -rf src/ -if [ -f stdout0 ]; then - cat stdout0 -fi -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - exit $ret -fi -ret=`cat compileit.retcode` -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - ret=1 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/compile/cpp b/boca-1.5.0/doc/problemexamples/abacaxi/compile/cpp deleted file mode 100644 index 2ec55ac..0000000 --- a/boca-1.5.0/doc/problemexamples/abacaxi/compile/cpp +++ /dev/null @@ -1,159 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 source_file -# $2 exe_file (default run.exe) -# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition) -# $4 maximum allowed memory (in MBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 - -if [ "$1" == "" ]; then - echo "parameter problem" - exit 43 -fi -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -name="$1" -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -mkdir -p src -if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then - unzip "$name" -d src - name="*.c" -else - mv $name src -fi -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi -maxm=512000 -if [ "$4" != "" -a "$4" -gt "0" ]; then -maxm=${4}000 -fi - -# setting up the timelimit according to the problem -if [ "$3" == "" ]; then -time=5 -else -time=$3 -fi -let ttime=$time+30 - -if [ "$2" == "" ]; then - exe=run.exe -else - exe=$2 -fi - -rm -f ../$exe 2>/dev/null -cat <<EOF > compileit.sh -#!/bin/bash -cc=\`which g++\` -[ -x "\$cc" ] || cc=/usr/bin/g++ -if [ ! -x "\$cc" ]; then - echo "\$cc not found or it's not executable" - exit 47 -fi -cd src -"\$cc" -static -O2 -lm -o ../$exe "$name" -echo \$? > compileit.retcode -exit 0 -EOF -chmod 755 compileit.sh - -cdir=`pwd` -echo "Current directory is $cdir" >&2 -echo $cdir | grep -q "/bocajail" -if [ $? == 0 ]; then - cdir=`echo $cdir | sed "s/.*\/bocajail//"` - cat <<EOF > runit.sh -#!/bin/bash -[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc -#/bin/mount --bind /dev /dev -[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys -$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh -echo \$? > runit.retcode -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null -EOF - chmod 755 runit.sh - chroot /bocajail "$cdir/runit.sh" - ret=`cat runit.retcode` -else - echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING" - $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh - ret=$? -fi -rm -rf src/ -if [ -f stdout0 ]; then - cat stdout0 -fi -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - exit $ret -fi -ret=`cat compileit.retcode` -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - ret=1 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/compile/java b/boca-1.5.0/doc/problemexamples/abacaxi/compile/java deleted file mode 100644 index dae050e..0000000 --- a/boca-1.5.0/doc/problemexamples/abacaxi/compile/java +++ /dev/null @@ -1,176 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 source_file -# $2 exe_file (default run.jar) -# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition) -# $4 maximum allowed memory (in MBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 -if [ "$1" == "" ]; then - echo "parameter problem" - exit 43 -fi -name="$1" -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -mkdir -p src -if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then - unzip "$name" -d src - if [ "${name##*.}" == "zip" ]; then - name=`basename $name .zip` - else - name=`basename $name .ZIP` - fi -else - mv $name src -fi - -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi - -time=$4 -if [ "$time" -gt "0" ]; then - let "ttime = $time + 30" -else - time=1 - ttime=30 -fi - -maxm=512 -if [ "$4" != "" -a "$4" -gt "0" ]; then -maxm=$4 -fi - -if [ "$2" == "" ]; then - jarfile=run.jar -else - jarfile=$2 -fi - -cdir=`pwd` -echo "Current directory is $cdir" >&2 - -cat <<EOF > compileit.sh -#!/bin/bash -javac=`which javac` -[ -x "\$javac" ] || javac=/usr/bin/javac -if [ ! -x \$javac ]; then - echo "\$javac not found or it's not executable" - exit 47 -fi -jar=`which jar` -[ -x "\$jar" ] || jar=/usr/bin/jar -if [ ! -x \$jar ]; then - echo "\$jar not found or it's not executable" - exit 47 -fi -export CLASSPATH=.:\$CLASSPATH -cd src -if [ -r "$name" ]; then - \$javac -Xmx${maxm}M -Xms${maxm}M "$name" - echo \$? > compileit.retcode -fi -find . -name "*.java" | while read lin; do - \$javac -Xmx${maxm}M -Xms${maxm}M "\$lin" - echo \$? > compileit.retcode -done -rm -f ../$jarfile -\$jar cvf ../$jarfile * -EOF -chmod 755 compileit.sh - -echo $cdir | grep -q "/bocajail" -if [ $? == 0 ]; then - cdir=`echo $cdir | sed "s/.*\/bocajail//"` - cat <<EOF > runit.sh -#!/bin/bash -[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc -#/bin/mount --bind /dev /dev -[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys - -$sf -r1 -t$time -T$ttime -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 ./compileit.sh - -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null -EOF - chmod 755 runit.sh - chroot /bocajail "$cdir/runit.sh" - ret=`cat runit.retcode` -else - echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING" -# $javac "$name" - $sf -r1 -t$time -T$ttime -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 ./compileit.sh - ret=$? -fi -rm -rf src/ -if [ -f stdout0 ]; then - cat stdout0 -fi -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - exit $ret -fi -ret=`cat compileit.retcode` -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - ret=1 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/limits b/boca-1.5.0/doc/problemexamples/abacaxi/limits new file mode 120000 index 0000000..3744764 --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/abacaxi/limits @@ -0,0 +1 @@ +../problemtemplate/limits
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/limits/c b/boca-1.5.0/doc/problemexamples/abacaxi/limits/c deleted file mode 100644 index b48a3b7..0000000 --- a/boca-1.5.0/doc/problemexamples/abacaxi/limits/c +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename -echo 4 -# and the number of repetitions to run within the given timelimit in the second line -echo 10 -# and the maximum amount of memory per repetition in the third line (in Mbytes) -echo 512 -# and shall return zero to indicate no failure -exit 0 -# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be -# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is -# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs -# the value. diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/limits/cpp b/boca-1.5.0/doc/problemexamples/abacaxi/limits/cpp deleted file mode 100644 index b48a3b7..0000000 --- a/boca-1.5.0/doc/problemexamples/abacaxi/limits/cpp +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename -echo 4 -# and the number of repetitions to run within the given timelimit in the second line -echo 10 -# and the maximum amount of memory per repetition in the third line (in Mbytes) -echo 512 -# and shall return zero to indicate no failure -exit 0 -# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be -# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is -# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs -# the value. diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/limits/java b/boca-1.5.0/doc/problemexamples/abacaxi/limits/java deleted file mode 100644 index b48a3b7..0000000 --- a/boca-1.5.0/doc/problemexamples/abacaxi/limits/java +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename -echo 4 -# and the number of repetitions to run within the given timelimit in the second line -echo 10 -# and the maximum amount of memory per repetition in the third line (in Mbytes) -echo 512 -# and shall return zero to indicate no failure -exit 0 -# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be -# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is -# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs -# the value. diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/run b/boca-1.5.0/doc/problemexamples/abacaxi/run new file mode 120000 index 0000000..fd7410f --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/abacaxi/run @@ -0,0 +1 @@ +../problemtemplate/run
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/run/c b/boca-1.5.0/doc/problemexamples/abacaxi/run/c deleted file mode 100755 index d65ed58..0000000 --- a/boca-1.5.0/doc/problemexamples/abacaxi/run/c +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 exe_file -# $2 input_file -# $3 timelimit (limit to run all the repetitions, by default only one repetition) -# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit) -# $5 maximum allowed memory (in KBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec - -if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then - echo "parameter problem" - exit 43 -fi -name=`basename "$1"` -if [ ! -x "$name" ]; then - echo "$1 not found (or is not in the current dir) or it's not executable" - exit 44 -fi -if [ "${name##*.}" != "exe" -a "${name##*.}" != "EXE" ]; then - echo "WARNING: executable file extension is not .exe" -fi -input=`basename "$2"` -if [ ! -r "$input" ]; then - echo "$2 not found (or is not in the current dir) or it's not readable" - exit 45 -fi -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi - -time=$3 -if [ "$time" -gt "0" ]; then - let "ttime = $time + 30" -else - time=1 - ttime=30 -fi - -nruns=1 -if [ "$4" != "" -a "$4" -gt "0" ]; then -nruns=$4 -fi -maxm=512000 -if [ "$5" != "" -a "$5" -gt "0" ]; then -maxm=${5}000 -fi - -rm -f stdin0 2>/dev/null -mv "$input" stdin0 - -rm -f run.exe 2>/dev/null -mv "$name" run.exe -file run.exe | grep -iq "statically linked" -if [ "$?" != "0" ]; then - echo "Aborting because $name is not statically linked" - exit 47 -fi - -cdir=`pwd` -echo "Current directory is $cdir -- chrooting on it" >&2 -$sf -F10 -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe -ret=$? -if [ $ret -gt 10 ]; then - ret=0 -fi -if [ -f stdout0 ]; then - cat stdout0 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/run/cpp b/boca-1.5.0/doc/problemexamples/abacaxi/run/cpp deleted file mode 100755 index 9b2d092..0000000 --- a/boca-1.5.0/doc/problemexamples/abacaxi/run/cpp +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 exe_file -# $2 input_file -# $3 timelimit (limit to run all the repetitions, by default only one repetition) -# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit) -# $5 maximum allowed memory (in KBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec - -if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then - echo "parameter problem" - exit 43 -fi -if [ ! -x "$1" ]; then - echo "$1 not found or it's not executable" - exit 44 -fi -name="$1" -if [ "${name##*.}" != "exe" -a "${name##*.}" != "EXE" ]; then - echo "WARNING: executable file extension is not .exe" -fi -if [ ! -r "$2" ]; then - echo "$2 not found or it's not readable" - exit 45 -fi -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi - -time=$3 -if [ "$time" -gt "0" ]; then - let "ttime = $time + 30" -else - time=1 - ttime=30 -fi - -nruns=1 -if [ "$4" != "" -a "$4" -gt "0" ]; then -nruns=$4 -fi -maxm=512000 -if [ "$5" != "" -a "$5" -gt "0" ]; then -maxm=${5}000 -fi - -rm -f stdin0 2>/dev/null -mv "$2" stdin0 - -rm -f run.exe 2>/dev/null -mv "$name" run.exe -file run.exe | grep -iq "statically linked" -if [ "$?" != "0" ]; then - echo "Aborting because $name is not statically linked" - exit 47 -fi - -cdir=`pwd` -echo "Current directory is $cdir -- chrooting on it" >&2 -$sf -F10 -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe -ret=$? -if [ $ret -gt 10 ]; then - ret=0 -fi -if [ -f stdout0 ]; then - cat stdout0 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/run/java b/boca-1.5.0/doc/problemexamples/abacaxi/run/java deleted file mode 100755 index 945f15d..0000000 --- a/boca-1.5.0/doc/problemexamples/abacaxi/run/java +++ /dev/null @@ -1,163 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 main_class -# $2 input_file -# $3 timelimit (limit to run all the repetitions, by default only one repetition) -# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit) -# $5 maximum allowed memory (in KBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec - -if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then - echo "parameter problem" - exit 43 -fi -if [ ! -r run.jar ]; then - echo "ERROR: file run.jar not found - possible error during compilation" - exit 1 -fi -name="$1" -if [ "${name##*.}" == "class" -a "${name##*.}" == "CLASS" ]; then - echo "WARNING: removing .class file extension" -fi -if [ "${name##*.}" == "class" ]; then - name=`basename "$1" .class` -fi -if [ "${name##*.}" == "CLASS" ]; then - name=`basename "$1" .CLASS` -fi -input=`basename "$2"` -if [ ! -r "$input" ]; then - echo "$2 not found (or is not in the current dir) or it's not readable" - exit 45 -fi -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi - -time=$3 -if [ "$time" -gt "0" ]; then - let "ttime = $time + 30" -else - time=1 - ttime=30 -fi - -nruns=1 -if [ "$4" != "" -a "$4" -gt "0" ]; then -nruns=$4 -fi -maxm=512 -if [ "$5" != "" -a "$5" -gt "0" ]; then -maxm=${5} -fi - -rm -f stdin0 2>/dev/null -mv "$input" stdin0 - -cdir=`pwd` -echo "Current directory is $cdir" >&2 -echo $cdir | grep -q "/bocajail" -if [ $? == 0 ]; then - cdir=`echo $cdir | sed "s/.*\/bocajail//"` - cat <<EOF > runit.sh -#!/bin/bash -[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc -#/bin/mount --bind /dev /dev -[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys -java=`which java` -[ -x "$java" ] || java=/usr/bin/java -if [ ! -x $java ]; then - echo "$java not found or it's not executable" - exit 47 -fi -export CLASSPATH=.:./run.jar:$CLASSPATH -cd $cdir -$sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 -- $java -Xmx${maxm}M -Xms${maxm}M "$name" -echo \$? > runit.retcode -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null -EOF - chmod 755 runit.sh - chroot /bocajail $cdir/runit.sh - ret=`cat runit.retcode` - if [ "$ret" == "" ]; then - echo "Execution error - check autojudging" - exit 49 - fi - if [ $ret -gt 10 ]; then - echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <" - exit 9 - fi - else - echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 - echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 - echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 -# $java "$name" < stdin0 - $sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 -- $java -cp run.jar -Xmx${maxm}M -Xms${maxm}M "$name" - ret=$? - fi - if [ $ret -gt 10 ]; then - echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <" - ret=9 - fi -fi -if [ -f stdout0 ]; then - cat stdout0 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/tests b/boca-1.5.0/doc/problemexamples/abacaxi/tests new file mode 120000 index 0000000..7ef2d62 --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/abacaxi/tests @@ -0,0 +1 @@ +../problemtemplate/tests
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/abacaxi/tests/c b/boca-1.5.0/doc/problemexamples/abacaxi/tests/c deleted file mode 100755 index 1a0ca95..0000000 --- a/boca-1.5.0/doc/problemexamples/abacaxi/tests/c +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -cat > test.c <<EOF -int main() { - char s[100]; - scanf("%s", s); - printf("%s\n",s); - return 0; -} -EOF -cat > test.in <<EOF -inputdata -EOF - -TL=2 -REP=10 -../compile/c test.c test.exe TL -../run/c test.exe test.in TL REP -output=`cat stdout0` -if [ "$output" != "inputdata" ]; then - echo "ERROR" - exit 1 -fi -exit 0 diff --git a/boca-1.5.0/doc/problemexamples/bits/compare b/boca-1.5.0/doc/problemexamples/bits/compare new file mode 120000 index 0000000..934e331 --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/bits/compare @@ -0,0 +1 @@ +../problemtemplate/compare
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/bits/compare/c b/boca-1.5.0/doc/problemexamples/bits/compare/c deleted file mode 100755 index 4998be3..0000000 --- a/boca-1.5.0/doc/problemexamples/bits/compare/c +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -# // Last modified 21/jul/2012 by cassio@ime.usp.br -# -# This script receives: -# $1 team_output -# $2 sol_output -# $3 problem_input (might be used by some specific checkers, here it is not) -# -# BOCA reads the last line of the standard output -# and pass it to judges -# -if [ ! -r "$1" -o ! -r "$2" ]; then - echo "Parameter problem" - exit 43 -fi - -# Next lines of this script just compares team_output and sol_output, -# although it is possible to change them to more complex evaluations. - -diff -q "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff \"$1\" \"$2\" # files match" - echo "Files match exactly" - exit 4 -fi -diff -q -b "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b \"$1\" \"$2\" # files match" - echo -e "diff -c \"$1\" \"$2\" # files dont match - see output" - diff -c "$1" "$2" - echo "Files match with differences in the amount of white spaces" - exit 5 -fi -diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output" - diff -c -b "$1" "$2" - echo "Files match with differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B "$1" "$2" - echo "Files match if we ignore case and differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B "$1" "$2" - echo "Files match if we discard all white spaces" - exit 5 -fi -diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B -w "$1" "$2" - echo "Files match if we ignore case and discard all white spaces" - exit 5 -fi -wd=`which wdiff` -if [ "$wd" != "" ]; then - wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null - if [ "$?" == "0" ]; then - echo -e "wdiff \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B -w "$1" "$2" - echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff" - echo "diff has a bug that, if a line contains a single space, this is not discarded by -w" - exit 5 - fi -fi -echo -e "### files dont match - see output" -diff -c -i -b -B -w "$1" "$2" -echo "Differences found" -exit 6 diff --git a/boca-1.5.0/doc/problemexamples/bits/compare/cpp b/boca-1.5.0/doc/problemexamples/bits/compare/cpp deleted file mode 100755 index 4998be3..0000000 --- a/boca-1.5.0/doc/problemexamples/bits/compare/cpp +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -# // Last modified 21/jul/2012 by cassio@ime.usp.br -# -# This script receives: -# $1 team_output -# $2 sol_output -# $3 problem_input (might be used by some specific checkers, here it is not) -# -# BOCA reads the last line of the standard output -# and pass it to judges -# -if [ ! -r "$1" -o ! -r "$2" ]; then - echo "Parameter problem" - exit 43 -fi - -# Next lines of this script just compares team_output and sol_output, -# although it is possible to change them to more complex evaluations. - -diff -q "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff \"$1\" \"$2\" # files match" - echo "Files match exactly" - exit 4 -fi -diff -q -b "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b \"$1\" \"$2\" # files match" - echo -e "diff -c \"$1\" \"$2\" # files dont match - see output" - diff -c "$1" "$2" - echo "Files match with differences in the amount of white spaces" - exit 5 -fi -diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output" - diff -c -b "$1" "$2" - echo "Files match with differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B "$1" "$2" - echo "Files match if we ignore case and differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B "$1" "$2" - echo "Files match if we discard all white spaces" - exit 5 -fi -diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B -w "$1" "$2" - echo "Files match if we ignore case and discard all white spaces" - exit 5 -fi -wd=`which wdiff` -if [ "$wd" != "" ]; then - wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null - if [ "$?" == "0" ]; then - echo -e "wdiff \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B -w "$1" "$2" - echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff" - echo "diff has a bug that, if a line contains a single space, this is not discarded by -w" - exit 5 - fi -fi -echo -e "### files dont match - see output" -diff -c -i -b -B -w "$1" "$2" -echo "Differences found" -exit 6 diff --git a/boca-1.5.0/doc/problemexamples/bits/compare/java b/boca-1.5.0/doc/problemexamples/bits/compare/java deleted file mode 100755 index 4998be3..0000000 --- a/boca-1.5.0/doc/problemexamples/bits/compare/java +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -# // Last modified 21/jul/2012 by cassio@ime.usp.br -# -# This script receives: -# $1 team_output -# $2 sol_output -# $3 problem_input (might be used by some specific checkers, here it is not) -# -# BOCA reads the last line of the standard output -# and pass it to judges -# -if [ ! -r "$1" -o ! -r "$2" ]; then - echo "Parameter problem" - exit 43 -fi - -# Next lines of this script just compares team_output and sol_output, -# although it is possible to change them to more complex evaluations. - -diff -q "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff \"$1\" \"$2\" # files match" - echo "Files match exactly" - exit 4 -fi -diff -q -b "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b \"$1\" \"$2\" # files match" - echo -e "diff -c \"$1\" \"$2\" # files dont match - see output" - diff -c "$1" "$2" - echo "Files match with differences in the amount of white spaces" - exit 5 -fi -diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output" - diff -c -b "$1" "$2" - echo "Files match with differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B "$1" "$2" - echo "Files match if we ignore case and differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B "$1" "$2" - echo "Files match if we discard all white spaces" - exit 5 -fi -diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B -w "$1" "$2" - echo "Files match if we ignore case and discard all white spaces" - exit 5 -fi -wd=`which wdiff` -if [ "$wd" != "" ]; then - wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null - if [ "$?" == "0" ]; then - echo -e "wdiff \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B -w "$1" "$2" - echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff" - echo "diff has a bug that, if a line contains a single space, this is not discarded by -w" - exit 5 - fi -fi -echo -e "### files dont match - see output" -diff -c -i -b -B -w "$1" "$2" -echo "Differences found" -exit 6 diff --git a/boca-1.5.0/doc/problemexamples/bits/compile b/boca-1.5.0/doc/problemexamples/bits/compile new file mode 120000 index 0000000..83641d6 --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/bits/compile @@ -0,0 +1 @@ +../problemtemplate/compile
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/bits/compile/c b/boca-1.5.0/doc/problemexamples/bits/compile/c deleted file mode 100644 index 04a08e9..0000000 --- a/boca-1.5.0/doc/problemexamples/bits/compile/c +++ /dev/null @@ -1,159 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 source_file -# $2 exe_file (default run.exe) -# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition) -# $4 maximum allowed memory (in MBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 - -if [ "$1" == "" ]; then - echo "parameter problem" - exit 43 -fi -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -name="$1" -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -mkdir -p src -if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then - unzip "$name" -d src - name="*.c" -else - mv $name src -fi -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi -maxm=512000 -if [ "$4" != "" -a "$4" -gt "0" ]; then -maxm=${4}000 -fi - -# setting up the timelimit according to the problem -if [ "$3" == "" ]; then -time=5 -else -time=$3 -fi -let ttime=$time+30 - -if [ "$2" == "" ]; then - exe=run.exe -else - exe=$2 -fi - -rm -f ../$exe 2>/dev/null -cat <<EOF > compileit.sh -#!/bin/bash -cc=\`which gcc\` -[ -x "\$cc" ] || cc=/usr/bin/gcc -if [ ! -x "\$cc" ]; then - echo "\$cc not found or it's not executable" - exit 47 -fi -cd src -"\$cc" -static -O2 -lm -o ../$exe "$name" -echo \$? > compileit.retcode -exit 0 -EOF -chmod 755 compileit.sh - -cdir=`pwd` -echo "Current directory is $cdir" >&2 -echo $cdir | grep -q "/bocajail" -if [ $? == 0 ]; then - cdir=`echo $cdir | sed "s/.*\/bocajail//"` - cat <<EOF > runit.sh -#!/bin/bash -[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc -#/bin/mount --bind /dev /dev -[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys -$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh -echo \$? > runit.retcode -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null -EOF - chmod 755 runit.sh - chroot /bocajail "$cdir/runit.sh" - ret=`cat runit.retcode` -else - echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING" - $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh - ret=$? -fi -rm -rf src/ -if [ -f stdout0 ]; then - cat stdout0 -fi -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - exit $ret -fi -ret=`cat compileit.retcode` -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - ret=1 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/bits/compile/cpp b/boca-1.5.0/doc/problemexamples/bits/compile/cpp deleted file mode 100644 index 2ec55ac..0000000 --- a/boca-1.5.0/doc/problemexamples/bits/compile/cpp +++ /dev/null @@ -1,159 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 source_file -# $2 exe_file (default run.exe) -# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition) -# $4 maximum allowed memory (in MBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 - -if [ "$1" == "" ]; then - echo "parameter problem" - exit 43 -fi -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -name="$1" -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -mkdir -p src -if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then - unzip "$name" -d src - name="*.c" -else - mv $name src -fi -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi -maxm=512000 -if [ "$4" != "" -a "$4" -gt "0" ]; then -maxm=${4}000 -fi - -# setting up the timelimit according to the problem -if [ "$3" == "" ]; then -time=5 -else -time=$3 -fi -let ttime=$time+30 - -if [ "$2" == "" ]; then - exe=run.exe -else - exe=$2 -fi - -rm -f ../$exe 2>/dev/null -cat <<EOF > compileit.sh -#!/bin/bash -cc=\`which g++\` -[ -x "\$cc" ] || cc=/usr/bin/g++ -if [ ! -x "\$cc" ]; then - echo "\$cc not found or it's not executable" - exit 47 -fi -cd src -"\$cc" -static -O2 -lm -o ../$exe "$name" -echo \$? > compileit.retcode -exit 0 -EOF -chmod 755 compileit.sh - -cdir=`pwd` -echo "Current directory is $cdir" >&2 -echo $cdir | grep -q "/bocajail" -if [ $? == 0 ]; then - cdir=`echo $cdir | sed "s/.*\/bocajail//"` - cat <<EOF > runit.sh -#!/bin/bash -[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc -#/bin/mount --bind /dev /dev -[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys -$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh -echo \$? > runit.retcode -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null -EOF - chmod 755 runit.sh - chroot /bocajail "$cdir/runit.sh" - ret=`cat runit.retcode` -else - echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING" - $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh - ret=$? -fi -rm -rf src/ -if [ -f stdout0 ]; then - cat stdout0 -fi -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - exit $ret -fi -ret=`cat compileit.retcode` -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - ret=1 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/bits/compile/java b/boca-1.5.0/doc/problemexamples/bits/compile/java deleted file mode 100644 index dae050e..0000000 --- a/boca-1.5.0/doc/problemexamples/bits/compile/java +++ /dev/null @@ -1,176 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 source_file -# $2 exe_file (default run.jar) -# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition) -# $4 maximum allowed memory (in MBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 -if [ "$1" == "" ]; then - echo "parameter problem" - exit 43 -fi -name="$1" -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -mkdir -p src -if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then - unzip "$name" -d src - if [ "${name##*.}" == "zip" ]; then - name=`basename $name .zip` - else - name=`basename $name .ZIP` - fi -else - mv $name src -fi - -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi - -time=$4 -if [ "$time" -gt "0" ]; then - let "ttime = $time + 30" -else - time=1 - ttime=30 -fi - -maxm=512 -if [ "$4" != "" -a "$4" -gt "0" ]; then -maxm=$4 -fi - -if [ "$2" == "" ]; then - jarfile=run.jar -else - jarfile=$2 -fi - -cdir=`pwd` -echo "Current directory is $cdir" >&2 - -cat <<EOF > compileit.sh -#!/bin/bash -javac=`which javac` -[ -x "\$javac" ] || javac=/usr/bin/javac -if [ ! -x \$javac ]; then - echo "\$javac not found or it's not executable" - exit 47 -fi -jar=`which jar` -[ -x "\$jar" ] || jar=/usr/bin/jar -if [ ! -x \$jar ]; then - echo "\$jar not found or it's not executable" - exit 47 -fi -export CLASSPATH=.:\$CLASSPATH -cd src -if [ -r "$name" ]; then - \$javac -Xmx${maxm}M -Xms${maxm}M "$name" - echo \$? > compileit.retcode -fi -find . -name "*.java" | while read lin; do - \$javac -Xmx${maxm}M -Xms${maxm}M "\$lin" - echo \$? > compileit.retcode -done -rm -f ../$jarfile -\$jar cvf ../$jarfile * -EOF -chmod 755 compileit.sh - -echo $cdir | grep -q "/bocajail" -if [ $? == 0 ]; then - cdir=`echo $cdir | sed "s/.*\/bocajail//"` - cat <<EOF > runit.sh -#!/bin/bash -[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc -#/bin/mount --bind /dev /dev -[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys - -$sf -r1 -t$time -T$ttime -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 ./compileit.sh - -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null -EOF - chmod 755 runit.sh - chroot /bocajail "$cdir/runit.sh" - ret=`cat runit.retcode` -else - echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING" -# $javac "$name" - $sf -r1 -t$time -T$ttime -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 ./compileit.sh - ret=$? -fi -rm -rf src/ -if [ -f stdout0 ]; then - cat stdout0 -fi -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - exit $ret -fi -ret=`cat compileit.retcode` -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - ret=1 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/bits/limits b/boca-1.5.0/doc/problemexamples/bits/limits new file mode 120000 index 0000000..3744764 --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/bits/limits @@ -0,0 +1 @@ +../problemtemplate/limits
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/bits/limits/c b/boca-1.5.0/doc/problemexamples/bits/limits/c deleted file mode 100644 index b48a3b7..0000000 --- a/boca-1.5.0/doc/problemexamples/bits/limits/c +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename -echo 4 -# and the number of repetitions to run within the given timelimit in the second line -echo 10 -# and the maximum amount of memory per repetition in the third line (in Mbytes) -echo 512 -# and shall return zero to indicate no failure -exit 0 -# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be -# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is -# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs -# the value. diff --git a/boca-1.5.0/doc/problemexamples/bits/limits/cpp b/boca-1.5.0/doc/problemexamples/bits/limits/cpp deleted file mode 100644 index b48a3b7..0000000 --- a/boca-1.5.0/doc/problemexamples/bits/limits/cpp +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename -echo 4 -# and the number of repetitions to run within the given timelimit in the second line -echo 10 -# and the maximum amount of memory per repetition in the third line (in Mbytes) -echo 512 -# and shall return zero to indicate no failure -exit 0 -# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be -# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is -# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs -# the value. diff --git a/boca-1.5.0/doc/problemexamples/bits/limits/java b/boca-1.5.0/doc/problemexamples/bits/limits/java deleted file mode 100644 index b48a3b7..0000000 --- a/boca-1.5.0/doc/problemexamples/bits/limits/java +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename -echo 4 -# and the number of repetitions to run within the given timelimit in the second line -echo 10 -# and the maximum amount of memory per repetition in the third line (in Mbytes) -echo 512 -# and shall return zero to indicate no failure -exit 0 -# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be -# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is -# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs -# the value. diff --git a/boca-1.5.0/doc/problemexamples/bits/run b/boca-1.5.0/doc/problemexamples/bits/run new file mode 120000 index 0000000..fd7410f --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/bits/run @@ -0,0 +1 @@ +../problemtemplate/run
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/bits/run/c b/boca-1.5.0/doc/problemexamples/bits/run/c deleted file mode 100755 index d65ed58..0000000 --- a/boca-1.5.0/doc/problemexamples/bits/run/c +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 exe_file -# $2 input_file -# $3 timelimit (limit to run all the repetitions, by default only one repetition) -# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit) -# $5 maximum allowed memory (in KBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec - -if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then - echo "parameter problem" - exit 43 -fi -name=`basename "$1"` -if [ ! -x "$name" ]; then - echo "$1 not found (or is not in the current dir) or it's not executable" - exit 44 -fi -if [ "${name##*.}" != "exe" -a "${name##*.}" != "EXE" ]; then - echo "WARNING: executable file extension is not .exe" -fi -input=`basename "$2"` -if [ ! -r "$input" ]; then - echo "$2 not found (or is not in the current dir) or it's not readable" - exit 45 -fi -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi - -time=$3 -if [ "$time" -gt "0" ]; then - let "ttime = $time + 30" -else - time=1 - ttime=30 -fi - -nruns=1 -if [ "$4" != "" -a "$4" -gt "0" ]; then -nruns=$4 -fi -maxm=512000 -if [ "$5" != "" -a "$5" -gt "0" ]; then -maxm=${5}000 -fi - -rm -f stdin0 2>/dev/null -mv "$input" stdin0 - -rm -f run.exe 2>/dev/null -mv "$name" run.exe -file run.exe | grep -iq "statically linked" -if [ "$?" != "0" ]; then - echo "Aborting because $name is not statically linked" - exit 47 -fi - -cdir=`pwd` -echo "Current directory is $cdir -- chrooting on it" >&2 -$sf -F10 -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe -ret=$? -if [ $ret -gt 10 ]; then - ret=0 -fi -if [ -f stdout0 ]; then - cat stdout0 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/bits/run/cpp b/boca-1.5.0/doc/problemexamples/bits/run/cpp deleted file mode 100755 index 9b2d092..0000000 --- a/boca-1.5.0/doc/problemexamples/bits/run/cpp +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 exe_file -# $2 input_file -# $3 timelimit (limit to run all the repetitions, by default only one repetition) -# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit) -# $5 maximum allowed memory (in KBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec - -if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then - echo "parameter problem" - exit 43 -fi -if [ ! -x "$1" ]; then - echo "$1 not found or it's not executable" - exit 44 -fi -name="$1" -if [ "${name##*.}" != "exe" -a "${name##*.}" != "EXE" ]; then - echo "WARNING: executable file extension is not .exe" -fi -if [ ! -r "$2" ]; then - echo "$2 not found or it's not readable" - exit 45 -fi -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi - -time=$3 -if [ "$time" -gt "0" ]; then - let "ttime = $time + 30" -else - time=1 - ttime=30 -fi - -nruns=1 -if [ "$4" != "" -a "$4" -gt "0" ]; then -nruns=$4 -fi -maxm=512000 -if [ "$5" != "" -a "$5" -gt "0" ]; then -maxm=${5}000 -fi - -rm -f stdin0 2>/dev/null -mv "$2" stdin0 - -rm -f run.exe 2>/dev/null -mv "$name" run.exe -file run.exe | grep -iq "statically linked" -if [ "$?" != "0" ]; then - echo "Aborting because $name is not statically linked" - exit 47 -fi - -cdir=`pwd` -echo "Current directory is $cdir -- chrooting on it" >&2 -$sf -F10 -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe -ret=$? -if [ $ret -gt 10 ]; then - ret=0 -fi -if [ -f stdout0 ]; then - cat stdout0 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/bits/run/java b/boca-1.5.0/doc/problemexamples/bits/run/java deleted file mode 100755 index 945f15d..0000000 --- a/boca-1.5.0/doc/problemexamples/bits/run/java +++ /dev/null @@ -1,163 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 main_class -# $2 input_file -# $3 timelimit (limit to run all the repetitions, by default only one repetition) -# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit) -# $5 maximum allowed memory (in KBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec - -if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then - echo "parameter problem" - exit 43 -fi -if [ ! -r run.jar ]; then - echo "ERROR: file run.jar not found - possible error during compilation" - exit 1 -fi -name="$1" -if [ "${name##*.}" == "class" -a "${name##*.}" == "CLASS" ]; then - echo "WARNING: removing .class file extension" -fi -if [ "${name##*.}" == "class" ]; then - name=`basename "$1" .class` -fi -if [ "${name##*.}" == "CLASS" ]; then - name=`basename "$1" .CLASS` -fi -input=`basename "$2"` -if [ ! -r "$input" ]; then - echo "$2 not found (or is not in the current dir) or it's not readable" - exit 45 -fi -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi - -time=$3 -if [ "$time" -gt "0" ]; then - let "ttime = $time + 30" -else - time=1 - ttime=30 -fi - -nruns=1 -if [ "$4" != "" -a "$4" -gt "0" ]; then -nruns=$4 -fi -maxm=512 -if [ "$5" != "" -a "$5" -gt "0" ]; then -maxm=${5} -fi - -rm -f stdin0 2>/dev/null -mv "$input" stdin0 - -cdir=`pwd` -echo "Current directory is $cdir" >&2 -echo $cdir | grep -q "/bocajail" -if [ $? == 0 ]; then - cdir=`echo $cdir | sed "s/.*\/bocajail//"` - cat <<EOF > runit.sh -#!/bin/bash -[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc -#/bin/mount --bind /dev /dev -[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys -java=`which java` -[ -x "$java" ] || java=/usr/bin/java -if [ ! -x $java ]; then - echo "$java not found or it's not executable" - exit 47 -fi -export CLASSPATH=.:./run.jar:$CLASSPATH -cd $cdir -$sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 -- $java -Xmx${maxm}M -Xms${maxm}M "$name" -echo \$? > runit.retcode -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null -EOF - chmod 755 runit.sh - chroot /bocajail $cdir/runit.sh - ret=`cat runit.retcode` - if [ "$ret" == "" ]; then - echo "Execution error - check autojudging" - exit 49 - fi - if [ $ret -gt 10 ]; then - echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <" - exit 9 - fi - else - echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 - echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 - echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 -# $java "$name" < stdin0 - $sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 -- $java -cp run.jar -Xmx${maxm}M -Xms${maxm}M "$name" - ret=$? - fi - if [ $ret -gt 10 ]; then - echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <" - ret=9 - fi -fi -if [ -f stdout0 ]; then - cat stdout0 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/bits/tests b/boca-1.5.0/doc/problemexamples/bits/tests new file mode 120000 index 0000000..7ef2d62 --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/bits/tests @@ -0,0 +1 @@ +../problemtemplate/tests
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/bits/tests/c b/boca-1.5.0/doc/problemexamples/bits/tests/c deleted file mode 100755 index 1a0ca95..0000000 --- a/boca-1.5.0/doc/problemexamples/bits/tests/c +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -cat > test.c <<EOF -int main() { - char s[100]; - scanf("%s", s); - printf("%s\n",s); - return 0; -} -EOF -cat > test.in <<EOF -inputdata -EOF - -TL=2 -REP=10 -../compile/c test.c test.exe TL -../run/c test.exe test.in TL REP -output=`cat stdout0` -if [ "$output" != "inputdata" ]; then - echo "ERROR" - exit 1 -fi -exit 0 diff --git a/boca-1.5.0/doc/problemexamples/formiga/compare b/boca-1.5.0/doc/problemexamples/formiga/compare new file mode 120000 index 0000000..934e331 --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/formiga/compare @@ -0,0 +1 @@ +../problemtemplate/compare
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/formiga/compare/c b/boca-1.5.0/doc/problemexamples/formiga/compare/c deleted file mode 100755 index 4998be3..0000000 --- a/boca-1.5.0/doc/problemexamples/formiga/compare/c +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -# // Last modified 21/jul/2012 by cassio@ime.usp.br -# -# This script receives: -# $1 team_output -# $2 sol_output -# $3 problem_input (might be used by some specific checkers, here it is not) -# -# BOCA reads the last line of the standard output -# and pass it to judges -# -if [ ! -r "$1" -o ! -r "$2" ]; then - echo "Parameter problem" - exit 43 -fi - -# Next lines of this script just compares team_output and sol_output, -# although it is possible to change them to more complex evaluations. - -diff -q "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff \"$1\" \"$2\" # files match" - echo "Files match exactly" - exit 4 -fi -diff -q -b "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b \"$1\" \"$2\" # files match" - echo -e "diff -c \"$1\" \"$2\" # files dont match - see output" - diff -c "$1" "$2" - echo "Files match with differences in the amount of white spaces" - exit 5 -fi -diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output" - diff -c -b "$1" "$2" - echo "Files match with differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B "$1" "$2" - echo "Files match if we ignore case and differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B "$1" "$2" - echo "Files match if we discard all white spaces" - exit 5 -fi -diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B -w "$1" "$2" - echo "Files match if we ignore case and discard all white spaces" - exit 5 -fi -wd=`which wdiff` -if [ "$wd" != "" ]; then - wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null - if [ "$?" == "0" ]; then - echo -e "wdiff \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B -w "$1" "$2" - echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff" - echo "diff has a bug that, if a line contains a single space, this is not discarded by -w" - exit 5 - fi -fi -echo -e "### files dont match - see output" -diff -c -i -b -B -w "$1" "$2" -echo "Differences found" -exit 6 diff --git a/boca-1.5.0/doc/problemexamples/formiga/compare/cpp b/boca-1.5.0/doc/problemexamples/formiga/compare/cpp deleted file mode 100755 index 4998be3..0000000 --- a/boca-1.5.0/doc/problemexamples/formiga/compare/cpp +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -# // Last modified 21/jul/2012 by cassio@ime.usp.br -# -# This script receives: -# $1 team_output -# $2 sol_output -# $3 problem_input (might be used by some specific checkers, here it is not) -# -# BOCA reads the last line of the standard output -# and pass it to judges -# -if [ ! -r "$1" -o ! -r "$2" ]; then - echo "Parameter problem" - exit 43 -fi - -# Next lines of this script just compares team_output and sol_output, -# although it is possible to change them to more complex evaluations. - -diff -q "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff \"$1\" \"$2\" # files match" - echo "Files match exactly" - exit 4 -fi -diff -q -b "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b \"$1\" \"$2\" # files match" - echo -e "diff -c \"$1\" \"$2\" # files dont match - see output" - diff -c "$1" "$2" - echo "Files match with differences in the amount of white spaces" - exit 5 -fi -diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output" - diff -c -b "$1" "$2" - echo "Files match with differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B "$1" "$2" - echo "Files match if we ignore case and differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B "$1" "$2" - echo "Files match if we discard all white spaces" - exit 5 -fi -diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B -w "$1" "$2" - echo "Files match if we ignore case and discard all white spaces" - exit 5 -fi -wd=`which wdiff` -if [ "$wd" != "" ]; then - wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null - if [ "$?" == "0" ]; then - echo -e "wdiff \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B -w "$1" "$2" - echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff" - echo "diff has a bug that, if a line contains a single space, this is not discarded by -w" - exit 5 - fi -fi -echo -e "### files dont match - see output" -diff -c -i -b -B -w "$1" "$2" -echo "Differences found" -exit 6 diff --git a/boca-1.5.0/doc/problemexamples/formiga/compare/java b/boca-1.5.0/doc/problemexamples/formiga/compare/java deleted file mode 100755 index 4998be3..0000000 --- a/boca-1.5.0/doc/problemexamples/formiga/compare/java +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -# // Last modified 21/jul/2012 by cassio@ime.usp.br -# -# This script receives: -# $1 team_output -# $2 sol_output -# $3 problem_input (might be used by some specific checkers, here it is not) -# -# BOCA reads the last line of the standard output -# and pass it to judges -# -if [ ! -r "$1" -o ! -r "$2" ]; then - echo "Parameter problem" - exit 43 -fi - -# Next lines of this script just compares team_output and sol_output, -# although it is possible to change them to more complex evaluations. - -diff -q "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff \"$1\" \"$2\" # files match" - echo "Files match exactly" - exit 4 -fi -diff -q -b "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b \"$1\" \"$2\" # files match" - echo -e "diff -c \"$1\" \"$2\" # files dont match - see output" - diff -c "$1" "$2" - echo "Files match with differences in the amount of white spaces" - exit 5 -fi -diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output" - diff -c -b "$1" "$2" - echo "Files match with differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B "$1" "$2" - echo "Files match if we ignore case and differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B "$1" "$2" - echo "Files match if we discard all white spaces" - exit 5 -fi -diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B -w "$1" "$2" - echo "Files match if we ignore case and discard all white spaces" - exit 5 -fi -wd=`which wdiff` -if [ "$wd" != "" ]; then - wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null - if [ "$?" == "0" ]; then - echo -e "wdiff \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B -w "$1" "$2" - echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff" - echo "diff has a bug that, if a line contains a single space, this is not discarded by -w" - exit 5 - fi -fi -echo -e "### files dont match - see output" -diff -c -i -b -B -w "$1" "$2" -echo "Differences found" -exit 6 diff --git a/boca-1.5.0/doc/problemexamples/formiga/compile b/boca-1.5.0/doc/problemexamples/formiga/compile new file mode 120000 index 0000000..83641d6 --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/formiga/compile @@ -0,0 +1 @@ +../problemtemplate/compile
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/formiga/compile/c b/boca-1.5.0/doc/problemexamples/formiga/compile/c deleted file mode 100644 index 04a08e9..0000000 --- a/boca-1.5.0/doc/problemexamples/formiga/compile/c +++ /dev/null @@ -1,159 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 source_file -# $2 exe_file (default run.exe) -# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition) -# $4 maximum allowed memory (in MBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 - -if [ "$1" == "" ]; then - echo "parameter problem" - exit 43 -fi -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -name="$1" -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -mkdir -p src -if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then - unzip "$name" -d src - name="*.c" -else - mv $name src -fi -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi -maxm=512000 -if [ "$4" != "" -a "$4" -gt "0" ]; then -maxm=${4}000 -fi - -# setting up the timelimit according to the problem -if [ "$3" == "" ]; then -time=5 -else -time=$3 -fi -let ttime=$time+30 - -if [ "$2" == "" ]; then - exe=run.exe -else - exe=$2 -fi - -rm -f ../$exe 2>/dev/null -cat <<EOF > compileit.sh -#!/bin/bash -cc=\`which gcc\` -[ -x "\$cc" ] || cc=/usr/bin/gcc -if [ ! -x "\$cc" ]; then - echo "\$cc not found or it's not executable" - exit 47 -fi -cd src -"\$cc" -static -O2 -lm -o ../$exe "$name" -echo \$? > compileit.retcode -exit 0 -EOF -chmod 755 compileit.sh - -cdir=`pwd` -echo "Current directory is $cdir" >&2 -echo $cdir | grep -q "/bocajail" -if [ $? == 0 ]; then - cdir=`echo $cdir | sed "s/.*\/bocajail//"` - cat <<EOF > runit.sh -#!/bin/bash -[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc -#/bin/mount --bind /dev /dev -[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys -$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh -echo \$? > runit.retcode -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null -EOF - chmod 755 runit.sh - chroot /bocajail "$cdir/runit.sh" - ret=`cat runit.retcode` -else - echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING" - $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh - ret=$? -fi -rm -rf src/ -if [ -f stdout0 ]; then - cat stdout0 -fi -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - exit $ret -fi -ret=`cat compileit.retcode` -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - ret=1 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/formiga/compile/cpp b/boca-1.5.0/doc/problemexamples/formiga/compile/cpp deleted file mode 100644 index 2ec55ac..0000000 --- a/boca-1.5.0/doc/problemexamples/formiga/compile/cpp +++ /dev/null @@ -1,159 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 source_file -# $2 exe_file (default run.exe) -# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition) -# $4 maximum allowed memory (in MBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 - -if [ "$1" == "" ]; then - echo "parameter problem" - exit 43 -fi -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -name="$1" -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -mkdir -p src -if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then - unzip "$name" -d src - name="*.c" -else - mv $name src -fi -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi -maxm=512000 -if [ "$4" != "" -a "$4" -gt "0" ]; then -maxm=${4}000 -fi - -# setting up the timelimit according to the problem -if [ "$3" == "" ]; then -time=5 -else -time=$3 -fi -let ttime=$time+30 - -if [ "$2" == "" ]; then - exe=run.exe -else - exe=$2 -fi - -rm -f ../$exe 2>/dev/null -cat <<EOF > compileit.sh -#!/bin/bash -cc=\`which g++\` -[ -x "\$cc" ] || cc=/usr/bin/g++ -if [ ! -x "\$cc" ]; then - echo "\$cc not found or it's not executable" - exit 47 -fi -cd src -"\$cc" -static -O2 -lm -o ../$exe "$name" -echo \$? > compileit.retcode -exit 0 -EOF -chmod 755 compileit.sh - -cdir=`pwd` -echo "Current directory is $cdir" >&2 -echo $cdir | grep -q "/bocajail" -if [ $? == 0 ]; then - cdir=`echo $cdir | sed "s/.*\/bocajail//"` - cat <<EOF > runit.sh -#!/bin/bash -[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc -#/bin/mount --bind /dev /dev -[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys -$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh -echo \$? > runit.retcode -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null -EOF - chmod 755 runit.sh - chroot /bocajail "$cdir/runit.sh" - ret=`cat runit.retcode` -else - echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING" - $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh - ret=$? -fi -rm -rf src/ -if [ -f stdout0 ]; then - cat stdout0 -fi -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - exit $ret -fi -ret=`cat compileit.retcode` -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - ret=1 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/formiga/compile/java b/boca-1.5.0/doc/problemexamples/formiga/compile/java deleted file mode 100644 index dae050e..0000000 --- a/boca-1.5.0/doc/problemexamples/formiga/compile/java +++ /dev/null @@ -1,176 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 source_file -# $2 exe_file (default run.jar) -# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition) -# $4 maximum allowed memory (in MBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 -if [ "$1" == "" ]; then - echo "parameter problem" - exit 43 -fi -name="$1" -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -mkdir -p src -if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then - unzip "$name" -d src - if [ "${name##*.}" == "zip" ]; then - name=`basename $name .zip` - else - name=`basename $name .ZIP` - fi -else - mv $name src -fi - -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi - -time=$4 -if [ "$time" -gt "0" ]; then - let "ttime = $time + 30" -else - time=1 - ttime=30 -fi - -maxm=512 -if [ "$4" != "" -a "$4" -gt "0" ]; then -maxm=$4 -fi - -if [ "$2" == "" ]; then - jarfile=run.jar -else - jarfile=$2 -fi - -cdir=`pwd` -echo "Current directory is $cdir" >&2 - -cat <<EOF > compileit.sh -#!/bin/bash -javac=`which javac` -[ -x "\$javac" ] || javac=/usr/bin/javac -if [ ! -x \$javac ]; then - echo "\$javac not found or it's not executable" - exit 47 -fi -jar=`which jar` -[ -x "\$jar" ] || jar=/usr/bin/jar -if [ ! -x \$jar ]; then - echo "\$jar not found or it's not executable" - exit 47 -fi -export CLASSPATH=.:\$CLASSPATH -cd src -if [ -r "$name" ]; then - \$javac -Xmx${maxm}M -Xms${maxm}M "$name" - echo \$? > compileit.retcode -fi -find . -name "*.java" | while read lin; do - \$javac -Xmx${maxm}M -Xms${maxm}M "\$lin" - echo \$? > compileit.retcode -done -rm -f ../$jarfile -\$jar cvf ../$jarfile * -EOF -chmod 755 compileit.sh - -echo $cdir | grep -q "/bocajail" -if [ $? == 0 ]; then - cdir=`echo $cdir | sed "s/.*\/bocajail//"` - cat <<EOF > runit.sh -#!/bin/bash -[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc -#/bin/mount --bind /dev /dev -[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys - -$sf -r1 -t$time -T$ttime -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 ./compileit.sh - -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null -EOF - chmod 755 runit.sh - chroot /bocajail "$cdir/runit.sh" - ret=`cat runit.retcode` -else - echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING" -# $javac "$name" - $sf -r1 -t$time -T$ttime -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 ./compileit.sh - ret=$? -fi -rm -rf src/ -if [ -f stdout0 ]; then - cat stdout0 -fi -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - exit $ret -fi -ret=`cat compileit.retcode` -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - ret=1 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/formiga/limits b/boca-1.5.0/doc/problemexamples/formiga/limits new file mode 120000 index 0000000..3744764 --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/formiga/limits @@ -0,0 +1 @@ +../problemtemplate/limits
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/formiga/limits/c b/boca-1.5.0/doc/problemexamples/formiga/limits/c deleted file mode 100644 index b48a3b7..0000000 --- a/boca-1.5.0/doc/problemexamples/formiga/limits/c +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename -echo 4 -# and the number of repetitions to run within the given timelimit in the second line -echo 10 -# and the maximum amount of memory per repetition in the third line (in Mbytes) -echo 512 -# and shall return zero to indicate no failure -exit 0 -# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be -# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is -# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs -# the value. diff --git a/boca-1.5.0/doc/problemexamples/formiga/limits/cpp b/boca-1.5.0/doc/problemexamples/formiga/limits/cpp deleted file mode 100644 index b48a3b7..0000000 --- a/boca-1.5.0/doc/problemexamples/formiga/limits/cpp +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename -echo 4 -# and the number of repetitions to run within the given timelimit in the second line -echo 10 -# and the maximum amount of memory per repetition in the third line (in Mbytes) -echo 512 -# and shall return zero to indicate no failure -exit 0 -# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be -# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is -# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs -# the value. diff --git a/boca-1.5.0/doc/problemexamples/formiga/limits/java b/boca-1.5.0/doc/problemexamples/formiga/limits/java deleted file mode 100644 index b48a3b7..0000000 --- a/boca-1.5.0/doc/problemexamples/formiga/limits/java +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename -echo 4 -# and the number of repetitions to run within the given timelimit in the second line -echo 10 -# and the maximum amount of memory per repetition in the third line (in Mbytes) -echo 512 -# and shall return zero to indicate no failure -exit 0 -# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be -# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is -# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs -# the value. diff --git a/boca-1.5.0/doc/problemexamples/formiga/run b/boca-1.5.0/doc/problemexamples/formiga/run new file mode 120000 index 0000000..fd7410f --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/formiga/run @@ -0,0 +1 @@ +../problemtemplate/run
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/formiga/run/c b/boca-1.5.0/doc/problemexamples/formiga/run/c deleted file mode 100755 index d65ed58..0000000 --- a/boca-1.5.0/doc/problemexamples/formiga/run/c +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 exe_file -# $2 input_file -# $3 timelimit (limit to run all the repetitions, by default only one repetition) -# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit) -# $5 maximum allowed memory (in KBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec - -if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then - echo "parameter problem" - exit 43 -fi -name=`basename "$1"` -if [ ! -x "$name" ]; then - echo "$1 not found (or is not in the current dir) or it's not executable" - exit 44 -fi -if [ "${name##*.}" != "exe" -a "${name##*.}" != "EXE" ]; then - echo "WARNING: executable file extension is not .exe" -fi -input=`basename "$2"` -if [ ! -r "$input" ]; then - echo "$2 not found (or is not in the current dir) or it's not readable" - exit 45 -fi -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi - -time=$3 -if [ "$time" -gt "0" ]; then - let "ttime = $time + 30" -else - time=1 - ttime=30 -fi - -nruns=1 -if [ "$4" != "" -a "$4" -gt "0" ]; then -nruns=$4 -fi -maxm=512000 -if [ "$5" != "" -a "$5" -gt "0" ]; then -maxm=${5}000 -fi - -rm -f stdin0 2>/dev/null -mv "$input" stdin0 - -rm -f run.exe 2>/dev/null -mv "$name" run.exe -file run.exe | grep -iq "statically linked" -if [ "$?" != "0" ]; then - echo "Aborting because $name is not statically linked" - exit 47 -fi - -cdir=`pwd` -echo "Current directory is $cdir -- chrooting on it" >&2 -$sf -F10 -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe -ret=$? -if [ $ret -gt 10 ]; then - ret=0 -fi -if [ -f stdout0 ]; then - cat stdout0 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/formiga/run/cpp b/boca-1.5.0/doc/problemexamples/formiga/run/cpp deleted file mode 100755 index 9b2d092..0000000 --- a/boca-1.5.0/doc/problemexamples/formiga/run/cpp +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 exe_file -# $2 input_file -# $3 timelimit (limit to run all the repetitions, by default only one repetition) -# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit) -# $5 maximum allowed memory (in KBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec - -if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then - echo "parameter problem" - exit 43 -fi -if [ ! -x "$1" ]; then - echo "$1 not found or it's not executable" - exit 44 -fi -name="$1" -if [ "${name##*.}" != "exe" -a "${name##*.}" != "EXE" ]; then - echo "WARNING: executable file extension is not .exe" -fi -if [ ! -r "$2" ]; then - echo "$2 not found or it's not readable" - exit 45 -fi -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi - -time=$3 -if [ "$time" -gt "0" ]; then - let "ttime = $time + 30" -else - time=1 - ttime=30 -fi - -nruns=1 -if [ "$4" != "" -a "$4" -gt "0" ]; then -nruns=$4 -fi -maxm=512000 -if [ "$5" != "" -a "$5" -gt "0" ]; then -maxm=${5}000 -fi - -rm -f stdin0 2>/dev/null -mv "$2" stdin0 - -rm -f run.exe 2>/dev/null -mv "$name" run.exe -file run.exe | grep -iq "statically linked" -if [ "$?" != "0" ]; then - echo "Aborting because $name is not statically linked" - exit 47 -fi - -cdir=`pwd` -echo "Current directory is $cdir -- chrooting on it" >&2 -$sf -F10 -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe -ret=$? -if [ $ret -gt 10 ]; then - ret=0 -fi -if [ -f stdout0 ]; then - cat stdout0 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/formiga/run/java b/boca-1.5.0/doc/problemexamples/formiga/run/java deleted file mode 100755 index 945f15d..0000000 --- a/boca-1.5.0/doc/problemexamples/formiga/run/java +++ /dev/null @@ -1,163 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 main_class -# $2 input_file -# $3 timelimit (limit to run all the repetitions, by default only one repetition) -# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit) -# $5 maximum allowed memory (in KBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec - -if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then - echo "parameter problem" - exit 43 -fi -if [ ! -r run.jar ]; then - echo "ERROR: file run.jar not found - possible error during compilation" - exit 1 -fi -name="$1" -if [ "${name##*.}" == "class" -a "${name##*.}" == "CLASS" ]; then - echo "WARNING: removing .class file extension" -fi -if [ "${name##*.}" == "class" ]; then - name=`basename "$1" .class` -fi -if [ "${name##*.}" == "CLASS" ]; then - name=`basename "$1" .CLASS` -fi -input=`basename "$2"` -if [ ! -r "$input" ]; then - echo "$2 not found (or is not in the current dir) or it's not readable" - exit 45 -fi -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi - -time=$3 -if [ "$time" -gt "0" ]; then - let "ttime = $time + 30" -else - time=1 - ttime=30 -fi - -nruns=1 -if [ "$4" != "" -a "$4" -gt "0" ]; then -nruns=$4 -fi -maxm=512 -if [ "$5" != "" -a "$5" -gt "0" ]; then -maxm=${5} -fi - -rm -f stdin0 2>/dev/null -mv "$input" stdin0 - -cdir=`pwd` -echo "Current directory is $cdir" >&2 -echo $cdir | grep -q "/bocajail" -if [ $? == 0 ]; then - cdir=`echo $cdir | sed "s/.*\/bocajail//"` - cat <<EOF > runit.sh -#!/bin/bash -[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc -#/bin/mount --bind /dev /dev -[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys -java=`which java` -[ -x "$java" ] || java=/usr/bin/java -if [ ! -x $java ]; then - echo "$java not found or it's not executable" - exit 47 -fi -export CLASSPATH=.:./run.jar:$CLASSPATH -cd $cdir -$sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 -- $java -Xmx${maxm}M -Xms${maxm}M "$name" -echo \$? > runit.retcode -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null -EOF - chmod 755 runit.sh - chroot /bocajail $cdir/runit.sh - ret=`cat runit.retcode` - if [ "$ret" == "" ]; then - echo "Execution error - check autojudging" - exit 49 - fi - if [ $ret -gt 10 ]; then - echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <" - exit 9 - fi - else - echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 - echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 - echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 -# $java "$name" < stdin0 - $sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 -- $java -cp run.jar -Xmx${maxm}M -Xms${maxm}M "$name" - ret=$? - fi - if [ $ret -gt 10 ]; then - echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <" - ret=9 - fi -fi -if [ -f stdout0 ]; then - cat stdout0 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/formiga/tests b/boca-1.5.0/doc/problemexamples/formiga/tests new file mode 120000 index 0000000..7ef2d62 --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/formiga/tests @@ -0,0 +1 @@ +../problemtemplate/tests
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/formiga/tests/c b/boca-1.5.0/doc/problemexamples/formiga/tests/c deleted file mode 100755 index 1a0ca95..0000000 --- a/boca-1.5.0/doc/problemexamples/formiga/tests/c +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -cat > test.c <<EOF -int main() { - char s[100]; - scanf("%s", s); - printf("%s\n",s); - return 0; -} -EOF -cat > test.in <<EOF -inputdata -EOF - -TL=2 -REP=10 -../compile/c test.c test.exe TL -../run/c test.exe test.in TL REP -output=`cat stdout0` -if [ "$output" != "inputdata" ]; then - echo "ERROR" - exit 1 -fi -exit 0 diff --git a/boca-1.5.0/doc/problemexamples/gen_examples.sh b/boca-1.5.0/doc/problemexamples/gen_examples.sh new file mode 100644 index 0000000..e25f7e7 --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/gen_examples.sh @@ -0,0 +1,6 @@ +#!/bin/bash +rm -f keys.txt +../../src/private/createproblemzip.php abacaxi A.problem.zip password | grep -A2 "The following line" | tail -n1 >> keys.txt +../../src/private/createproblemzip.php bits B.problem.zip password | grep -A2 "The following line" | tail -n1 >> keys.txt +../../src/private/createproblemzip.php formiga C.problem.zip password | grep -A2 "The following line" | tail -n1 >> keys.txt +../../src/private/createproblemzip.php multas D.problem.zip password | grep -A2 "The following line" | tail -n1 >> keys.txt diff --git a/boca-1.5.0/doc/problemexamples/multas/compare b/boca-1.5.0/doc/problemexamples/multas/compare new file mode 120000 index 0000000..934e331 --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/multas/compare @@ -0,0 +1 @@ +../problemtemplate/compare
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/multas/compare/c b/boca-1.5.0/doc/problemexamples/multas/compare/c deleted file mode 100755 index 4998be3..0000000 --- a/boca-1.5.0/doc/problemexamples/multas/compare/c +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -# // Last modified 21/jul/2012 by cassio@ime.usp.br -# -# This script receives: -# $1 team_output -# $2 sol_output -# $3 problem_input (might be used by some specific checkers, here it is not) -# -# BOCA reads the last line of the standard output -# and pass it to judges -# -if [ ! -r "$1" -o ! -r "$2" ]; then - echo "Parameter problem" - exit 43 -fi - -# Next lines of this script just compares team_output and sol_output, -# although it is possible to change them to more complex evaluations. - -diff -q "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff \"$1\" \"$2\" # files match" - echo "Files match exactly" - exit 4 -fi -diff -q -b "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b \"$1\" \"$2\" # files match" - echo -e "diff -c \"$1\" \"$2\" # files dont match - see output" - diff -c "$1" "$2" - echo "Files match with differences in the amount of white spaces" - exit 5 -fi -diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output" - diff -c -b "$1" "$2" - echo "Files match with differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B "$1" "$2" - echo "Files match if we ignore case and differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B "$1" "$2" - echo "Files match if we discard all white spaces" - exit 5 -fi -diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B -w "$1" "$2" - echo "Files match if we ignore case and discard all white spaces" - exit 5 -fi -wd=`which wdiff` -if [ "$wd" != "" ]; then - wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null - if [ "$?" == "0" ]; then - echo -e "wdiff \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B -w "$1" "$2" - echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff" - echo "diff has a bug that, if a line contains a single space, this is not discarded by -w" - exit 5 - fi -fi -echo -e "### files dont match - see output" -diff -c -i -b -B -w "$1" "$2" -echo "Differences found" -exit 6 diff --git a/boca-1.5.0/doc/problemexamples/multas/compare/cpp b/boca-1.5.0/doc/problemexamples/multas/compare/cpp deleted file mode 100755 index 4998be3..0000000 --- a/boca-1.5.0/doc/problemexamples/multas/compare/cpp +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -# // Last modified 21/jul/2012 by cassio@ime.usp.br -# -# This script receives: -# $1 team_output -# $2 sol_output -# $3 problem_input (might be used by some specific checkers, here it is not) -# -# BOCA reads the last line of the standard output -# and pass it to judges -# -if [ ! -r "$1" -o ! -r "$2" ]; then - echo "Parameter problem" - exit 43 -fi - -# Next lines of this script just compares team_output and sol_output, -# although it is possible to change them to more complex evaluations. - -diff -q "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff \"$1\" \"$2\" # files match" - echo "Files match exactly" - exit 4 -fi -diff -q -b "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b \"$1\" \"$2\" # files match" - echo -e "diff -c \"$1\" \"$2\" # files dont match - see output" - diff -c "$1" "$2" - echo "Files match with differences in the amount of white spaces" - exit 5 -fi -diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output" - diff -c -b "$1" "$2" - echo "Files match with differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B "$1" "$2" - echo "Files match if we ignore case and differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B "$1" "$2" - echo "Files match if we discard all white spaces" - exit 5 -fi -diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B -w "$1" "$2" - echo "Files match if we ignore case and discard all white spaces" - exit 5 -fi -wd=`which wdiff` -if [ "$wd" != "" ]; then - wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null - if [ "$?" == "0" ]; then - echo -e "wdiff \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B -w "$1" "$2" - echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff" - echo "diff has a bug that, if a line contains a single space, this is not discarded by -w" - exit 5 - fi -fi -echo -e "### files dont match - see output" -diff -c -i -b -B -w "$1" "$2" -echo "Differences found" -exit 6 diff --git a/boca-1.5.0/doc/problemexamples/multas/compare/java b/boca-1.5.0/doc/problemexamples/multas/compare/java deleted file mode 100755 index 4998be3..0000000 --- a/boca-1.5.0/doc/problemexamples/multas/compare/java +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -# // Last modified 21/jul/2012 by cassio@ime.usp.br -# -# This script receives: -# $1 team_output -# $2 sol_output -# $3 problem_input (might be used by some specific checkers, here it is not) -# -# BOCA reads the last line of the standard output -# and pass it to judges -# -if [ ! -r "$1" -o ! -r "$2" ]; then - echo "Parameter problem" - exit 43 -fi - -# Next lines of this script just compares team_output and sol_output, -# although it is possible to change them to more complex evaluations. - -diff -q "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff \"$1\" \"$2\" # files match" - echo "Files match exactly" - exit 4 -fi -diff -q -b "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b \"$1\" \"$2\" # files match" - echo -e "diff -c \"$1\" \"$2\" # files dont match - see output" - diff -c "$1" "$2" - echo "Files match with differences in the amount of white spaces" - exit 5 -fi -diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output" - diff -c -b "$1" "$2" - echo "Files match with differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B "$1" "$2" - echo "Files match if we ignore case and differences in the amount of white spaces and blank lines" - exit 5 -fi -diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B "$1" "$2" - echo "Files match if we discard all white spaces" - exit 5 -fi -diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null -if [ "$?" == "0" ]; then - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match" - echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -b -B -w "$1" "$2" - echo "Files match if we ignore case and discard all white spaces" - exit 5 -fi -wd=`which wdiff` -if [ "$wd" != "" ]; then - wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null - if [ "$?" == "0" ]; then - echo -e "wdiff \"$1\" \"$2\" # files match" - echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output" - diff -c -i -b -B -w "$1" "$2" - echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff" - echo "diff has a bug that, if a line contains a single space, this is not discarded by -w" - exit 5 - fi -fi -echo -e "### files dont match - see output" -diff -c -i -b -B -w "$1" "$2" -echo "Differences found" -exit 6 diff --git a/boca-1.5.0/doc/problemexamples/multas/compile b/boca-1.5.0/doc/problemexamples/multas/compile new file mode 120000 index 0000000..83641d6 --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/multas/compile @@ -0,0 +1 @@ +../problemtemplate/compile
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/multas/compile/c b/boca-1.5.0/doc/problemexamples/multas/compile/c deleted file mode 100644 index 04a08e9..0000000 --- a/boca-1.5.0/doc/problemexamples/multas/compile/c +++ /dev/null @@ -1,159 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 source_file -# $2 exe_file (default run.exe) -# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition) -# $4 maximum allowed memory (in MBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 - -if [ "$1" == "" ]; then - echo "parameter problem" - exit 43 -fi -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -name="$1" -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -mkdir -p src -if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then - unzip "$name" -d src - name="*.c" -else - mv $name src -fi -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi -maxm=512000 -if [ "$4" != "" -a "$4" -gt "0" ]; then -maxm=${4}000 -fi - -# setting up the timelimit according to the problem -if [ "$3" == "" ]; then -time=5 -else -time=$3 -fi -let ttime=$time+30 - -if [ "$2" == "" ]; then - exe=run.exe -else - exe=$2 -fi - -rm -f ../$exe 2>/dev/null -cat <<EOF > compileit.sh -#!/bin/bash -cc=\`which gcc\` -[ -x "\$cc" ] || cc=/usr/bin/gcc -if [ ! -x "\$cc" ]; then - echo "\$cc not found or it's not executable" - exit 47 -fi -cd src -"\$cc" -static -O2 -lm -o ../$exe "$name" -echo \$? > compileit.retcode -exit 0 -EOF -chmod 755 compileit.sh - -cdir=`pwd` -echo "Current directory is $cdir" >&2 -echo $cdir | grep -q "/bocajail" -if [ $? == 0 ]; then - cdir=`echo $cdir | sed "s/.*\/bocajail//"` - cat <<EOF > runit.sh -#!/bin/bash -[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc -#/bin/mount --bind /dev /dev -[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys -$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh -echo \$? > runit.retcode -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null -EOF - chmod 755 runit.sh - chroot /bocajail "$cdir/runit.sh" - ret=`cat runit.retcode` -else - echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING" - $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh - ret=$? -fi -rm -rf src/ -if [ -f stdout0 ]; then - cat stdout0 -fi -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - exit $ret -fi -ret=`cat compileit.retcode` -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - ret=1 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/multas/compile/cpp b/boca-1.5.0/doc/problemexamples/multas/compile/cpp deleted file mode 100644 index 2ec55ac..0000000 --- a/boca-1.5.0/doc/problemexamples/multas/compile/cpp +++ /dev/null @@ -1,159 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 source_file -# $2 exe_file (default run.exe) -# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition) -# $4 maximum allowed memory (in MBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 - -if [ "$1" == "" ]; then - echo "parameter problem" - exit 43 -fi -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -name="$1" -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -mkdir -p src -if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then - unzip "$name" -d src - name="*.c" -else - mv $name src -fi -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi -maxm=512000 -if [ "$4" != "" -a "$4" -gt "0" ]; then -maxm=${4}000 -fi - -# setting up the timelimit according to the problem -if [ "$3" == "" ]; then -time=5 -else -time=$3 -fi -let ttime=$time+30 - -if [ "$2" == "" ]; then - exe=run.exe -else - exe=$2 -fi - -rm -f ../$exe 2>/dev/null -cat <<EOF > compileit.sh -#!/bin/bash -cc=\`which g++\` -[ -x "\$cc" ] || cc=/usr/bin/g++ -if [ ! -x "\$cc" ]; then - echo "\$cc not found or it's not executable" - exit 47 -fi -cd src -"\$cc" -static -O2 -lm -o ../$exe "$name" -echo \$? > compileit.retcode -exit 0 -EOF -chmod 755 compileit.sh - -cdir=`pwd` -echo "Current directory is $cdir" >&2 -echo $cdir | grep -q "/bocajail" -if [ $? == 0 ]; then - cdir=`echo $cdir | sed "s/.*\/bocajail//"` - cat <<EOF > runit.sh -#!/bin/bash -[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc -#/bin/mount --bind /dev /dev -[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys -$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh -echo \$? > runit.retcode -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null -EOF - chmod 755 runit.sh - chroot /bocajail "$cdir/runit.sh" - ret=`cat runit.retcode` -else - echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING" - $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh - ret=$? -fi -rm -rf src/ -if [ -f stdout0 ]; then - cat stdout0 -fi -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - exit $ret -fi -ret=`cat compileit.retcode` -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - ret=1 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/multas/compile/java b/boca-1.5.0/doc/problemexamples/multas/compile/java deleted file mode 100644 index dae050e..0000000 --- a/boca-1.5.0/doc/problemexamples/multas/compile/java +++ /dev/null @@ -1,176 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 source_file -# $2 exe_file (default run.jar) -# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition) -# $4 maximum allowed memory (in MBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 -if [ "$1" == "" ]; then - echo "parameter problem" - exit 43 -fi -name="$1" -if [ ! -r "$1" ]; then - echo "$1 not found or it's not readable" - exit 44 -fi -mkdir -p src -if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then - unzip "$name" -d src - if [ "${name##*.}" == "zip" ]; then - name=`basename $name .zip` - else - name=`basename $name .ZIP` - fi -else - mv $name src -fi - -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi - -time=$4 -if [ "$time" -gt "0" ]; then - let "ttime = $time + 30" -else - time=1 - ttime=30 -fi - -maxm=512 -if [ "$4" != "" -a "$4" -gt "0" ]; then -maxm=$4 -fi - -if [ "$2" == "" ]; then - jarfile=run.jar -else - jarfile=$2 -fi - -cdir=`pwd` -echo "Current directory is $cdir" >&2 - -cat <<EOF > compileit.sh -#!/bin/bash -javac=`which javac` -[ -x "\$javac" ] || javac=/usr/bin/javac -if [ ! -x \$javac ]; then - echo "\$javac not found or it's not executable" - exit 47 -fi -jar=`which jar` -[ -x "\$jar" ] || jar=/usr/bin/jar -if [ ! -x \$jar ]; then - echo "\$jar not found or it's not executable" - exit 47 -fi -export CLASSPATH=.:\$CLASSPATH -cd src -if [ -r "$name" ]; then - \$javac -Xmx${maxm}M -Xms${maxm}M "$name" - echo \$? > compileit.retcode -fi -find . -name "*.java" | while read lin; do - \$javac -Xmx${maxm}M -Xms${maxm}M "\$lin" - echo \$? > compileit.retcode -done -rm -f ../$jarfile -\$jar cvf ../$jarfile * -EOF -chmod 755 compileit.sh - -echo $cdir | grep -q "/bocajail" -if [ $? == 0 ]; then - cdir=`echo $cdir | sed "s/.*\/bocajail//"` - cat <<EOF > runit.sh -#!/bin/bash -[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc -#/bin/mount --bind /dev /dev -[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys - -$sf -r1 -t$time -T$ttime -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 ./compileit.sh - -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null -EOF - chmod 755 runit.sh - chroot /bocajail "$cdir/runit.sh" - ret=`cat runit.retcode` -else - echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING" -# $javac "$name" - $sf -r1 -t$time -T$ttime -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 ./compileit.sh - ret=$? -fi -rm -rf src/ -if [ -f stdout0 ]; then - cat stdout0 -fi -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - exit $ret -fi -ret=`cat compileit.retcode` -if [ "$ret" != "0" ]; then - echo "Compilation Error: $ret" - ret=1 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/multas/limits b/boca-1.5.0/doc/problemexamples/multas/limits new file mode 120000 index 0000000..3744764 --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/multas/limits @@ -0,0 +1 @@ +../problemtemplate/limits
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/multas/limits/c b/boca-1.5.0/doc/problemexamples/multas/limits/c deleted file mode 100644 index b48a3b7..0000000 --- a/boca-1.5.0/doc/problemexamples/multas/limits/c +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename -echo 4 -# and the number of repetitions to run within the given timelimit in the second line -echo 10 -# and the maximum amount of memory per repetition in the third line (in Mbytes) -echo 512 -# and shall return zero to indicate no failure -exit 0 -# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be -# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is -# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs -# the value. diff --git a/boca-1.5.0/doc/problemexamples/multas/limits/cpp b/boca-1.5.0/doc/problemexamples/multas/limits/cpp deleted file mode 100644 index b48a3b7..0000000 --- a/boca-1.5.0/doc/problemexamples/multas/limits/cpp +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename -echo 4 -# and the number of repetitions to run within the given timelimit in the second line -echo 10 -# and the maximum amount of memory per repetition in the third line (in Mbytes) -echo 512 -# and shall return zero to indicate no failure -exit 0 -# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be -# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is -# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs -# the value. diff --git a/boca-1.5.0/doc/problemexamples/multas/limits/java b/boca-1.5.0/doc/problemexamples/multas/limits/java deleted file mode 100644 index b48a3b7..0000000 --- a/boca-1.5.0/doc/problemexamples/multas/limits/java +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename -echo 4 -# and the number of repetitions to run within the given timelimit in the second line -echo 10 -# and the maximum amount of memory per repetition in the third line (in Mbytes) -echo 512 -# and shall return zero to indicate no failure -exit 0 -# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be -# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is -# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs -# the value. diff --git a/boca-1.5.0/doc/problemexamples/multas/run b/boca-1.5.0/doc/problemexamples/multas/run new file mode 120000 index 0000000..fd7410f --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/multas/run @@ -0,0 +1 @@ +../problemtemplate/run
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/multas/run/c b/boca-1.5.0/doc/problemexamples/multas/run/c deleted file mode 100755 index d65ed58..0000000 --- a/boca-1.5.0/doc/problemexamples/multas/run/c +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 exe_file -# $2 input_file -# $3 timelimit (limit to run all the repetitions, by default only one repetition) -# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit) -# $5 maximum allowed memory (in KBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec - -if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then - echo "parameter problem" - exit 43 -fi -name=`basename "$1"` -if [ ! -x "$name" ]; then - echo "$1 not found (or is not in the current dir) or it's not executable" - exit 44 -fi -if [ "${name##*.}" != "exe" -a "${name##*.}" != "EXE" ]; then - echo "WARNING: executable file extension is not .exe" -fi -input=`basename "$2"` -if [ ! -r "$input" ]; then - echo "$2 not found (or is not in the current dir) or it's not readable" - exit 45 -fi -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi - -time=$3 -if [ "$time" -gt "0" ]; then - let "ttime = $time + 30" -else - time=1 - ttime=30 -fi - -nruns=1 -if [ "$4" != "" -a "$4" -gt "0" ]; then -nruns=$4 -fi -maxm=512000 -if [ "$5" != "" -a "$5" -gt "0" ]; then -maxm=${5}000 -fi - -rm -f stdin0 2>/dev/null -mv "$input" stdin0 - -rm -f run.exe 2>/dev/null -mv "$name" run.exe -file run.exe | grep -iq "statically linked" -if [ "$?" != "0" ]; then - echo "Aborting because $name is not statically linked" - exit 47 -fi - -cdir=`pwd` -echo "Current directory is $cdir -- chrooting on it" >&2 -$sf -F10 -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe -ret=$? -if [ $ret -gt 10 ]; then - ret=0 -fi -if [ -f stdout0 ]; then - cat stdout0 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/multas/run/cpp b/boca-1.5.0/doc/problemexamples/multas/run/cpp deleted file mode 100755 index 9b2d092..0000000 --- a/boca-1.5.0/doc/problemexamples/multas/run/cpp +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 exe_file -# $2 input_file -# $3 timelimit (limit to run all the repetitions, by default only one repetition) -# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit) -# $5 maximum allowed memory (in KBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec - -if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then - echo "parameter problem" - exit 43 -fi -if [ ! -x "$1" ]; then - echo "$1 not found or it's not executable" - exit 44 -fi -name="$1" -if [ "${name##*.}" != "exe" -a "${name##*.}" != "EXE" ]; then - echo "WARNING: executable file extension is not .exe" -fi -if [ ! -r "$2" ]; then - echo "$2 not found or it's not readable" - exit 45 -fi -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi - -time=$3 -if [ "$time" -gt "0" ]; then - let "ttime = $time + 30" -else - time=1 - ttime=30 -fi - -nruns=1 -if [ "$4" != "" -a "$4" -gt "0" ]; then -nruns=$4 -fi -maxm=512000 -if [ "$5" != "" -a "$5" -gt "0" ]; then -maxm=${5}000 -fi - -rm -f stdin0 2>/dev/null -mv "$2" stdin0 - -rm -f run.exe 2>/dev/null -mv "$name" run.exe -file run.exe | grep -iq "statically linked" -if [ "$?" != "0" ]; then - echo "Aborting because $name is not statically linked" - exit 47 -fi - -cdir=`pwd` -echo "Current directory is $cdir -- chrooting on it" >&2 -$sf -F10 -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe -ret=$? -if [ $ret -gt 10 ]; then - ret=0 -fi -if [ -f stdout0 ]; then - cat stdout0 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/multas/run/java b/boca-1.5.0/doc/problemexamples/multas/run/java deleted file mode 100755 index 945f15d..0000000 --- a/boca-1.5.0/doc/problemexamples/multas/run/java +++ /dev/null @@ -1,163 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -#Last modified: 21/july/2012 by cassio@ime.usp.br -# -# parameters are: -# $1 main_class -# $2 input_file -# $3 timelimit (limit to run all the repetitions, by default only one repetition) -# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit) -# $5 maximum allowed memory (in KBytes) -# -# the output of the submission should be directed to the standard output -# -# the return code show what happened (according to safeexec): -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -# other_codes are unknown to boca: in this case BOCA will present the -# last line of standard output to the judge - -umask 0022 -id -u bocajail >/dev/null 2>/dev/null -if [ $? == 0 ]; then - bocau=`id -u bocajail` - bocag=`id -g bocajail` - chown bocajail.nogroup . -else - bocau=`id -u nobody` - bocag=`id -g nobody` - chown nobody.nogroup . -fi -if [ "$bocau" == "" -o "$bocag" == "" ]; then - echo "error finding user to run script" - exit 43 -fi - -# this script makes use of safeexec to execute the code with less privilegies -# make sure that directories below are correct. -sf=`which safeexec` -[ -x "$sf" ] || sf=/usr/bin/safeexec - -if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then - echo "parameter problem" - exit 43 -fi -if [ ! -r run.jar ]; then - echo "ERROR: file run.jar not found - possible error during compilation" - exit 1 -fi -name="$1" -if [ "${name##*.}" == "class" -a "${name##*.}" == "CLASS" ]; then - echo "WARNING: removing .class file extension" -fi -if [ "${name##*.}" == "class" ]; then - name=`basename "$1" .class` -fi -if [ "${name##*.}" == "CLASS" ]; then - name=`basename "$1" .CLASS` -fi -input=`basename "$2"` -if [ ! -r "$input" ]; then - echo "$2 not found (or is not in the current dir) or it's not readable" - exit 45 -fi -if [ ! -x $sf ]; then - echo "$sf not found or it's not executable" - exit 46 -fi - -time=$3 -if [ "$time" -gt "0" ]; then - let "ttime = $time + 30" -else - time=1 - ttime=30 -fi - -nruns=1 -if [ "$4" != "" -a "$4" -gt "0" ]; then -nruns=$4 -fi -maxm=512 -if [ "$5" != "" -a "$5" -gt "0" ]; then -maxm=${5} -fi - -rm -f stdin0 2>/dev/null -mv "$input" stdin0 - -cdir=`pwd` -echo "Current directory is $cdir" >&2 -echo $cdir | grep -q "/bocajail" -if [ $? == 0 ]; then - cdir=`echo $cdir | sed "s/.*\/bocajail//"` - cat <<EOF > runit.sh -#!/bin/bash -[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc -#/bin/mount --bind /dev /dev -[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys -java=`which java` -[ -x "$java" ] || java=/usr/bin/java -if [ ! -x $java ]; then - echo "$java not found or it's not executable" - exit 47 -fi -export CLASSPATH=.:./run.jar:$CLASSPATH -cd $cdir -$sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 -- $java -Xmx${maxm}M -Xms${maxm}M "$name" -echo \$? > runit.retcode -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null -EOF - chmod 755 runit.sh - chroot /bocajail $cdir/runit.sh - ret=`cat runit.retcode` - if [ "$ret" == "" ]; then - echo "Execution error - check autojudging" - exit 49 - fi - if [ $ret -gt 10 ]; then - echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <" - exit 9 - fi - else - echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 - echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 - echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 -# $java "$name" < stdin0 - $sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 -- $java -cp run.jar -Xmx${maxm}M -Xms${maxm}M "$name" - ret=$? - fi - if [ $ret -gt 10 ]; then - echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <" - ret=9 - fi -fi -if [ -f stdout0 ]; then - cat stdout0 -fi -exit $ret diff --git a/boca-1.5.0/doc/problemexamples/multas/tests b/boca-1.5.0/doc/problemexamples/multas/tests new file mode 120000 index 0000000..7ef2d62 --- /dev/null +++ b/boca-1.5.0/doc/problemexamples/multas/tests @@ -0,0 +1 @@ +../problemtemplate/tests
\ No newline at end of file diff --git a/boca-1.5.0/doc/problemexamples/multas/tests/c b/boca-1.5.0/doc/problemexamples/multas/tests/c deleted file mode 100755 index 1a0ca95..0000000 --- a/boca-1.5.0/doc/problemexamples/multas/tests/c +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -cat > test.c <<EOF -int main() { - char s[100]; - scanf("%s", s); - printf("%s\n",s); - return 0; -} -EOF -cat > test.in <<EOF -inputdata -EOF - -TL=2 -REP=10 -../compile/c test.c test.exe TL -../run/c test.exe test.in TL REP -output=`cat stdout0` -if [ "$output" != "inputdata" ]; then - echo "ERROR" - exit 1 -fi -exit 0 diff --git a/boca-1.5.0/doc/problemexamples/problemtemplate/compile/c b/boca-1.5.0/doc/problemexamples/problemtemplate/compile/c index 04a08e9..4cb7ea8 100644 --- a/boca-1.5.0/doc/problemexamples/problemtemplate/compile/c +++ b/boca-1.5.0/doc/problemexamples/problemtemplate/compile/c @@ -59,7 +59,7 @@ if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then unzip "$name" -d src name="*.c" else - mv $name src + cp "$name" src fi id -u bocajail >/dev/null 2>/dev/null if [ $? == 0 ]; then @@ -85,8 +85,10 @@ if [ ! -x $sf ]; then exit 46 fi maxm=512000 -if [ "$4" != "" -a "$4" -gt "0" ]; then -maxm=${4}000 +if [ "$4" != "" ]; then + if [ "$4" -gt "0" ]; then + maxm=${4}000 + fi fi # setting up the timelimit according to the problem @@ -95,7 +97,7 @@ time=5 else time=$3 fi -let ttime=$time+30 +let "ttime = $time + 30" if [ "$2" == "" ]; then exe=run.exe @@ -103,7 +105,7 @@ else exe=$2 fi -rm -f ../$exe 2>/dev/null +rm -f $exe compileit.retcode runit.retcode 2>/dev/null cat <<EOF > compileit.sh #!/bin/bash cc=\`which gcc\` @@ -113,8 +115,8 @@ if [ ! -x "\$cc" ]; then exit 47 fi cd src -"\$cc" -static -O2 -lm -o ../$exe "$name" -echo \$? > compileit.retcode +"\$cc" -static -O2 -o ../$exe $name -lm +echo \$? > ../compileit.retcode exit 0 EOF chmod 755 compileit.sh @@ -124,29 +126,40 @@ echo "Current directory is $cdir" >&2 echo $cdir | grep -q "/bocajail" if [ $? == 0 ]; then cdir=`echo $cdir | sed "s/.*\/bocajail//"` + echo "Internal directory is $cdir" cat <<EOF > runit.sh #!/bin/bash +cd "$cdir" [ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc #/bin/mount --bind /dev /dev [ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh echo \$? > runit.retcode -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null +if [ ! -d /bocajail ]; then + /bin/umount /proc 2>/dev/null + #/bin/umount /dev + /bin/umount /sys 2>/dev/null +fi EOF chmod 755 runit.sh chroot /bocajail "$cdir/runit.sh" - ret=`cat runit.retcode` + if [ -r runit.retcode ]; then + ret=`cat runit.retcode` + else + ret=99 + fi else echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING" $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh ret=$? fi -rm -rf src/ -if [ -f stdout0 ]; then - cat stdout0 +if [ -f "stdout0" ]; then + cat "stdout0" fi +if [ -f "stderr0" ]; then + cat "stderr0" +fi +rm -rf src/ if [ "$ret" != "0" ]; then echo "Compilation Error: $ret" exit $ret diff --git a/boca-1.5.0/doc/problemexamples/problemtemplate/compile/cpp b/boca-1.5.0/doc/problemexamples/problemtemplate/compile/cpp index 2ec55ac..6a61bc1 100644 --- a/boca-1.5.0/doc/problemexamples/problemtemplate/compile/cpp +++ b/boca-1.5.0/doc/problemexamples/problemtemplate/compile/cpp @@ -59,7 +59,7 @@ if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then unzip "$name" -d src name="*.c" else - mv $name src + cp "$name" src fi id -u bocajail >/dev/null 2>/dev/null if [ $? == 0 ]; then @@ -85,8 +85,10 @@ if [ ! -x $sf ]; then exit 46 fi maxm=512000 -if [ "$4" != "" -a "$4" -gt "0" ]; then -maxm=${4}000 +if [ "$4" != "" ]; then + if [ "$4" -gt "0" ]; then + maxm=${4}000 + fi fi # setting up the timelimit according to the problem @@ -95,7 +97,7 @@ time=5 else time=$3 fi -let ttime=$time+30 +let "ttime = $time + 30" if [ "$2" == "" ]; then exe=run.exe @@ -103,7 +105,7 @@ else exe=$2 fi -rm -f ../$exe 2>/dev/null +rm -f $exe compileit.retcode runit.retcode 2>/dev/null cat <<EOF > compileit.sh #!/bin/bash cc=\`which g++\` @@ -113,8 +115,8 @@ if [ ! -x "\$cc" ]; then exit 47 fi cd src -"\$cc" -static -O2 -lm -o ../$exe "$name" -echo \$? > compileit.retcode +"\$cc" -static -O2 -o ../$exe $name -lm +echo \$? > ../compileit.retcode exit 0 EOF chmod 755 compileit.sh @@ -124,29 +126,40 @@ echo "Current directory is $cdir" >&2 echo $cdir | grep -q "/bocajail" if [ $? == 0 ]; then cdir=`echo $cdir | sed "s/.*\/bocajail//"` + echo "Internal directory is $cdir" cat <<EOF > runit.sh #!/bin/bash +cd "$cdir" [ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc #/bin/mount --bind /dev /dev [ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh echo \$? > runit.retcode -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null +if [ ! -d /bocajail ]; then + /bin/umount /proc 2>/dev/null + #/bin/umount /dev + /bin/umount /sys 2>/dev/null +fi EOF chmod 755 runit.sh chroot /bocajail "$cdir/runit.sh" - ret=`cat runit.retcode` + if [ -r runit.retcode ]; then + ret=`cat runit.retcode` + else + ret=99 + fi else echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING" $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh ret=$? fi -rm -rf src/ -if [ -f stdout0 ]; then - cat stdout0 +if [ -f "stdout0" ]; then + cat "stdout0" fi +if [ -f "stderr0" ]; then + cat "stderr0" +fi +rm -rf src/ if [ "$ret" != "0" ]; then echo "Compilation Error: $ret" exit $ret diff --git a/boca-1.5.0/doc/problemexamples/problemtemplate/compile/java b/boca-1.5.0/doc/problemexamples/problemtemplate/compile/java index dae050e..f62215b 100644 --- a/boca-1.5.0/doc/problemexamples/problemtemplate/compile/java +++ b/boca-1.5.0/doc/problemexamples/problemtemplate/compile/java @@ -49,18 +49,6 @@ if [ ! -r "$1" ]; then echo "$1 not found or it's not readable" exit 44 fi -mkdir -p src -if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then - unzip "$name" -d src - if [ "${name##*.}" == "zip" ]; then - name=`basename $name .zip` - else - name=`basename $name .ZIP` - fi -else - mv $name src -fi - id -u bocajail >/dev/null 2>/dev/null if [ $? == 0 ]; then bocau=`id -u bocajail` @@ -76,6 +64,20 @@ if [ "$bocau" == "" -o "$bocag" == "" ]; then exit 43 fi +mkdir -p src +if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then + unzip "$name" -d src + if [ "${name##*.}" == "zip" ]; then + name=`basename $name .zip` + else + name=`basename $name .ZIP` + fi +else + cp $name src +fi +chown -R $bocau src +chmod -R 700 src + # this script makes use of safeexec to execute the code with less privilegies # make sure that directories below are correct. sf=`which safeexec` @@ -124,15 +126,16 @@ fi export CLASSPATH=.:\$CLASSPATH cd src if [ -r "$name" ]; then - \$javac -Xmx${maxm}M -Xms${maxm}M "$name" - echo \$? > compileit.retcode + \$javac "$name" + echo \$? > ../compileit.retcode fi find . -name "*.java" | while read lin; do - \$javac -Xmx${maxm}M -Xms${maxm}M "\$lin" - echo \$? > compileit.retcode + \$javac "\$lin" + echo \$? > ../compileit.retcode done rm -f ../$jarfile \$jar cvf ../$jarfile * +exit 0 EOF chmod 755 compileit.sh @@ -141,29 +144,39 @@ if [ $? == 0 ]; then cdir=`echo $cdir | sed "s/.*\/bocajail//"` cat <<EOF > runit.sh #!/bin/bash +cd "$cdir" [ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc #/bin/mount --bind /dev /dev [ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys $sf -r1 -t$time -T$ttime -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 ./compileit.sh - -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null +echo \$? > runit.retcode +if [ ! -d /bocajail ]; then + /bin/umount /proc 2>/dev/null + #/bin/umount /dev + /bin/umount /sys 2>/dev/null +fi EOF chmod 755 runit.sh chroot /bocajail "$cdir/runit.sh" - ret=`cat runit.retcode` + if [ -r runit.retcode ]; then + ret=`cat runit.retcode` + else + ret=99 + fi else echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING" # $javac "$name" $sf -r1 -t$time -T$ttime -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 ./compileit.sh ret=$? fi -rm -rf src/ -if [ -f stdout0 ]; then - cat stdout0 +if [ -f "stdout0" ]; then + cat "stdout0" +fi +if [ -f "stderr0" ]; then + cat "stderr0" fi +rm -rf src/ if [ "$ret" != "0" ]; then echo "Compilation Error: $ret" exit $ret diff --git a/boca-1.5.0/doc/problemexamples/problemtemplate/run/c b/boca-1.5.0/doc/problemexamples/problemtemplate/run/c index d65ed58..75720ee 100755 --- a/boca-1.5.0/doc/problemexamples/problemtemplate/run/c +++ b/boca-1.5.0/doc/problemexamples/problemtemplate/run/c @@ -65,16 +65,11 @@ if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then echo "parameter problem" exit 43 fi -name=`basename "$1"` -if [ ! -x "$name" ]; then +if [ ! -x "$1" ]; then echo "$1 not found (or is not in the current dir) or it's not executable" exit 44 fi -if [ "${name##*.}" != "exe" -a "${name##*.}" != "EXE" ]; then - echo "WARNING: executable file extension is not .exe" -fi -input=`basename "$2"` -if [ ! -r "$input" ]; then +if [ ! -r "$2" ]; then echo "$2 not found (or is not in the current dir) or it's not readable" exit 45 fi @@ -92,22 +87,24 @@ else fi nruns=1 -if [ "$4" != "" -a "$4" -gt "0" ]; then -nruns=$4 +if [ "$4" != "" ]; then + if [ "$4" -gt "0" ]; then + nruns=$4 + fi fi maxm=512000 -if [ "$5" != "" -a "$5" -gt "0" ]; then -maxm=${5}000 +if [ "$5" != "" ]; then + if [ "$5" -gt "0" ]; then + maxm=${5}000 + fi fi -rm -f stdin0 2>/dev/null -mv "$input" stdin0 +cp "$2" stdin0 2>/dev/null +cp "$1" run.exe 2>/dev/null -rm -f run.exe 2>/dev/null -mv "$name" run.exe file run.exe | grep -iq "statically linked" if [ "$?" != "0" ]; then - echo "Aborting because $name is not statically linked" + echo "Aborting because $1 is not statically linked" exit 47 fi diff --git a/boca-1.5.0/doc/problemexamples/problemtemplate/run/cpp b/boca-1.5.0/doc/problemexamples/problemtemplate/run/cpp index 9b2d092..e5c7620 100755 --- a/boca-1.5.0/doc/problemexamples/problemtemplate/run/cpp +++ b/boca-1.5.0/doc/problemexamples/problemtemplate/run/cpp @@ -69,10 +69,6 @@ if [ ! -x "$1" ]; then echo "$1 not found or it's not executable" exit 44 fi -name="$1" -if [ "${name##*.}" != "exe" -a "${name##*.}" != "EXE" ]; then - echo "WARNING: executable file extension is not .exe" -fi if [ ! -r "$2" ]; then echo "$2 not found or it's not readable" exit 45 @@ -91,22 +87,24 @@ else fi nruns=1 -if [ "$4" != "" -a "$4" -gt "0" ]; then -nruns=$4 +if [ "$4" != "" ]; then + if [ "$4" -gt "0" ]; then + nruns=$4 + fi fi maxm=512000 -if [ "$5" != "" -a "$5" -gt "0" ]; then -maxm=${5}000 +if [ "$5" != "" ]; then + if [ "$5" -gt "0" ]; then + maxm=${5}000 + fi fi -rm -f stdin0 2>/dev/null -mv "$2" stdin0 +cp "$2" stdin0 2>/dev/null +cp "$1" run.exe 2>/dev/null -rm -f run.exe 2>/dev/null -mv "$name" run.exe file run.exe | grep -iq "statically linked" if [ "$?" != "0" ]; then - echo "Aborting because $name is not statically linked" + echo "Aborting because $1 is not statically linked" exit 47 fi diff --git a/boca-1.5.0/doc/problemexamples/problemtemplate/run/java b/boca-1.5.0/doc/problemexamples/problemtemplate/run/java index 945f15d..c24d842 100755 --- a/boca-1.5.0/doc/problemexamples/problemtemplate/run/java +++ b/boca-1.5.0/doc/problemexamples/problemtemplate/run/java @@ -65,6 +65,12 @@ if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then echo "parameter problem" exit 43 fi +if [ -r run.exe ]; then + mv run.exe run.jar +fi +if [ -r "$1" ]; then + mv "$1" run.jar +fi if [ ! -r run.jar ]; then echo "ERROR: file run.jar not found - possible error during compilation" exit 1 @@ -79,8 +85,7 @@ fi if [ "${name##*.}" == "CLASS" ]; then name=`basename "$1" .CLASS` fi -input=`basename "$2"` -if [ ! -r "$input" ]; then +if [ ! -r "$2" ]; then echo "$2 not found (or is not in the current dir) or it's not readable" exit 45 fi @@ -98,16 +103,20 @@ else fi nruns=1 -if [ "$4" != "" -a "$4" -gt "0" ]; then -nruns=$4 +if [ "$4" != "" ]; then + if [ "$4" -gt "0" ]; then + nruns=$4 + fi fi maxm=512 -if [ "$5" != "" -a "$5" -gt "0" ]; then -maxm=${5} +if [ "$5" != "" ]; then + if [ "$5" -gt "0" ]; then + maxm=${5} + fi fi -rm -f stdin0 2>/dev/null -mv "$input" stdin0 +rm -f runit.retcode 2>/dev/null +cp "$2" stdin0 2>/dev/null cdir=`pwd` echo "Current directory is $cdir" >&2 @@ -116,46 +125,44 @@ if [ $? == 0 ]; then cdir=`echo $cdir | sed "s/.*\/bocajail//"` cat <<EOF > runit.sh #!/bin/bash +cd "$cdir" [ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc #/bin/mount --bind /dev /dev [ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys java=`which java` -[ -x "$java" ] || java=/usr/bin/java -if [ ! -x $java ]; then - echo "$java not found or it's not executable" +[ -x "\$java" ] || java=/usr/bin/java +if [ ! -x \$java ]; then + echo "\$java not found or it's not executable" exit 47 fi export CLASSPATH=.:./run.jar:$CLASSPATH -cd $cdir -$sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 -- $java -Xmx${maxm}M -Xms${maxm}M "$name" +$sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 -- \$java -Xmx${maxm}M -Xms${maxm}M "$name" echo \$? > runit.retcode -/bin/umount /proc 2>/dev/null -#/bin/umount /dev -/bin/umount /sys 2>/dev/null +if [ ! -d /bocajail ]; then + /bin/umount /proc 2>/dev/null + #/bin/umount /dev + /bin/umount /sys 2>/dev/null +fi EOF - chmod 755 runit.sh - chroot /bocajail $cdir/runit.sh - ret=`cat runit.retcode` - if [ "$ret" == "" ]; then - echo "Execution error - check autojudging" - exit 49 - fi - if [ $ret -gt 10 ]; then - echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <" - exit 9 - fi - else - echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 - echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 - echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 -# $java "$name" < stdin0 - $sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 -- $java -cp run.jar -Xmx${maxm}M -Xms${maxm}M "$name" - ret=$? - fi - if [ $ret -gt 10 ]; then - echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <" - ret=9 + chmod 755 runit.sh + chroot /bocajail "$cdir/runit.sh" + if [ -r runit.retcode ]; then + ret=`cat runit.retcode` fi + if [ "$ret" == "" ]; then + echo "Execution error - check autojudging" + exit 49 + fi +else + echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 + echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 + echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2 + $sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 -- $java -cp run.jar -Xmx${maxm}M -Xms${maxm}M "$name" + ret=$? +fi +if [ $ret -gt 10 ]; then + echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <" + ret=9 fi if [ -f stdout0 ]; then cat stdout0 diff --git a/boca-1.5.0/doc/problemexamples/problemtemplate/tests/c b/boca-1.5.0/doc/problemexamples/problemtemplate/tests/c index d7d0411..de0a9c5 100755 --- a/boca-1.5.0/doc/problemexamples/problemtemplate/tests/c +++ b/boca-1.5.0/doc/problemexamples/problemtemplate/tests/c @@ -4,6 +4,7 @@ # and the script files that are included in the problem package cat > test.c <<EOF +#include<stdio.h> int main() { char s[100]; scanf("%s", s); @@ -17,11 +18,19 @@ EOF TL=2 REP=10 -../compile/c test.c test.exe TL -../run/c test.exe test.in TL REP -output=`cat stdout0` -if [ "$output" != "inputdata" ]; then +chmod 755 ../compile/c +../compile/c test.c test.exe $TL +chmod 755 ../run/c +../run/c test.exe test.in $TL $REP +if [ -r stdout0 ]; then + output=`cat stdout0` + if [ "$output" != "inputdata" ]; then + echo "ERROR" + exit 1 + fi +else echo "ERROR" exit 1 fi +echo "TEST PASSED" exit 0 diff --git a/boca-1.5.0/src/admin/contest.php b/boca-1.5.0/src/admin/contest.php index 361b55b..ddffed4 100644 --- a/boca-1.5.0/src/admin/contest.php +++ b/boca-1.5.0/src/admin/contest.php @@ -95,12 +95,16 @@ if (isset($_POST["Submit3"]) && isset($_POST["penalty"]) && is_numeric($_POST["p if($dd > 0) { $param['keys']=implode(',',$ar); MSGError(count($ar) . ' keys are being imported from the file'); + DBClearProblemTmp($_SESSION["usertable"]["contestnumber"]); } } $param['atualizasites']=$at; } DBUpdateContest ($param); - if(strlen($param['unlockkey'])>1) DBGetFullProblemData($_SESSION["usertable"]["contestnumber"],true); + if(strlen($param['unlockkey'])>1) { + DBClearProblemTmp($_SESSION["usertable"]["contestnumber"]); + DBGetFullProblemData($_SESSION["usertable"]["contestnumber"],true); + } } ForceLoad("contest.php"); } diff --git a/boca-1.5.0/src/admin/problem.php b/boca-1.5.0/src/admin/problem.php index d52c429..0b055b6 100644 --- a/boca-1.5.0/src/admin/problem.php +++ b/boca-1.5.0/src/admin/problem.php @@ -53,7 +53,6 @@ if (isset($_POST["Submit3"]) && isset($_POST["problemnumber"]) && is_numeric($_P $param['fake'] = 'f'; $param['colorname'] = $_POST["colorname"]; $param['color'] = $_POST["color"]; - if($param['color']=='') $param['color']=-1; DBNewProblem ($_SESSION["usertable"]["contestnumber"], $param); } ForceLoad("problem.php"); diff --git a/boca-1.5.0/src/admin/runedit.php b/boca-1.5.0/src/admin/runedit.php index 5b995ce..fa691e8 100644 --- a/boca-1.5.0/src/admin/runedit.php +++ b/boca-1.5.0/src/admin/runedit.php @@ -290,9 +290,9 @@ else <td width="83%"> <?php if($a["autostdout"]!="") { - echo "<a href=\"../filedownload.php?".filedownload($a["autostdout"]."stdout") ."\">stdout</a>\n"; + echo "<a href=\"../filedownload.php?".filedownload($a["autostdout"],"stdout") ."\">stdout</a>\n"; echo "<a href=\"#\" class=menu style=\"font-weight:bold\" onClick=\"window.open('../filewindow.php?". - filedownload($a["autostdout"]."stdout") ."', 'View - STDOUT','width=680,height=600,scrollbars=yes,". + filedownload($a["autostdout"],"stdout") ."', 'View - STDOUT','width=680,height=600,scrollbars=yes,". "resizable=yes')\">view</a>\n"; } else echo "unavailable"; diff --git a/boca-1.5.0/src/admin/site.php b/boca-1.5.0/src/admin/site.php index 67a9ebe..84241f3 100644 --- a/boca-1.5.0/src/admin/site.php +++ b/boca-1.5.0/src/admin/site.php @@ -131,7 +131,7 @@ if (isset($_POST["Submit1"]) && $_POST["Submit1"] == "Send" && isset($_POST["nam $param['contestnumber']=$_SESSION["usertable"]["contestnumber"]; $param['sitenumber']=$_POST["site"]; $param['sitename']=$_POST["name"]; - $param['siteip']=$_POST["ip"]; +// $param['siteip']=$_POST["ip"]; $param['siteduration']=$_POST["duration"]*60; $param['sitelastmileanswer']= $_POST["lastmileanswer"]*60; $param['sitelastmilescore']= $_POST["lastmilescore"]*60; diff --git a/boca-1.5.0/src/fclar.php b/boca-1.5.0/src/fclar.php index 6eb9b77..0a7b439 100644 --- a/boca-1.5.0/src/fclar.php +++ b/boca-1.5.0/src/fclar.php @@ -80,7 +80,7 @@ function DBUserClars($contest,$site,$user) { $c = DBConnect(); $r = DBExec($c, "select distinct c.clarsitenumber as site, c.clarnumber as number, c.clardatediff as timestamp, " . "p.problemname as problem, c.clarstatus as status, c.clardata as question, " . - "c.claranswer as answer, c.updatetime as updatetime " . + "c.claranswer as answer, c.updatetime as updatetime, c.clardatediffans as anstime " . "from clartable as c, problemtable as p " . "where c.contestnumber=$contest and p.contestnumber=c.contestnumber and " . "c.clarproblem=p.problemnumber and not clarstatus ~ 'deleted' and " . diff --git a/boca-1.5.0/src/fcontest.php b/boca-1.5.0/src/fcontest.php index ea426f3..9390a31 100644 --- a/boca-1.5.0/src/fcontest.php +++ b/boca-1.5.0/src/fcontest.php @@ -237,7 +237,7 @@ function DBAllSiteTime($contest, $site) { return $a; } -function DBUserInfo($contest, $site, $user, $c=null) { +function DBUserInfo($contest, $site, $user, $c=null,$hashpass=true) { $sql = "select * from usertable where usernumber=$user and usersitenumber=$site and " . "contestnumber=$contest"; $a = DBGetRow ($sql, 0, $c); @@ -245,7 +245,8 @@ function DBUserInfo($contest, $site, $user, $c=null) { LOGError("Unable to find the user in the database. SQL=(" . $sql . ")"); MSGError("Unable to find the user in the database. Contact an admin now!"); } - $a['userpassword'] = myhash($a['userpassword'] . $a['usersessionextra']); + if($hashpass) + $a['userpassword'] = myhash($a['userpassword'] . $a['usersessionextra']); return $a; } function DBDeleteUser($contest, $site, $user) { @@ -973,11 +974,12 @@ function DBNewSite ($contest, $c=null, $param=array()) { } $ct = DBContestInfo ($contest, $c); if($ct==null) return false; - $f=$ct["contestduration"]; if(isset($param['sitenumber']) && !isset($param['number'])) $param['number']=$param['sitenumber']; - $ac=array('number','siteip','sitename','sitescorelevel','updatetime'); + $ac=array('number','siteip','sitename','sitescorelevel','updatetime','startdate','duration'); $type=array(); + $type['startdate']=1; + $type['duration']=1; $type['number']=1; $type['sitescorelevel']=1; $type['updatetime']=1; @@ -997,6 +999,8 @@ function DBNewSite ($contest, $c=null, $param=array()) { $a = DBGetRow ("select * from sitetable where contestnumber=$contest and sitenumber=$number", 0, $c); if($a != null) return 1; } + if($duration=='') $duration = $ct["contestduration"]; + if($startdate=='') $startdate=$ct["conteststartdate"]; if($siteip=="") $siteip="127.0.0.1/boca"; if($sitename=="") $sitename="Site"; if($sitescorelevel=="") $sitescorelevel=3; @@ -1008,7 +1012,7 @@ function DBNewSite ($contest, $c=null, $param=array()) { "sitenextuser, sitenextclar, sitenextrun, sitenexttask, sitemaxtask, updatetime) values ". "($contest, $number, '$siteip', '$sitename', 't', 't', ". $ct["contestlastmileanswer"].",".$ct["contestlastmilescore"]. - ", $f, 't', '$number', '$number', '$number', $sitescorelevel, 0, 0, 0, 0, 10, $updatetime)"); + ", $duration, 't', '$number', '$number', '$number', $sitescorelevel, 0, 0, 0, 0, 10, $updatetime)"); $cf=globalconf(); $admpass = myhash($cf["basepass"]); @@ -1022,7 +1026,7 @@ function DBNewSite ($contest, $c=null, $param=array()) { $param=array(); $param['contest']=$contest; $param['site']=$number; - $param['start']=$ct["conteststartdate"]; + $param['start']=$startdate; DBRenewSiteTime($param, $c); if($cw) DBExec($c, "commit work"); LOGLevel("User " . $_SESSION["usertable"]["username"]."/". $_SESSION["usertable"]["usersitenumber"] . @@ -1031,18 +1035,18 @@ function DBNewSite ($contest, $c=null, $param=array()) { } function DBUserUpdate($contest, $site, $user, $username, $userfull, $userdesc, $passo, $passn) { - $a = DBUserInfo ($contest, $site, $user); + $a = DBUserInfo($contest, $site, $user, null, false); $p = myhash($a["userpassword"] . session_id()); - if ($a["userpassword"] != "" && $p != $passo) { + if ($a["userpassword"] != "" && $p != $passo) { LOGLevel("User " . $_SESSION["usertable"]["username"]."/". $_SESSION["usertable"]["usersitenumber"] . " (contest=$contest, site=$site) " . - "tried to change settings, but password was incorrect.",2); + "tried to change settings, but password was incorrect.",2); MSGError ("Incorrect password."); } else { if ($a["userpassword"] == "") $temp = myhash(""); else $temp = $a["userpassword"]; $temp = bighexsub($passn, $temp); - $newpass = substr($temp, strlen($temp)-32, 32); + $newpass = substr($temp, strlen($temp)-strlen($myhash), strlen($myhash)); $c = DBConnect(); DBExec($c, "begin work"); @@ -1207,6 +1211,10 @@ function siteclock() { return array("contest not running",-1000000000); if ($s["currenttime"]<0) { $t = - $s["currenttime"]; + if($t>3600) { + $t = ((int) ($t/360))/10; + return array("> ". $t . " hour(s) to start",$s["currenttime"]); + } if ($t>60) { $t = (int) ($t/60); return array("> ". $t . " min(s) to start",$s["currenttime"]); @@ -1216,17 +1224,22 @@ function siteclock() { } if ($s["currenttime"]>=0) { $t = $s["siteduration"] - $s["currenttime"]; + $str = ''; + if($t >= 3600) { + $str .= ((int)($t/3600)) . 'h '; + $t = $t % 3600; + } if ($t>60) { $t = (int) ($t/60); - return array("> " . $t . " minute(s) left",$s["currenttime"]); - } else { + return array($str . $t . " min(s) left",$s["currenttime"]); + } else if($str=='') { if ($t>0) { return array($t . " second(s) left",$s["currenttime"]); } else { $t = (int) (- $t/60); return array($t . "min. of extra time",$s["currenttime"]); } - } + } else return array($str . " left",$s["currenttime"]); } else return array("not started",-1000000000); } diff --git a/boca-1.5.0/src/fproblem.php b/boca-1.5.0/src/fproblem.php index 669c2ef..42346cb 100644 --- a/boca-1.5.0/src/fproblem.php +++ b/boca-1.5.0/src/fproblem.php @@ -85,7 +85,8 @@ function DBGetProblemData($contestnumber, $problemnumber, $c=null) { $ds = DIRECTORY_SEPARATOR; if($ds=="") $ds = "/"; - $ptmp = $_SESSION["locr"] . $ds . "private" . $ds . "problemtmp" . $ds . "problem" . $a[$i]['number'] . "-contest" . $contestnumber; + $nn = $a[$i]['number']; + $ptmp = $_SESSION["locr"] . $ds . "private" . $ds . "problemtmp" . $ds . "contest" . $contestnumber ."-problem" . $nn; if(is_readable($ptmp . ".name")) { $a[$i]['descfilename']=trim(file_get_contents($ptmp . ".name")); if($a[$i]['descfilename'] != '') @@ -94,6 +95,14 @@ function DBGetProblemData($contestnumber, $problemnumber, $c=null) { } return $a; } +function DBClearProblemTmp($contestnumber) { + $ds = DIRECTORY_SEPARATOR; + if($ds=="") $ds = "/"; + $ptmp = $_SESSION["locr"] . $ds . "private" . $ds . "problemtmp" . $ds . "contest" . $contestnumber . "-*.name"; + foreach(glob($ptmp) as $file) @unlink($file); + $ptmp = $_SESSION["locr"] . $ds . "private" . $ds . "problemtmp" . $ds . "contest" . $contestnumber . "-*.hash"; + foreach(glob($ptmp) as $file) @unlink($file); +} function DBGetFullProblemData($contestnumber,$freeproblems=false) { $c = DBConnect(); DBExec($c, "begin work", "GetFullProblemData"); @@ -110,18 +119,31 @@ function DBGetFullProblemData($contestnumber,$freeproblems=false) { } $cf = globalconf(); $a = array(); + $ds = DIRECTORY_SEPARATOR; + if($ds=="") $ds = "/"; for ($i=0;$i<$n;$i++) { $a[$i] = array_merge(array(),DBRow($r,$i)); $nn=$a[$i]['number']; + $ptmp = $_SESSION["locr"] . $ds . "private" . $ds . "problemtmp" . $ds . "contest" . $contestnumber ."-problem" . $nn; + $ck = myshorthash(''); + if(is_readable($ptmp . ".hash")) { + $ck = trim(file_get_contents($ptmp . ".hash")); + } + if($ck != $a[$i]['inputhash']) { + @unlink($ptmp . ".name"); + @unlink($ptmp . ".hash"); + $a[$i]['basefilename']=''; + $a[$i]['descfilename']=''; + $a[$i]['fullname']=''; + } if($freeproblems && $a[$i]['fake'] != 't') { - $ds = DIRECTORY_SEPARATOR; - if($ds=="") $ds = "/"; - $ptmp = $_SESSION["locr"] . $ds . "private" . $ds . "problemtmp" . $ds . "problem" . $nn . "-contest" . $contestnumber; if(is_readable($ptmp . ".name")) { $a[$i]['descfilename']=trim(file_get_contents($ptmp . ".name")); if($a[$i]['descfilename'] != '') $a[$i]['descoid']=-1; } else { + @unlink($ptmp . ".name"); + @unlink($ptmp . ".hash"); $randnum = session_id() . "_" . rand(); $dir = $ptmp . '-' . $randnum; @mkdir($dir,0770,true); @@ -153,6 +175,7 @@ function DBGetFullProblemData($contestnumber,$freeproblems=false) { $failed=5; if(!$failed) { file_put_contents($ptmp . ".name",$ptmp . $ds . $descfile); + file_put_contents($ptmp . ".hash",$a[$i]['inputhash']); if(is_readable($ptmp . ".name")) { $a[$i]['descfilename']=trim(file_get_contents($ptmp . ".name")); if($a[$i]['descfilename'] != '') @@ -166,6 +189,13 @@ function DBGetFullProblemData($contestnumber,$freeproblems=false) { } } if($failed) { + $a[$i]['basefilename']=''; + $a[$i]['descfilename']=''; + @unlink($ptmp . ".name"); + @unlink($ptmp . ".hash"); + DBExec($c,"update problemtable set problemfullname='', problembasefilename='' where problemnumber=$nn and contestnumber=$contestnumber", + "DBGetFullProblemData(unfree problem)"); + if($failed!=4) { LogError("Failed to unzip problem package (failcode=$failed, problem=$nn, contest=$contestnumber)"); if($failed==1) $a[$i]['fullname']='(ERROR READING FROM DATABASE, OR DIRECTORY PERMISSION PROBLEM)'; @@ -177,7 +207,7 @@ function DBGetFullProblemData($contestnumber,$freeproblems=false) { } cleardir($dir,false,true); } - } + } } DBExec($c, "commit", "GetFullProblemData"); return $a; @@ -282,8 +312,8 @@ function DBNewProblem($contestnumber, $param, $c=null) { $oldfullname=''; $deservesupdatetime=false; if ($n == 0) { - DBExec ($c, "insert into problemtable (contestnumber, problemnumber, problemname) values " . - "($contestnumber, $number, '$name')", "DBNewProblem(insert problem)"); + DBExec ($c, "insert into problemtable (contestnumber, problemnumber, problemname, problemcolor) values " . + "($contestnumber, $number, '$name','-1')", "DBNewProblem(insert problem)"); $deservesupdatetime=true; $s = "created"; } @@ -369,7 +399,7 @@ function DBNewProblem($contestnumber, $param, $c=null) { if($deservesupdatetime) { $ds = DIRECTORY_SEPARATOR; if($ds=="") $ds = "/"; - @unlink($_SESSION["locr"] . $ds . "private" . $ds . "problemtmp" . $ds . "problem" . $number . "-contest" . $contestnumber . '.name'); + @unlink($_SESSION["locr"] . $ds . "private" . $ds . "problemtmp" . $ds . "contest" . $contestnumber ."-problem" . $number . '.name'); DBExec ($c, "update problemtable set updatetime=" . $updatetime . " where contestnumber=$contestnumber and problemnumber=$number", "DBNewProblem(time)"); } @@ -407,7 +437,8 @@ function DBGetProblems($contest,$showanyway=false) { $ds = DIRECTORY_SEPARATOR; if($ds=="") $ds = "/"; - $ptmp = $_SESSION["locr"] . $ds . "private" . $ds . "problemtmp" . $ds . "problem" . $a[$i]['number'] . "-contest" . $contest; + $nn = $a[$i]['number']; + $ptmp = $_SESSION["locr"] . $ds . "private" . $ds . "problemtmp" . $ds . "contest" . $contestnumber ."-problem" . $nn; if(is_readable($ptmp . ".name")) { $a[$i]['descfilename']=trim(file_get_contents($ptmp . ".name")); if($a[$i]['descfilename'] != '') diff --git a/boca-1.5.0/src/frun.php b/boca-1.5.0/src/frun.php index cd6cd50..3ea398a 100644 --- a/boca-1.5.0/src/frun.php +++ b/boca-1.5.0/src/frun.php @@ -412,9 +412,8 @@ function DBGetRunToAutojudging($contest, $ip) { "r.runnumber as number, r.rundatediff as timestamp, r.runstatus as status, " . "r.rundata as sourceoid, r.runfilename as sourcename, l.langnumber as langnumber, " . "p.problemname as problemname, p.problemnumber as problemnumber, l.langextension as extension, l.langname as language, " . - "p.problembasefilename as basename, p.problemtimelimit as timelimit, ". + "p.problembasefilename as basename, ". "p.probleminputfilename as inputname, p.probleminputfile as inputoid, " . - "p.problemsolfilename as solname, p.problemsolfile as soloid, " . "r.autoip as autoip, r.autobegindate as autobegin, r.autoenddate as autoend, r.autoanswer as autoanswer, ". "r.autostdout as autostdout, r.autostderr as autostderr ". "from runtable as r, problemtable as p, langtable as l " . @@ -947,5 +946,83 @@ function DBJudgedRuns($contest,$site,$user) { } return $a; } + +function exitmsg($retval) { +/* FROM SAFEEXEC +# 0 ok +# 1 compile error +# 2 runtime error +# 3 timelimit exceeded +# 4 internal error +# 5 parameter error +# 6 internal error +# 7 memory limit exceeded +# 8 security threat +# 9 runtime error +*/ +/* + DBExec($c, "insert into answertable (contestnumber, answernumber, runanswer, yes, fake) values ". + "($n, 0, 'Not answered yet', 'f', 't')", "DBNewContest(insert fake answer)"); + DBExec($c, "insert into answertable (contestnumber, answernumber, runanswer, yes, fake) values ". + "($n, 1, 'YES', 't', 'f')", "DBNewContest(insert YES answer)"); + DBExec($c, "insert into answertable (contestnumber, answernumber, runanswer, yes, fake) values ". + "($n, 2, 'NO - Compilation error', 'f', 'f')", "DBNewContest(insert CE answer)"); + DBExec($c, "insert into answertable (contestnumber, answernumber, runanswer, yes, fake) values ". + "($n, 3, 'NO - Runtime error', 'f', 'f')", "DBNewContest(insert RE answer)"); + DBExec($c, "insert into answertable (contestnumber, answernumber, runanswer, yes, fake) values ". + "($n, 4, 'NO - Time limit exceeded', 'f', 'f')", "DBNewContest(insert TLE answer)"); + DBExec($c, "insert into answertable (contestnumber, answernumber, runanswer, yes, fake) values ". + "($n, 5, 'NO - Presentation error', 'f', 'f')", "DBNewContest(insert PE answer)"); + DBExec($c, "insert into answertable (contestnumber, answernumber, runanswer, yes, fake) values ". + "($n, 6, 'NO - Wrong answer', 'f', 'f')", "DBNewContest(insert WA answer)"); + DBExec($c, "insert into answertable (contestnumber, answernumber, runanswer, yes, fake) values ". + "($n, 7, 'NO - Contact staff', 'f', 'f')", "DBNewContest(insert CS answer)"); +*/ + if($retval==-1) { + $answer="Internal error while executing run command"; + $retval = 7; // contact staff + } + else if($retval==1) { + $answer="Compilation error"; + $retval = 2; // compilation error + } + else if($retval==2) { + $answer="Runtime error"; + $retval = 3; // runtime error + } + else if($retval==3) { + $answer="Time limit exceeded"; + $retval = 4; // timelimit exceeded + } + else if($retval==4) { + $answer="safeexec internal error (4)"; + $retval = 7; // contact staff + } + else if($retval==5) { + $answer="safeexec error: parameter problem"; + $retval = 7; // contact staff + } + else if($retval==6) { + $answer="safeexec internal error (6)"; + $retval = 7; // contact staff + } + else if($retval==7) { + $answer="Runtime error (memory-limit)"; + $retval = 3; // runtime error + } + else if($retval==8) { + $answer="Code generates security threat"; + $retval = 3; // runtime error + } + else if($retval==9) { + $answer="Runtime error"; + $retval = 3; // runtime error + } else { + $answer="Unknown autojudge status"; + $retval = 7; + } + return array($retval,$answer); +} + // eof ?> diff --git a/boca-1.5.0/src/judge/runedit.php b/boca-1.5.0/src/judge/runedit.php index e446ad7..e53b3a3 100644 --- a/boca-1.5.0/src/judge/runedit.php +++ b/boca-1.5.0/src/judge/runedit.php @@ -102,19 +102,9 @@ $b = DBGetProblemData($_SESSION["usertable"]["contestnumber"], $a["problemnumber <?php for ($i=0;$i<count($b);$i++) { $if = rawurlencode($b[$i]["inputfilename"]); - $sf = rawurlencode($b[$i]["solfilename"]); echo "<a href=\"../filedownload.php?". filedownload($b[$i]["inputoid"],$b[$i]["inputfilename"]) . "\">"; - echo $b[$i]["inputfilename"] . "</a>"; -// echo " <a href=\"#\" class=menu style=\"font-weight:bold\" onClick=\"window.open('../filewindow.php?". -// filedownload($b[$i]["inputoid"],$b[$i]["inputfilename"]) ."', 'View$i - INPUT','width=680,height=600,scrollbars=yes,". -// "resizable=yes')\">view</a> "; - -// echo "<b>Sol:</b><a href=\"../filedownload.php?". filedownload($b[$i]["soloid"],$b[$i]["solfilename"]) . "\">"; -// echo $b[$i]["solfilename"] . "</a>"; -// echo " <a href=\"#\" class=menu style=\"font-weight:bold\" onClick=\"window.open('../filewindow.php?". -// filedownload($b[$i]["soloid"],$b[$i]["solfilename"]) . "', 'View$i - CORRECT OUTPUT','width=680,height=600,scrollbars=yes,". -// "resizable=yes')\">view</a>"; + echo basename($b[$i]["inputfilename"]) . "</a>"; } ?> </td> diff --git a/boca-1.5.0/src/judge/runeditchief.php b/boca-1.5.0/src/judge/runeditchief.php index 6395650..c538dca 100644 --- a/boca-1.5.0/src/judge/runeditchief.php +++ b/boca-1.5.0/src/judge/runeditchief.php @@ -96,7 +96,6 @@ if (($a = DBChiefGetRunToAnswer($runnumber, $runsitenumber, } $b = DBGetProblemData($_SESSION["usertable"]["contestnumber"], $a["problemnumber"]); -$c = DBGetLanguageData($_SESSION["usertable"]["contestnumber"], $a["langnumber"], $a["problemnumber"]); ?> <br><br><center><b>Use the following fields to judge the run: </b></center> @@ -143,18 +142,8 @@ for ($i=0;$i<count($b);$i++) { </td> </tr> <tr> - <td width="27%" align=right><b>Language</b><i> <?php echo $a["language"]; ?></i>:</td> - <td width="83%"> -<?php - if (isset($c["compilation"]) && $c["compilation"]!="") echo "<b>Compilation Line:</b> ".$c["compilation"]. "<br>"; - if (isset($c["execution"]) && $c["execution"]!="") echo "<b>Execution Line:</b> ".$c["execution"]. "<br>"; - if (isset($c["showoutput"]) && $c["showoutput"]!="") echo "<b>Showing Output Line:</b> ". $c["showoutput"]. "<br>"; - - if (isset($c["scriptname"]) && $c["scriptname"]!="") { - echo "<b>Script for judging:</b> <a href=\"../filedownload.php?". filedownload($c["scriptoid"], $c["scriptname"]) ."\">"; - echo $c["scriptname"] . "</a>"; - } -?> + <td width="27%" align=right><b>Language</b>:</td> + <td width="83%"><i> <?php echo $a["language"]; ?></i> </td> </tr> <tr> diff --git a/boca-1.5.0/src/optionlower.php b/boca-1.5.0/src/optionlower.php index b2eb5d4..9c997e3 100644 --- a/boca-1.5.0/src/optionlower.php +++ b/boca-1.5.0/src/optionlower.php @@ -56,17 +56,18 @@ $a = DBUserInfo($_SESSION["usertable"]["contestnumber"], <script language="JavaScript"> function computeHASH() { - var username, userdesc, userfull, passHASHo, passHASHn1, passHASHn2; + var username, userdesc, userfull, passHASHo, passHASHn1, passHASHn2; if (document.form1.passwordn1.value != document.form1.passwordn2.value) return; - username = document.form1.username.value; - userdesc = document.form1.userdesc.value; - userfull = document.form1.userfull.value; - passMDo = js_myhash(js_myhash(document.form1.passwordo.value)+'<?php echo session_id(); ?>'); - passMDn = bighexsoma(js_myhash(document.form1.passwordn2.value),js_myhash(document.form1.passwordo.value)); - document.form1.passwordo.value = ''; - document.form1.passwordn1.value = ''; - document.form1.passwordn2.value = ''; - document.location='option.php?username='+username+'&userdesc='+userdesc+'&userfullname='+userfull+'&passwordo='+passMDo+'&passwordn='+passMDn; + username = document.form1.username.value; + userdesc = document.form1.userdesc.value; + userfull = document.form1.userfull.value; + + passMDo = js_myhash(js_myhash(document.form1.passwordo.value)+'<?php echo session_id(); ?>'); + passMDn = bighexsoma(js_myhash(document.form1.passwordn2.value),js_myhash(document.form1.passwordo.value)); + document.form1.passwordo.value = ''; + document.form1.passwordn1.value = ''; + document.form1.passwordn2.value = ''; + document.location='option.php?username='+username+'&userdesc='+userdesc+'&userfullname='+userfull+'&passwordo='+passMDo+'&passwordn='+passMDn; } </script> diff --git a/boca-1.5.0/src/private/autojudging.php b/boca-1.5.0/src/private/autojudging.php index cdd1e2e..d5c49df 100755 --- a/boca-1.5.0/src/private/autojudging.php +++ b/boca-1.5.0/src/private/autojudging.php @@ -82,7 +82,13 @@ $cf = globalconf(); $ip = $cf["ip"]; $activecontest=DBGetActiveContest(); $prevsleep=0; +$dodebug=1; while(42) { +if(!isset($dodebug)) { + if(isset($dir)) cleardir($dir); + if(isset($name)) unlink($name); +} + if(($run = DBGetRunToAutojudging($activecontest["contestnumber"], $ip)) === false) { if($prevsleep==0) echo "Nothing to do. Sleeping..."; @@ -129,86 +135,39 @@ chdir($dir); echo "Using directory $dir (contest=$contest, site=$site, run=$number)\n"; -/* -if($run["scriptoid"]=="" || $run["scriptname"]=="") { - LogLevel("Autojuging: Script file not defined (run=$number, site=$site, contest=$contest)",1); - echo "Compiling/running script file not defined (contest=$contest, site=$site, run=$number)\n"; - cleardir($dir); - unlink($name); - DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: compiling/running script not defined"); - continue; -} -if($run["compscriptoid"]=="" || $run["compscriptname"]=="") { - LogLevel("Autojuging: Comparing script file not defined (run=$number, site=$site, contest=$contest)",1); - echo "Comparing script file not defined (contest=$contest, site=$site, run=$number)\n"; - cleardir($dir); - unlink($name); - DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: comparing script not defined"); - continue; -} -*/ if($run["sourceoid"]=="" || $run["sourcename"]=="") { LogLevel("Autojuging: Source file not defined (run=$number, site=$site, contest=$contest)",1); - echo "Source file not defined (contest=$contest, site=$site, run=$number)\n"; - cleardir($dir); - unlink($name); - DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: source file not defined"); + echo "Source file not defined (contest=$contest, site=$site, run=$number)\n"; + DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: source file not defined"); continue; } if($run["inputoid"]=="" || $run["inputname"]=="") { LogLevel("Autojuging: problem package not defined (run=$number, site=$site, contest=$contest)",1); - echo "Package file not defined (contest=$contest, site=$site, run=$number)\n"; - cleardir($dir); - unlink($name); - DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: problem package file not defined"); + echo "Package file not defined (contest=$contest, site=$site, run=$number)\n"; + DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: problem package file not defined"); continue; } -/* -if($run["soloid"]=="" || $run["solname"]=="") { - LogLevel("Autojuging: sol file not defined (run=$number, site=$site, contest=$contest)",1); - echo "solfile not defined (contest=$contest, site=$site, run=$number)\n"; - cleardir($dir); - unlink($name); - DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: correct output file not defined"); - continue; -} -*/ $c = DBConnect(); DBExec($c, "begin work", "Autojudging(exporttransaction)"); -/* -if(DB_lo_export($c, $run["scriptoid"], $dir . $ds . $run["scriptname"]) === false) { - DBExec($c, "rollback work", "Autojudging(rollback-script)"); - LogLevel("Autojuging: Unable to export script file (run=$number, site=$site, contest=$contest)",1); - echo "Error exporting compiling/running script file ${run["scriptname"]} (contest=$contest, site=$site, run=$number)\n"; - cleardir($dir); - unlink($name); - DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: unable to export compiling/running script"); - continue; -} -*/ -if(DB_lo_export($c, $run["sourceoid"], $dir . $ds . $run["sourcename"]) === false) { +if(DB_lo_export($contest,$c, $run["sourceoid"], $dir . $ds . $run["sourcename"]) === false) { DBExec($c, "rollback work", "Autojudging(rollback-source)"); LogLevel("Autojudging: Unable to export source file (run=$number, site=$site, contest=$contest)",1); echo "Error exporting source file ${run["sourcename"]} (contest=$contest, site=$site, run=$number)\n"; - cleardir($dir); - unlink($name); DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: unable to export source file"); DBExec($c, "commit", "Autojudging(exportcommit)"); continue; } if(is_readable($cache . $ds . $run["inputoid"] . "." . $run["inputname"])) { DBExec($c, "commit", "Autojudging(exportcommit)"); - echo "Getting problem package file from local cache\n"; + echo "Getting problem package file from local cache: " . $cache . $ds . $run["inputoid"] . "." . $run["inputname"] . "\n"; $s = file_get_contents($cache . $ds . $run["inputoid"] . "." . $run["inputname"]); file_put_contents($dir . $ds . $run["inputname"], decryptData($s,$key)); } else { - echo "Downloading problem package file from db\n"; - if(DB_lo_export($c, $run["inputoid"], $dir . $ds . $run["inputname"]) === false) { + echo "Downloading problem package file from db into: " . $dir . $ds . $run["inputname"] . "\n"; + if(DB_lo_export($contest,$c, $run["inputoid"], $dir . $ds . $run["inputname"]) === false) { DBExec($c, "rollback work", "Autojudging(rollback-input)"); LogLevel("Autojudging: Unable to export problem package file (run=$number, site=$site, contest=$contest)",1); echo "Error exporting problem package file ${run["inputname"]} (contest=$contest, site=$site, run=$number)\n"; - cleardir($dir); - unlink($name); DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: unable to export problem package file"); DBExec($c, "commit", "Autojudging(exportcommit)"); continue; @@ -221,138 +180,77 @@ if(is_readable($cache . $ds . $run["inputoid"] . "." . $run["inputname"])) { $zip->extractTo($dir . $ds . "problemdata"); $zip->close(); } else { - echo 'Failed to unzip the file -- please check the problem package\n'; + echo "Failed to unzip the package file -- please check the problem package (maybe it is encrypted?)\n"; DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: problem package file is invalid"); + cleardir($dir . $ds . "problemdata"); continue; } - if(($info=file($dir . $ds . "problemdata" . $ds . "description" . $ds . 'problem.info'))===false) { - echo 'Problem content missing (description/problem.info) -- please check the problem package\n'; - DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: problem package file is invalid"); + if(($info=@parse_ini_file($dir . $ds . "problemdata" . $ds . "description" . $ds . 'problem.info'))===false) { + echo "Problem content missing (description/problem.info) -- please check the problem package\n"; + DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: problem package file is incomplete"); + cleardir($dir . $ds . "problemdata"); continue; } - $basename=''; - foreach($info as $line) { - $a=explode('=',$line); - if(trim($a[0])=='basename') { - $basename=trim($a[1]); - break; - } - } + $descfile=trim(sanitizeText($info['descfile'])); + $basename=trim(sanitizeText($info['basename'])); + $fullname=trim(sanitizeText($info['fullname'])); if($basename=='') { - echo 'Problem content missing (description/problem.info) -- please check the problem package\n'; + echo "Problem content missing (description/problem.info) -- please check the problem package\n"; DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: problem package file is invalid"); + cleardir($dir . $ds . "problemdata"); continue; } if(!is_dir($dir . $ds . "problemdata" . $ds . "limits")) { - echo 'Problem content missing (limits) -- please check the problem package\n'; + echo "Problem content missing (limits) -- please check the problem package\n"; DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: problem package file is invalid"); + cleardir($dir . $ds . "problemdata"); continue; } chdir($dir . $ds . "problemdata" . $ds . "limits"); + $limits[$basename]=array(); foreach(glob($dir . $ds . "problemdata" . $ds . "limits" .$ds . '*') as $file) { chmod($file,0700); $ex = escapeshellcmd($file); $ex .= " >stdout 2>stderr"; - echo "Executing INIT SCRIPT " . $ex . "\n"; + echo "Executing INIT SCRIPT " . $ex . " at " . getcwd() . "\n"; if(system($ex, $retval)===false) $retval=-1; if($retval != 0) { - echo 'Error running script -- please check the problem package\n'; + echo "Error running script -- please check the problem package\n"; DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: problem package file is invalid"); + cleardir($dir . $ds . "problemdata"); continue; } - $limits[$basename] = file('stdout'); + $limits[$basename][basename($file)] = file('stdout',FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); } - + $cont=false; foreach(glob($dir . $ds . "problemdata" . $ds . "tests" .$ds . '*') as $file) { chdir($dir . $ds . "problemdata" . $ds . "tests"); chmod($file,0700); $ex = escapeshellcmd($file); $ex .= " >stdout 2>stderr"; - echo "Executing TEST SCRIPT " . $ex . "\n"; + echo "Executing TEST SCRIPT " . $ex . " at " . getcwd() . "\n"; if(system($ex, $retval)===false) $retval=-1; if($retval != 0) { - echo 'Error running test script -- please check the problem package\n'; + echo "Error running test script -- please check the problem package\n"; DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: internal test script failed"); - continue; + $cont=true; + break; } } cleardir($dir . $ds . "problemdata"); + if($cont) + continue; + $s = file_get_contents($dir . $ds . $run["inputname"]); file_put_contents($cache . $ds . $run["inputoid"] . "." . $run["inputname"], encryptData($s,$key)); } -function exitmsg($retval) { -/* FROM SAFEEXEC -# 0 ok -# 1 compile error -# 2 runtime error -# 3 timelimit exceeded -# 4 internal error -# 5 parameter error -# 6 internal error -# 7 memory limit exceeded -# 8 security threat -# 9 runtime error -*/ -/* - DBExec($c, "insert into answertable (contestnumber, answernumber, runanswer, yes, fake) values ". - "($n, 0, 'Not answered yet', 'f', 't')", "DBNewContest(insert fake answer)"); - DBExec($c, "insert into answertable (contestnumber, answernumber, runanswer, yes, fake) values ". - "($n, 1, 'YES', 't', 'f')", "DBNewContest(insert YES answer)"); - DBExec($c, "insert into answertable (contestnumber, answernumber, runanswer, yes, fake) values ". - "($n, 2, 'NO - Compilation error', 'f', 'f')", "DBNewContest(insert CE answer)"); - DBExec($c, "insert into answertable (contestnumber, answernumber, runanswer, yes, fake) values ". - "($n, 3, 'NO - Runtime error', 'f', 'f')", "DBNewContest(insert RE answer)"); - DBExec($c, "insert into answertable (contestnumber, answernumber, runanswer, yes, fake) values ". - "($n, 4, 'NO - Time limit exceeded', 'f', 'f')", "DBNewContest(insert TLE answer)"); - DBExec($c, "insert into answertable (contestnumber, answernumber, runanswer, yes, fake) values ". - "($n, 5, 'NO - Presentation error', 'f', 'f')", "DBNewContest(insert PE answer)"); - DBExec($c, "insert into answertable (contestnumber, answernumber, runanswer, yes, fake) values ". - "($n, 6, 'NO - Wrong answer', 'f', 'f')", "DBNewContest(insert WA answer)"); - DBExec($c, "insert into answertable (contestnumber, answernumber, runanswer, yes, fake) values ". - "($n, 7, 'NO - Contact staff', 'f', 'f')", "DBNewContest(insert CS answer)"); -*/ - if($retval==-1) { - $answer="Internal error while executing run command"; - $retval = 7; // contact staff - } - else if($retval==1) { - $answer="Compilation error"; - $retval = 2; // compilation error - } - else if($retval==2) { - $answer="Runtime error"; - $retval = 3; // runtime error - } - else if($retval==3) { - $answer="Time limit exceeded"; - $retval = 4; // timelimit exceeded - } - else if($retval==4) { - $answer="safeexec internal error (4)"; - $retval = 7; // contact staff - } - else if($retval==5) { - $answer="safeexec error: parameter problem"; - $retval = 7; // contact staff - } - else if($retval==6) { - $answer="safeexec internal error (6)"; - $retval = 7; // contact staff - } - else if($retval==7) { - $answer="Runtime error (memory-limit)"; - $retval = 3; // runtime error - } - else if($retval==8) { - $answer="Code generates security threat"; - $retval = 3; // runtime error - } - else if($retval==9) { - $answer="Runtime error"; - $retval = 3; // runtime error - } - return array($retval,$answer); +if(!isset($limits[$basename][$run["extension"]][0]) || !is_numeric($limits[$basename][$run["extension"]][0]) || + !isset($limits[$basename][$run["extension"]][1]) || !is_numeric($limits[$basename][$run["extension"]][1]) || + !isset($limits[$basename][$run["extension"]][2]) || !is_numeric($limits[$basename][$run["extension"]][2]) ) { + echo "Failed to find proper limits information for the problem -- please check the problem package\n"; + DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: problem package file is invalid"); + continue; } // COMPILATION @@ -364,31 +262,46 @@ function exitmsg($retval) { $zip = new ZipArchive; if ($zip->open($dir . $ds . $run["inputname"]) === true) { - $zip->extractTo($dir, "compile" . $ds . $run["extension"]); + $zip->extractTo($dir, array("compile" . $ds . $run["extension"])); $zip->close(); } else { - echo 'Failed to unzip the file -- please check the problem package\n'; + echo "Failed to unzip the package file -- please check the problem package\n"; DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: problem package file is invalid"); continue; } $script = $dir . $ds . 'compile' . $ds . $run["extension"]; if(!is_file($script)) { - echo 'Error (not found) compile script for '.$run["extension"].' -- please check the problem package\n'; + echo "Error (not found) compile script for ".$run["extension"]." -- please check the problem package\n"; DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: compile script failed (".$run["extension"].")"); continue; } +chdir($dir); +@unlink('allout'); +system('touch allout'); +@unlink('allerr'); +system('touch allerr'); + chmod($script, 0700); $ex = escapeshellcmd($script) ." ". escapeshellarg($run["sourcename"])." ". - "run.exe ". - escapeshellarg(trim($limits[$run["extension"]][0]))." ". - escapeshellarg(trim($limits[$run["extension"]][2])); + escapeshellarg($basename) . " ". + escapeshellarg(trim($limits[$basename][$run["extension"]][0]))." ". + escapeshellarg(trim($limits[$basename][$run["extension"]][2])); $ex .= " >stdout 2>stderr"; -echo "Executing " . $ex . "\n"; +echo "Executing " . $ex . " at " . getcwd() . "\n"; if(system($ex, $retval)===false) $retval=-1; +if(is_readable('stdout')) { + system('echo ##### COMPILATION STDOUT: >> allerr'); + system('cat stdout >> allerr'); +} +if(is_readable('stderr')) { + system('echo ##### COMPILATION STDERR: >> allerr'); + system('cat stderr >> allerr'); +} + if($retval != 0) { list($retval,$answer) = exitmsg($retval); $answer = "(WHILE COMPILING) " . $answer; @@ -401,48 +314,70 @@ if($retval != 0) { //# $5 maximum allowed memory (in KBytes) $zip = new ZipArchive; + $inputlist = array(); + $ninputlist = 0; + $outputlist = array(); + $noutputlist = 0; if ($zip->open($dir . $ds . $run["inputname"]) === true) { - $zip->extractTo($dir, array("run" . $ds . $run["extension"],"input" . $ds . '*')); - $zip->close(); + for($i = 0; $i < $zip->numFiles; $i++) { + $filename = $zip->getNameIndex($i); + $pos = strrpos(dirname($filename),"input"); + if($pos !== false && $pos==strlen(dirname($filename))-5) { + $inputlist[$ninputlist++] = 'input' . $ds . basename($filename); + $outputlist[$noutputlist++] = 'output' . $ds . basename($filename); + } + } + $zip->extractTo($dir, array_merge(array("run" . $ds . $run["extension"]),$inputlist)); + $zip->close(); } else { - echo 'Failed to unzip the file (inputs) -- please check the problem package\n'; + echo "Failed to unzip the file (inputs) -- please check the problem package\n"; DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: problem package file is invalid"); continue; } - chdir($dir); - @unlink('allout'); - @unlink('allerr'); $retval = 0; $script = $dir . $ds . 'run' . $ds . $run["extension"]; + if(!is_file($script)) { + echo "Failed to unzip the run script -- please check the problem package\n"; + DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: problem package file is invalid"); + continue; + } chmod($script, 0700); mkdir('team', 0755); - $d = opendir($dir . $ds . "input"); - while (($file = readdir($d)) !== false) { - if(is_file($dir . $ds . "input" . $ds . $file)) { - $ex = escapeshellcmd($script) ." ". - "run.exe ". - escapeshellarg($dir . $ds . "input" . $ds . $file)." ". - escapeshellarg(trim($limit[0]))." ". - escapeshellarg(trim($limit[1]))." ". - escapeshellarg(trim($limit[2])); - $ex .= " >stdout 2>stderr"; - echo "Executing " . $ex . " for input " . $file . "\n"; - if(system($ex, $retval)===false) $retval=-1; - foreach (glob($dir . $ds . '*') as $fne) { - @chown($fne,"nobody"); - @chmod($fne,0755); - } - if(is_readable('stderr0')) - system('cat stderr0 >> stderr'); - system('echo ##### STDERR FOR FILE ' . escapeshellarg($file) . ' >> allerr'); - system('cat stderr >> allerr'); - system('cat stdout > team' . $ds . escapeshellarg($file)); - system('echo ##### STDOUT FOR FILE ' . escapeshellarg($file) . ' >> allout'); - system('cat stdout >> allout'); - if($retval != 0) { - list($retval,$answer) = exitmsg($retval); - $answer = "(WHILE RUNNING) " . $answer; - break; + if($ninputlist == 0) { + echo "Failed to read input files from ZIP -- please check the problem package\n"; + DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: problem package file is invalid"); + continue; + } else { + foreach($inputlist as $file) { + $file = basename($file); + if(is_file($dir . $ds . "input" . $ds . $file)) { + $ex = escapeshellcmd($script) ." ". + escapeshellarg($basename) . " ". + escapeshellarg($dir . $ds . "input" . $ds . $file)." ". + escapeshellarg(trim($limits[$basename][$run["extension"]][0]))." ". + escapeshellarg(trim($limits[$basename][$run["extension"]][1]))." ". + escapeshellarg(trim($limits[$basename][$run["extension"]][2])); + $ex .= " >stdout 2>stderr"; + echo "Executing " . $ex . " at " . getcwd() . " for input " . $file . "\n"; + if(system($ex, $retval)===false) $retval=-1; + foreach (glob($dir . $ds . '*') as $fne) { + @chown($fne,"nobody"); + @chmod($fne,0755); + } + if(is_readable('stderr0')) + system('cat stderr0 >> stderr'); + system('echo ##### STDERR FOR FILE ' . escapeshellarg($file) . ' >> allerr'); + system('cat stderr >> allerr'); + system('cat stdout > team' . $ds . escapeshellarg($file)); + system('echo ##### STDOUT FOR FILE ' . escapeshellarg($file) . ' >> allout'); + system('cat stdout >> allout'); + if($retval != 0) { + list($retval,$answer) = exitmsg($retval); + $answer = "(WHILE RUNNING) " . $answer; + break; + } + } else { + echo "==> ERROR reading input file " . $dir . $ds . "input" . $ds . $file . " - skipping it!\n"; } } } @@ -450,24 +385,24 @@ if($retval != 0) { echo "Processing results\n"; $zip = new ZipArchive; if ($zip->open($dir . $ds . $run["inputname"]) === true) { - $zip->extractTo($dir, array("compare" . $ds . $run["extension"],"output" . $ds . '*')); + $zip->extractTo($dir, array_merge(array("compare" . $ds . $run["extension"]),$outputlist)); $zip->close(); } else { - echo 'Failed to unzip the file (outputs) -- please check the problem package\n'; + echo "Failed to unzip the file (outputs) -- please check the problem package\n"; DBGiveUpRunAutojudging($contest, $site, $number, $ip, "Autojuging error: problem package file is invalid"); continue; } $script = $dir . $ds . 'compare' . $ds . $run["extension"]; $retval = 0; chmod($script, 0700); - $d = opendir($dir . $ds . "output"); - while (($file = readdir($d)) !== false) { - if(is_file($dir . $ds . "output" . $ds . $file)) { + foreach($outputlist as $file) { + $file = basename($file); + if(is_file($dir . $ds . 'output' . $ds . $file)) { $ex = escapeshellcmd($script) ." ". - escapeshellarg("team" . $ds . $file)." ". - escapeshellarg("output" . $ds . $file)." ". - escapeshellarg("input" . $ds . $file) . " >compout"; - echo "Executing " . $ex . "\n"; + escapeshellarg($dir . $ds . "team" . $ds . $file)." ". + escapeshellarg($dir . $ds . "output" . $ds . $file)." ". + escapeshellarg($dir . $ds . "input" . $ds . $file) . " >compout"; + echo "Executing " . $ex . " at " . getcwd() . " for output file $file\n"; $answer = system($ex, $localretval); $fp = fopen($dir . $ds . "allerr", "a+"); @@ -503,6 +438,8 @@ if($retval != 0) { $answer='Presentation error'; } } + } else { + echo "==> ERROR reading output file " . $dir . $ds . 'output' . $ds . $file . " - skipping it!\n"; } } } @@ -515,23 +452,16 @@ if($retval > 9) { "(run=$number, site=$site, contest=$contest)",1); echo "Autojudging script returned unusual code $retval ($anstmp)". "(contest=$contest, site=$site, run=$number)\n"; -// cleardir($dir); -// unlink($name); -// DBGiveUpRunAutojudging($contest, $site, $number, $ip, "(unusual code: $retval) " . $anstmp); -// continue; $answer = "(check output files - unusual code: $retval) " . $anstmp; - // contact staff $retval = 7; } -echo "Sending results to server\n"; +echo "Sending results to server...\n"; +echo "out==> "; system("tail -n1 ". $dir.$ds.'allout'); +echo "err==> "; system("tail -n1 ". $dir.$ds.'allerr'); DBUpdateRunAutojudging($contest, $site, $number, $ip, $answer, $dir.$ds.'allout', $dir.$ds.'allerr', $retval); LogLevel("Autojudging: answered '$answer' (run=$number, site=$site, contest=$contest)",3); echo "Autojudging answered '$answer' (contest=$contest, site=$site, run=$number)\n"; -if(!isset($dodebug)) { - cleardir($dir); - unlink($name); -} } ?> diff --git a/boca-1.5.0/src/team/header.php b/boca-1.5.0/src/team/header.php index 23c6d98..2690766 100644 --- a/boca-1.5.0/src/team/header.php +++ b/boca-1.5.0/src/team/header.php @@ -93,10 +93,10 @@ if(!isset($_SESSION["popuptime"]) || $_SESSION["popuptime"] < time()-120) { $_SESSION["usertable"]["usersitenumber"], $_SESSION["usertable"]["usernumber"]); for ($i=0; $i<count($clar); $i++) { - if ($clar[$i]["timestamp"]>$_SESSION["usertable"]["userlastlogin"]-$st["sitestartdate"] && - $clar[$i]["timestamp"] < $st['siteduration'] && - trim($clar[$i]["answer"])!='' && !isset($_SESSION["popups"]['clar' . $i . '-' . $clar[$i]["timestamp"]])) { - $_SESSION["popups"]['clar' . $i . '-' . $clar[$i]["timestamp"]] = "Clarification for problem ".$clar[$i]["problem"]." answered\n"; + if ($clar[$i]["anstime"]>$_SESSION["usertable"]["userlastlogin"]-$st["sitestartdate"] && + $clar[$i]["anstime"] < $st['siteduration'] && + trim($clar[$i]["answer"])!='' && !isset($_SESSION["popups"]['clar' . $i . '-' . $clar[$i]["anstime"]])) { + $_SESSION["popups"]['clar' . $i . '-' . $clar[$i]["anstime"]] = "Clarification for problem ".$clar[$i]["problem"]." answered\n"; } } $run = DBUserRuns($_SESSION["usertable"]["contestnumber"], @@ -112,14 +112,16 @@ if(!isset($_SESSION["popuptime"]) || $_SESSION["popuptime"] < time()-120) { } $str = ''; - foreach($_SESSION["popups"] as $key => $value) { - if($value != '') { - $str .= $value; - $_SESSION["popups"][$key] = ''; - } - } - if($str != '') { - MSGError('YOU GOT NEWS:\n' . $str . '\n'); + if(isset($_SESSION["popups"])) { + foreach($_SESSION["popups"] as $key => $value) { + if($value != '') { + $str .= $value; + $_SESSION["popups"][$key] = ''; + } + } + if($str != '') { + MSGError('YOU GOT NEWS:\n' . $str . '\n'); + } } } diff --git a/boca-1.5.0/tools/etc/icpc/createbocajail.sh b/boca-1.5.0/tools/etc/icpc/createbocajail.sh index e8e0d84..bd8bd5d 100644 --- a/boca-1.5.0/tools/etc/icpc/createbocajail.sh +++ b/boca-1.5.0/tools/etc/icpc/createbocajail.sh @@ -59,7 +59,7 @@ rm -rf /bocajail mkdir -p $homejail/tmp chmod 1777 $homejail/tmp ln -s $homejail /bocajail -[ -f /usr/bin/safeexec ] && cp -a /usr/bin/safeexec /bocajail/usr/bin/ +[ -x /usr/bin/safeexec ] && cp -a /usr/bin/safeexec /bocajail/usr/bin/ #for i in usr lib var bin sbin etc dev; do # [ -d $homejail/$i ] && rm -rf $homejail/$i # cp -ar /$i $homejail diff --git a/boca-1.5.0/tools/etc/icpc/installboca.sh b/boca-1.5.0/tools/etc/icpc/installboca.sh index 073d432..8f35e74 100644 --- a/boca-1.5.0/tools/etc/icpc/installboca.sh +++ b/boca-1.5.0/tools/etc/icpc/installboca.sh @@ -129,6 +129,7 @@ fi strip safeexec cp -f safeexec /usr/bin chmod 4555 /usr/bin/safeexec +[ -d /bocajail/usr/bin ] && cp -a /usr/bin/safeexec /bocajail/usr/bin/ echo "==================================================" echo "=================== SERVER SETUP ===============" diff --git a/boca-1.5.0/tools/icpc.etc.tgz b/boca-1.5.0/tools/icpc.etc.tgz Binary files differindex 11090b0..ccbb81b 100644 --- a/boca-1.5.0/tools/icpc.etc.tgz +++ b/boca-1.5.0/tools/icpc.etc.tgz diff --git a/boca-1.5.0/tools/safeexec.c b/boca-1.5.0/tools/safeexec.c index 1b08d17..0dfa867 100644 --- a/boca-1.5.0/tools/safeexec.c +++ b/boca-1.5.0/tools/safeexec.c @@ -52,7 +52,7 @@ int killallproc; int bequiet; int checknchild; int user, group; -const char vers[] = "1.4.1"; +const char vers[] = "1.5.0"; #define BUFFSIZE 256 char curdir[BUFFSIZE], rootdir[BUFFSIZE], saida[BUFFSIZE], entrada[BUFFSIZE], erro[BUFFSIZE]; @@ -72,14 +72,14 @@ unsigned int getprocs(pid_t ppid, pid_t ppid2, int userid, int groupid, int *nch void exitandkill(int ret) { if(killallproc) { if(!bequiet) - fprintf(stderr,"Notice: killing all recent processes from this user/group to avoid possible malicious code... use -K if you don't want this\n"); + fprintf(stderr,"safeexec: killing all recent processes from this user/group to avoid possible malicious code... use -K if you don't want this\n"); struct Proc *P; unsigned n; int nchild, i; if((n = getprocs(child_pid,getpid(),user,group,&nchild,&P)) > 0) { for(i = 0; i < n; i++) { if(!bequiet) - fprintf(stderr,"killing processes pid=%d\n", P[i].pid); + fprintf(stderr,"safeexec: killing processes pid=%d\n", P[i].pid); kill(P[i].pid,9); /* kill children and all processes with userid/groupid that started after us if instructed to do so */ } } @@ -89,7 +89,7 @@ void exitandkill(int ret) { case 7: fprintf(stderr,"safeexec: memory limit exceeded\n"); break; case 5: fprintf(stderr,"safeexec: parameter problem\n"); break; case 6: - case 4: fprintf(stderr,"ERROR: internal error\n"); break; + case 4: fprintf(stderr,"safeexec: ERROR! internal error\n"); break; case 3: fprintf(stderr,"safeexec: time limit exceeded\n"); break; case 2: fprintf(stderr,"safeexec: runtime error\n"); break; case 9: fprintf(stderr,"safeexec: runtime error\n"); break; @@ -111,7 +111,7 @@ unsigned int getprocs(pid_t ppid, pid_t ppid2, int userid, int groupid, int *nch P = calloc(globbuf.gl_pathc, sizeof(struct Proc)); if (P == NULL) { - if(!bequiet) fprintf(stderr,"problem with malloc"); + if(!bequiet) fprintf(stderr,"safeexec: problem with malloc"); exitandkill(4); } *Pr = P; @@ -174,7 +174,7 @@ unsigned int getprocs(pid_t ppid, pid_t ppid2, int userid, int groupid, int *nch P[i] = P[--j]; } else { if(!bequiet) - fprintf(stderr,"process %d has user %d, group %d, time %lu, which is suspicious\n",P[i].pid,userid,groupid,P[i].starttime); + fprintf(stderr,"safeexec: process %d has user %d, group %d, time %lu, which is suspicious\n",P[i].pid,userid,groupid,P[i].starttime); i++; } } @@ -193,8 +193,8 @@ int testsystem(pid_t p, pid_t pp, int userid, int groupid, double memlim, double if(checknchild) { if(nchild != n) { if(!bequiet) { - fprintf(stderr,"\n%d children of this user/group, but list has %d processes (who are the others?).\n",nchild,n); - fprintf(stderr,"detached children found! Aborting because of possible malicious code... use -a if you don't want this\n"); + fprintf(stderr,"\nsafeexec: %d children of this user/group, but list has %d processes (who are the others?).\n",nchild,n); + fprintf(stderr,"safeexec: detached children found! Aborting because of possible malicious code... use -a if you don't want this\n"); } exitandkill(8); } @@ -212,7 +212,7 @@ int testsystem(pid_t p, pid_t pp, int userid, int groupid, double memlim, double #endif if(mem2 > memlim || mem1 > rsslim) { if(!bequiet) - fprintf(stderr,"\nmemory limit exceeded\n"); + fprintf(stderr,"\nsafeexec: memory limit exceeded\n"); exitandkill(7); } if(nchild == 0) ret = 2; @@ -221,7 +221,7 @@ int testsystem(pid_t p, pid_t pp, int userid, int groupid, double memlim, double // fprintf(stderr,"WARNING: controlling only waited-for children! Security issues here if code is not trustful...\n"); if(mem1 > memlim) { if(!bequiet) - fprintf(stderr,"\nmemory limit exceeded of %lfMB\n",memlim/1048576.); + fprintf(stderr,"\nsafeexec: memory limit exceeded of %lfMB\n",memlim/1048576.); exitandkill(7); } ret = 0; @@ -239,7 +239,7 @@ void handle_alarm(int sig) { testsystem(child_pid,getpid(),allproc?user:-1,allproc?group:-1,max_data.rlim_max,max_rss.rlim_max); if(++iter >= real_timeout) { if(!bequiet) - fprintf(stderr, "timed-out (realtime) after %d seconds\n", real_timeout); + fprintf(stderr, "safeexec: timed-out (realtime) after %d seconds\n", real_timeout); fflush(stderr); kill(child_pid,9); /* kill child */ exitandkill(3); @@ -411,7 +411,7 @@ Use -U and -G for that, but you might need to have root privilegies.\n"); } currun++; if(!bequiet) - fprintf(stderr,"Starting the job. Parent controller has pid %d, child is %d...\n",getpid(),child_pid); + fprintf(stderr,"safeexec: starting the job. Parent controller has pid %d, child is %d...\n",getpid(),child_pid); alarm(1); /* set alarm and wait for child execution */ signal(SIGALRM, handle_alarm); while(waitpid(child_pid, &status, 0) != child_pid) ; @@ -427,7 +427,7 @@ Use -U and -G for that, but you might need to have root privilegies.\n"); if (dt + EPSILON >= cpu_timeout.rlim_max) { // printf ("utsec=%d utusec=%d stsec=%d stusec=%d\n", uso.ru_utime.tv_sec, uso.ru_utime.tv_usec, uso.ru_stime.tv_sec, uso.ru_stime.tv_usec); if(!bequiet) - fprintf(stderr, "timed-out (cputime) after %d seconds\n", (int) cpu_timeout.rlim_max); + fprintf(stderr, "safeexec: timed-out (cputime) after %d seconds\n", (int) cpu_timeout.rlim_max); fflush(stderr); // fprintf(stdout, "timed-out (cputime) after %d seconds\n", (int) cpu_timeout.rlim_max); // fflush(stdout); |