aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/team/getfile.php4
-rw-r--r--src/team/run.php158
-rwxr-xr-xtools/boca-submit-run29
-rwxr-xr-xtools/boca-submit-run-aux53
-rwxr-xr-xtools/boca-submit-run-cron8
-rwxr-xr-xtools/boca-submit-run-root22
-rwxr-xr-xtools/etc/icpc/bocaserver.sh1
-rwxr-xr-xtools/etc/icpc/installboca.sh39
-rwxr-xr-xtools/etc/icpc/setup.sh3
-rw-r--r--tools/etc/icpc/update.sh.tmp40
-rw-r--r--tools/etc/network/if-pre-up.d/boca2
-rwxr-xr-xtools/install_14_04_3.sh3
-rwxr-xr-xtools/installv2.sh3
13 files changed, 211 insertions, 154 deletions
diff --git a/src/team/getfile.php b/src/team/getfile.php
index 8c594d0..cbb7fed 100644
--- a/src/team/getfile.php
+++ b/src/team/getfile.php
@@ -25,8 +25,8 @@ if(($st = DBSiteInfo($_SESSION["usertable"]["contestnumber"],$_SESSION["usertabl
$fn = tempnam("/tmp","bkp-");
$fout = fopen($fn,"wb");
-echo $_POST;
-echo $_POST['data'];
+//echo $_POST;
+//echo $_POST['data'];
fwrite($fout,base64_decode($_POST['data']));
fclose($fout);
$size=filesize($fn);
diff --git a/src/team/run.php b/src/team/run.php
index 9641386..caf3b3d 100644
--- a/src/team/run.php
+++ b/src/team/run.php
@@ -20,12 +20,12 @@ require('header.php');
$ds = DIRECTORY_SEPARATOR;
if($ds=="") $ds = "/";
-if (isset($_FILES["sourcefile"]) && isset($_POST["problem"]) && isset($_POST["Submit"]) && isset($_POST["language"]) &&
- is_numeric($_POST["problem"]) && is_numeric($_POST["language"]) && $_FILES["sourcefile"]["name"]!="") {
- if ($_POST["confirmation"] == "confirm") {
+if (isset($_POST["problem"]) && isset($_POST["language"]) &&
+ ((isset($_FILES["sourcefile"]) && isset($_POST["Submit"]) && $_FILES["sourcefile"]["name"]!="") || (isset($_POST["data"]) && isset($_POST["name"])))) {
+ if ($_POST["confirmation"] == "confirm" || (isset($_POST["data"]) && isset($_POST["name"]))) {
if(($ct = DBContestInfo($_SESSION["usertable"]["contestnumber"])) == null) {
- if(isset($_POST['pastcode']) && $_POST['pastcode'] != '') {
- echo "RESULT: CONTEST NOT FOUND";
+ if(isset($_POST['name']) && $_POST['name'] != '') {
+ echo "\nRESULT: CONTEST NOT FOUND";
exit;
}
ForceLoad("../index.php");
@@ -33,62 +33,77 @@ if (isset($_FILES["sourcefile"]) && isset($_POST["problem"]) && isset($_POST["Su
$prob = myhtmlspecialchars($_POST["problem"]);
$lang = myhtmlspecialchars($_POST["language"]);
- $probs = DBGetProblems($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usertype"]=='judge');
- $i = 0;
- $ss = "";
- for (;$i<count($probs);$i++) {
- if($probs[$i]["problem"]==$prob) break;
- $ss .= $probs[$i]["problem"] . " ";
- }
- if($i >= count($probs)) {
- echo "RESULT: INVALID PROBLEM (options are: " . $ss . ")";
+ if(!is_numeric($prob)) {
+ $probs = DBGetProblems($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usertype"]=='judge');
+ $i = 0;
+ $ss = "";
+ for (;$i<count($probs);$i++) {
+ if($probs[$i]["problem"]==$prob) {
+ $prob = $probs[$i]["number"];
+ break;
+ }
+ $ss .= $probs[$i]["problem"] . " ";
+ }
+ if($i >= count($probs)) {
+ echo "\nRESULT: INVALID PROBLEM (options are: " . $ss . ")";
exit;
+ }
}
- $langs = DBGetLanguages($_SESSION["usertable"]["contestnumber"]);
- $i = 0;
- $ss = "";
- for (;$i<count($langs);$i++) {
- if($langs[$i]["name"]==$lang) break;
- $ss .= $langs[$i]["name"] . " ";
- }
- if($i >= count($langs)) {
- echo "RESULT: INVALID LANGUAGE (options are: " . $ss . ")";
- exit;
- }
-
- $type=myhtmlspecialchars($_FILES["sourcefile"]["type"]);
- $size=myhtmlspecialchars($_FILES["sourcefile"]["size"]);
- $name=myhtmlspecialchars($_FILES["sourcefile"]["name"]);
- $temp=myhtmlspecialchars($_FILES["sourcefile"]["tmp_name"]);
-
- if ($size > $ct["contestmaxfilesize"]) {
- LOGLevel("User {$_SESSION["usertable"]["username"]} tried to submit file " .
- "$name with $size bytes ({$ct["contestmaxfilesize"]} max allowed).", 1);
- if(isset($_POST['pastcode']) && $_POST['pastcode'] != '') {
- echo "RESULT: FILE TOO LARGE";
+ if(!is_numeric($lang)) {
+ $langs = DBGetLanguages($_SESSION["usertable"]["contestnumber"]);
+ $i = 0;
+ $ss = "";
+ for (;$i<count($langs);$i++) {
+ if($langs[$i]["name"]==$lang) {
+ $lang = $langs[$i]["number"];
+ break;
+ }
+ $ss .= $langs[$i]["name"] . " ";
+ }
+ if($i >= count($langs)) {
+ echo "\nRESULT: INVALID LANGUAGE (options are: " . $ss . ")";
exit;
}
- MSGError("File size exceeds the limit allowed.");
- ForceLoad($runteam);
}
- if(strpos($name,' ') === true || strpos($temp,' ') === true) {
- if(isset($_POST['pastcode']) && $_POST['pastcode'] != '') {
- echo "RESULT: FILE NAME CANNOT HAVE SPACES";
+ if(isset($_POST['name']) && $_POST['name'] != '') {
+ $temp = tempnam("/tmp","bkp-");
+ $fout = fopen($temp,"wb");
+ fwrite($fout,base64_decode($_POST['data']));
+ fclose($fout);
+ $size=filesize($temp);
+ $name=$_POST['name'];
+ if ($size > $ct["contestmaxfilesize"] || strlen($name)>100 || strlen($name)<1) {
+ echo "\nRESULT: SUBMITTED FILE (OR NAME) TOO LARGE";
exit;
}
- MSGError("File name cannot contain spaces.");
- ForceLoad($runteam);
+ } else {
+ $type=myhtmlspecialchars($_FILES["sourcefile"]["type"]);
+ $size=myhtmlspecialchars($_FILES["sourcefile"]["size"]);
+ $name=myhtmlspecialchars($_FILES["sourcefile"]["name"]);
+ $temp=myhtmlspecialchars($_FILES["sourcefile"]["tmp_name"]);
+
+ if ($size > $ct["contestmaxfilesize"]) {
+ LOGLevel("User {$_SESSION["usertable"]["username"]} tried to submit file " .
+ "$name with $size bytes ({$ct["contestmaxfilesize"]} max allowed).", 1);
+ MSGError("File size exceeds the limit allowed.");
+ ForceLoad($runteam);
+ }
+ if (!is_uploaded_file($temp) || strlen($name)>100) {
+ IntrusionNotify("file upload problem.");
+ ForceLoad("../index.php");
+ }
}
- if (!is_uploaded_file($temp) || strlen($name)>100) {
- if(isset($_POST['pastcode']) && $_POST['pastcode'] != '') {
- echo "RESULT: FILE UPLOAD PROBLEM";
+ if(strpos($name,' ') === true || strpos($temp,' ') === true || strpos($name,'/') === true || strpos($temp,'/') === true ||
+ strpos($name,'`') === true || strpos($temp,'`') === true || strpos($name,'\'') === true || strpos($temp,'\'') === true ||
+ strpos($name, "\"") === true || strpos($temp, "\"") === true || strpos($name,'$') === true || strpos($temp,'$') === true) {
+ if(isset($_POST['name']) && $_POST['name'] != '') {
+ echo "\nRESULT: FILE NAME PROBLEM (EG CANNOT HAVE SPACES)";
exit;
}
- IntrusionNotify("file upload problem.");
- ForceLoad("../index.php");
+ MSGError("File name cannot contain spaces.");
+ ForceLoad($runteam);
}
-
$ac=array('contest','site','user','problem','lang','filename','filepath');
$ac1=array('runnumber','rundate','rundatediff','rundatediffans','runanswer','runstatus','runjudge','runjudgesite',
'runjudge1','runjudgesite1','runanswer1','runjudge2','runjudgesite2','runanswer2',
@@ -105,12 +120,16 @@ if (isset($_FILES["sourcefile"]) && isset($_POST["problem"]) && isset($_POST["Su
$pastcode = myhtmlspecialchars($_POST["pastcode"]);
if(isset($_POST["pasthash"]) && isset($_POST["pastval"])) {
$pasthash = myhtmlspecialchars($_POST["pasthash"]);
+ $pastvalhash = myhtmlspecialchars($_POST["pastvalhash"]);
$pastval = myhtmlspecialchars($_POST["pastval"]);
$pastabs = myhtmlspecialchars($_POST["pastabs"]);
- $pastsubmission = myhash(@file_get_contents($_SESSION["locr"] . $ds . "private" . $ds . 'run-past.config') . $pastcode . $pastabs);
- if($pastsubmission != $pasthash) {
- echo "\nRESULT: INVALID SUBMISSION CODE";
- exit;
+ $pastsubmission = myhash(trim(@file_get_contents($_SESSION["locr"] . $ds . "private" . $ds . 'run-past.config')) . $pastcode . $pastval);
+ if($pastsubmission != $pastvalhash) {
+ $pastsubmission = myhash(trim(@file_get_contents($_SESSION["locr"] . $ds . "private" . $ds . 'run-past.config')) . $pastcode . $pastabs);
+ if($pastsubmission != $pasthash) {
+ echo "\nRESULT: INVALID SUBMISSION CODE";
+ exit;
+ }
}
} else {
$pastval = 0;
@@ -118,27 +137,38 @@ if (isset($_FILES["sourcefile"]) && isset($_POST["problem"]) && isset($_POST["Su
$verify = $pastcode . '-' .$_SESSION["usertable"]["contestnumber"].'-'.$_SESSION["usertable"]["usersitenumber"].'-'.$_SESSION["usertable"]["usernumber"];
$fcname = $_SESSION["locr"] . $ds . "private" . $ds . 'laterun-submitted-' . $_SESSION["usertable"]["contestnumber"].'-'.
$_SESSION["usertable"]["usersitenumber"].'-'.$_SESSION["usertable"]["usernumber"].'.txt';
- $codes = @file($fcname);
+ $codes = @file($fcname,FILE_IGNORE_NEW_LINES);
if(in_array($verify,$codes)) {
echo "\nRESULT: RUN ALREADY SUBMITTED";
} else {
if($pastval > 0) {
$param['rundate']=time() - $pastval;
- $b = DBSiteInfo($contest, $site, $c);
+ $b = DBSiteInfo($_SESSION["usertable"]["contestnumber"], $_SESSION["usertable"]["usersitenumber"]);
$dif = $b["currenttime"];
$param['rundatediff']=$dif - $pastval;
}
if(DBNewRun ($param) == 2)
- @file_put_contents($fcname, $verify . '\n', FILE_APPEND | LOCK_EX);
- echo "\nRESULT: RUN SUBMITTED SUCCESSFULLY";
+ @file_put_contents($fcname, $verify . "\n", FILE_APPEND | LOCK_EX);
+ echo "\nRESULT: RUN SUBMITTED SUCCESSFULLY ($pastval)";
}
exit;
}
- DBNewRun ($param);
+ $retv = DBNewRun ($param);
+ if(isset($_POST['name']) && $_POST['name'] != '') {
+ if($retv == 2)
+ echo "\nRESULT: RUN SUBMITTED SUCCESSFULLY";
+ else
+ echo "\nRESULT: UNKNOWN PROBLEM";
+ exit;
+ }
$_SESSION['forceredo']=true;
}
ForceLoad($runteam);
}
+if(isset($_POST['name']) && $_POST['name'] != '') {
+ echo "RESULT: PARAMETERS MISSING";
+ exit;
+}
$runtmp = $_SESSION["locr"] . $ds . "private" . $ds . "runtmp" . $ds . "run-contest" . $_SESSION["usertable"]["contestnumber"] .
"-site". $_SESSION["usertable"]["usersitenumber"] . "-user" . $_SESSION["usertable"]["usernumber"] . ".php";
@@ -200,19 +230,19 @@ if (count($run) == 0) $strtmp .= "<br><center><b><font color=\"#ff0000\">NO RUNS
$linesubmission = @file_get_contents($_SESSION["locr"] . $ds . "private" . $ds . 'run-using-command.config');
if(trim($linesubmission) == '1') {
-$strtmp .= "<br><br><center><b>To submit a program, use the command-line tool:</b>\n<br><br>".
- "<pre>boca-submit-run USER PASSWORD PROBLEM LANGUAGE FILE</pre><br><br>".
- "where <pre>USER</pre> is your username, <pre>PASSWORD</pre> is your password, <pre>FILE</pre> is your submission file,<br>".
- "<pre>PROBLEM</pre> is one of { <pre>";
+$strtmp .= "<br><br><center><b>To submit a program, use the command-line tool:</b>\n<br>".
+ "<pre>boca-submit-run USER PASSWORD PROBLEM LANGUAGE FILE</pre><br>".
+ "where USER is your username, PASSWORD is your password, FILE is your submission file,<br>".
+ "PROBLEM is one of { ";
$prob = DBGetProblems($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usertype"]=='judge');
for ($i=0;$i<count($prob);$i++)
$strtmp .= $prob[$i]["problem"] . " ";
-$strtmp .= "</pre>} and<br><pre>LANGUAGE</pre> is one of { <pre>"
+$strtmp .= "} and<br>LANGUAGE is one of { ";
$lang = DBGetLanguages($_SESSION["usertable"]["contestnumber"]);
for ($i=0;$i<count($lang);$i++)
$strtmp .= $lang[$i]["name"] . " ";
-$strtmp .= "</pre>}<br><br>\n";
+$strtmp .= "}<br><br>\n";
} else {
$strtmp .= "<br><br><center><b>To submit a program, just fill in the following fields:</b></center>\n".
diff --git a/tools/boca-submit-run b/tools/boca-submit-run
index 78e79bd..d67c83f 100755
--- a/tools/boca-submit-run
+++ b/tools/boca-submit-run
@@ -42,30 +42,33 @@ fi
runaux=`which boca-submit-run-aux`
if [ "$runaux" == "" ]; then
- runaux=/var/www/boca/tools/boca-submit-run-aux
+ runaux=/usr/bin/boca-submit-run-aux
fi
-runroot=`which boca-submit-run-root`
+runroot=`which boca-submit-run-root-wrapper`
if [ "$runroot" == "" ]; then
- runroot=/var/www/boca/tools/boca-submit-run-root
+ runroot=/usr/bin/boca-submit-run-root-wrapper
fi
if [ -r "$5" ]; then
nom=`echo -n "$5" | perl -MURI::Escape -lne 'print uri_escape($_)'`
- for BOCASERVER in `echo $BOCASERVERS | cut -d';'`; do
- echo "$BOCASERVER: time-out - this will automatically retry soon, you should not worry"
+ for BOCASERVER in `echo $BOCASERVERS | tr ';' ' '`; do
echo "BOCASERVER=$BOCASERVER" > $temp
- echo "user=$user" >> $temp
- echo "pass=$pass" >> $temp
- echo "name=${nom}" >> $temp
- echo -n "data=" >> $temp
- uuencode -m zzzzzzzzzz < "$5" | grep -v "begin-base64.*zzzzzzzzzz" | perl -MURI::Escape -lne 'print uri_escape($_)' >> $temp
- echo "" >> $temp
+ echo "user=$1" >> $temp
+ echo "pass=$2" >> $temp
+ echo "problem=$3" >> $temp
+ echo "language=$4" >> $temp
+ echo "name=`basename $5`" >> $temp
+ uniq=`sha256sum "$5" | cut -f1 -d' '`
+ echo "uniq=$uniq" >> $temp
+ echo -en "data=\"" >> $temp
+ uuencode -m zzzzzzzzzz < "$5" | grep -v "begin-base64.*zzzzzzzzzz" >> $temp
+ echo -e "\"" >> $temp
$runaux $temp
if [ "$?" == "2" ]; then
echo "$BOCASERVER: time-out - this will automatically retry soon, you should not worry"
- $runroot $temp
+ $runroot "$BOCASERVER" "$1" "$2" "$3" "$4" "`basename $5`" "$5"
fi
- rm $temp
+ [ -f "$temp" ] && rm -f $temp
done
else
echo "file $1 not found/readable"
diff --git a/tools/boca-submit-run-aux b/tools/boca-submit-run-aux
index a9ff432..1be0945 100755
--- a/tools/boca-submit-run-aux
+++ b/tools/boca-submit-run-aux
@@ -5,6 +5,10 @@ if [ "$BOCASERVER" == "" -o "$user" == "" -o "$pass" == "" -o "$data" == "" -o "
echo "parameters missing in file $1"
exit 1
fi
+if [ "$problem" == "" -o "$language" == "" ]; then
+ echo "parameters missing in file $1"
+ exit 1
+fi
for i in uuencode wget tr perl sha256sum cut; do
p=`which $i`
@@ -17,49 +21,64 @@ for i in uuencode wget tr perl sha256sum cut; do
done
temp=/tmp/.temp.`date +%s%N`.txt
-md=`wget -t 2 -T 7 -S http://$BOCASERVER/boca/index.php -O /dev/null --save-cookies /tmp/.cookie.txt --keep-session-cookies 2>&1 | grep PHPSESS | tail -n1`
+md=`wget -t 2 -T 5 -S http://$BOCASERVER/boca/index.php -O /dev/null --save-cookies ${temp}.cookie.txt --keep-session-cookies 2>&1 | grep PHPSESS | tail -n1`
echo "$md" | grep -q PHPSESS
if [ "$?" == "0" ]; then
md=`echo $md | cut -f2 -d'=' | cut -f1 -d';'`
res=`echo -n $pass | sha256sum - | cut -f1 -d' '`
res=`echo -n "${res}${md}" | sha256sum - | cut -f1 -d' '`
- wget -t 2 -T 7 "http://$BOCASERVER/boca/index.php?name=${user}&password=${res}" --load-cookies /tmp/.cookie.txt --keep-session-cookies --save-cookies /tmp/.cookie.txt -O $temp 2>/dev/null >/dev/null
+ wget -t 2 -T 5 "http://$BOCASERVER/boca/index.php?name=${user}&password=${res}" --load-cookies ${temp}.cookie.txt --keep-session-cookies --save-cookies ${temp}.cookie.txt -O $temp 2>/dev/null >/dev/null
grep -qi incorrect $temp
if [ $? == 0 ]; then
echo "$BOCASERVER: User or password incorrect"
rm -f $temp
- rm -f /tmp/.cookie.txt
+ rm -f ${temp}.cookie.txt
exit 3
else
- echo -n "name=${nom}" > $temp
+ echo -n "name=`echo $name | perl -MURI::Escape -lne 'print uri_escape($_)'`" > $temp
if [ "$uniq" != "" ]; then
echo -n "&pastcode=$uniq" >> $temp
if [ "$code" != "" ]; then
echo -n "&pasthash=$code" >> $temp
- if [ "$dateerr" != "" ]; then
- echo -n "&pastabs=${dateerr}"
- let "dateerr = `date +%s` - $dateerr"
- echo -n "&pastval=${dateerr}"
+ fi
+ if [ "$dateerr" != "" ]; then
+ echo -n "&pastabs=${dateerr}" >> $temp
+ let "dateerr = `date +%s` - $dateerr"
+ echo -n "&pastval=${dateerr}" >> $temp
+ if [ -r /root/submissions/code ]; then
+ code=`cat /root/submissions/code`
+ res=`echo -n "${code}${uniq}${dateerr}" | sha256sum - | cut -f1 -d' '`
+ echo -n "&pastvalhash=${res}" >> $temp
fi
fi
fi
-
- echo -n "&data=" >> $temp
- uuencode -m zzzzzzzzzz < $1 | grep -v "begin-base64.*zzzzzzzzzz" | perl -MURI::Escape -lne 'print uri_escape($_)' >> $temp
- wget -t 2 -T 7 "http://$BOCASERVER/boca/team/run.php" --load-cookies /tmp/.cookie.txt --keep-session-cookies -O /dev/null --post-file=$temp >${temp}.out 2>/dev/null
+ echo -n "&problem=`echo $problem | perl -MURI::Escape -lne 'print uri_escape($_)'`" >> $temp
+ echo -n "&language=`echo $language | perl -MURI::Escape -lne 'print uri_escape($_)'`" >> $temp
+ echo -n "&data=`echo $data | tr -d ' ' | perl -MURI::Escape -lne 'print uri_escape($_)'`" >> $temp
+ wget -t 2 -T 5 "http://$BOCASERVER/boca/team/run.php" --load-cookies ${temp}.cookie.txt --keep-session-cookies -O ${temp}.out --post-file=$temp >/dev/null 2>/dev/null
res=`tail -n1 ${temp}.out`
echo $res | grep -q "RESULT:"
if [ "$?" == "0" ]; then
- echo "$BOCASERVER : run $uniq dateerr $dateerr : $res"
- rm -f "$1"
+ if [ "$uniq" == "" ]; then
+ echo "$BOCASERVER : $res"
+ else
+ echo "$BOCASERVER : run $uniq dateerr $dateerr : $res"
+ fi
else
- echo "$BOCASERVER : run $uniq dateerr $dateerr : error to upload the run, will NOT try again, check details"
+ if [ "$uniq" == "" ]; then
+ echo "$BOCASERVER : error to upload the run, will NOT try again, check details"
+ else
+ echo "$BOCASERVER : run $uniq dateerr $dateerr : error to upload the run, will NOT try again, check details:"
+ cat ${temp}.out
+ fi
+ rm -f ${temp}.out
+ exit 4
fi
rm -f ${temp}.out
fi
- rm -f $temp
- rm -f /tmp/.cookie.txt
+ [ -f "$temp" ] && rm -f "$temp"
+ rm -f ${temp}.cookie.txt
else
exit 2
fi
diff --git a/tools/boca-submit-run-cron b/tools/boca-submit-run-cron
index 83f5b41..64d55ee 100755
--- a/tools/boca-submit-run-cron
+++ b/tools/boca-submit-run-cron
@@ -15,6 +15,14 @@ if [ -d /root/submissions ]; then
for i in `ls /root/submissions/*.bocarun`; do
if [ "$i" != "/root/submissions/placeholder.bocarun" ]; then
$runaux "$i"
+ res=$?
+ if [ "$res" == "2" ]; then
+ echo "$i: time-out - this will automatically retry soon"
+ fi
+ if [ "$res" == "0" ]; then
+ mv "$i" "${i}.processed"
+ fi
fi
done
fi
+
diff --git a/tools/boca-submit-run-root b/tools/boca-submit-run-root
index a6d205a..4cc2231 100755
--- a/tools/boca-submit-run-root
+++ b/tools/boca-submit-run-root
@@ -5,18 +5,26 @@ if [ "`id -u`" != "0" ]; then
exit 1
fi
-fnam=`echo "$1" | tr -cd '[[:alnum:]]._-/'`
-if [ "$fnam" != "" -a -r "$fnam" ]; then
+if [ "$7" != "" ]; then
mkdir -p /root/submissions
chown root /root/submissions
chmod 700 /root/submissions
nom=/root/submissions/`date +%s%N`.bocarun.tmp
- cat "$fnam" | tr -cd '[[:alnum:]]._+-/= ' > "$nom"
-
- echo "dateerr=`date +%s`" >> "$nom"
- uniq=`date +%sN`-`sha256sum "$1"`
- uniq=`echo $uniq | sha256sum - | cut -f1 -d' '`
+ echo "BOCASERVER=`echo $1 | tr -cd '[[:alnum:]]._+-/'`" > "$nom"
+ echo "user=`echo $2 | tr -cd '[[:alnum:]]._+-/'`" >> "$nom"
+ echo "pass=`echo $3 | tr -cd '[[:alnum:]]._+-/'`" >> "$nom"
+ echo "problem=`echo $4 | tr -cd '[[:alnum:]]._+-/'`" >> "$nom"
+ echo "language=`echo $5 | tr -cd '[[:alnum:]]._+-/'`" >> "$nom"
+ echo "name=`echo $6 | tr -cd '[[:alnum:]]._+-/'`" >> "$nom"
+ echo -en "data=\"" >> "$nom"
+ uuencode -m zzzzzzzzzz < `echo "$7" | tr -cd '[[:alnum:]]._+-/'` | grep -v "begin-base64.*zzzzzzzzzz" >> "$nom"
+ echo "\"" >> "$nom"
+ dateerr=`date +%s`
+ echo "dateerr=$dateerr" >> "$nom"
+# uniq=`date +%sN`-`sha256sum "$7"`
+# uniq=`echo $uniq | sha256sum - | cut -f1 -d' '`
+ uniq=`sha256sum "$7" | cut -f1 -d' '`
code=`cat /root/submissions/code`
res=`echo -n "${code}${uniq}${dateerr}" | sha256sum - | cut -f1 -d' '`
echo "uniq=$uniq" >> "$nom"
diff --git a/tools/etc/icpc/bocaserver.sh b/tools/etc/icpc/bocaserver.sh
deleted file mode 100755
index 8bb6c2c..0000000
--- a/tools/etc/icpc/bocaserver.sh
+++ /dev/null
@@ -1 +0,0 @@
-BOCASERVER=127.0.0.1
diff --git a/tools/etc/icpc/installboca.sh b/tools/etc/icpc/installboca.sh
index 28eb0c7..88c266f 100755
--- a/tools/etc/icpc/installboca.sh
+++ b/tools/etc/icpc/installboca.sh
@@ -128,15 +128,42 @@ chmod -R g+rx,u+rwx boca-$bocaver/
chmod 600 boca-$bocaver/src/private/*.php
[ -f boca-$bocaver.$di/src/private/remotescores/otherservers ] && cp -f boca-$bocaver.$di/src/private/remotescores/otherservers boca-$bocaver/src/private/remotescores/otherservers
if [ "$OK" == "y" ]; then
- cp -f $conffile boca-$bocaver/src/private/conf.php
+ cp -f $conffile boca-$bocaver/src/private/conf.php
+ [ -f boca-$bocaver.$di/src/private/run-using-command.config ] && cp -f boca-$bocaver.$di/src/private/run-using-command.config boca-$bocaver/src/private/run-using-command.config
fi
chmod 700 boca-$bocaver/tools/*.sh
-chmod 755 boca-$bocaver/tools/boca-submit-run*
-chmod 700 boca-$bocaver/tools/boca-submit-run-cron
-chown root.root boca-$bocaver/tools/boca-submit-run-root
-chmod 4555 boca-$bocaver/tools/boca-submit-run-root
-echo "*/2 * * * * * root `pwd`/boca-$bocaver/tools/boca-submit-run-cron" > /etc/cron.d/boca
+if [ -f boca-$bocaver.$di/src/private/run-past.config ]; then
+ cp -f boca-$bocaver.$di/src/private/run-past.config boca-$bocaver/src/private/run-past.config
+else
+ echo "`date +%sN`-sha256sum-`date +%sN`" | sha256sum - | cut -d' ' -f1 > boca-$bocaver/src/private/run-past.config
+fi
+chmod 550 boca-$bocaver/src/private/run-past.config
+chown www-data.www-data boca-$bocaver/src/private/run-past.config
+
+cp boca-$bocaver/tools/boca-submit-run* /usr/bin/
+chmod 755 /usr/bin/boca-submit-run*
+chmod 700 /usr/bin/boca-submit-run-cron
+
+cat > /tmp/boca-submit-run-root-wrapper.c <<EOF
+#include<stdlib.h>
+#include<stdio.h>
+#include<sys/types.h>
+#include<unistd.h>
+char str[10000];
+int main(int argc, char **argv) {
+ if(argc != 8) return 1;
+ sprintf(str,"/usr/bin/boca-submit-run-root %1000s %1000s %1000s %1000s %1000s %1000s %1000s",argv[1],argv[2],argv[3],argv[4],argv[5],argv[6],argv[7]);
+ setuid(0);
+ system(str);
+ return 0;
+}
+EOF
+gcc -o /usr/bin/boca-submit-run-root-wrapper /tmp/boca-submit-run-root-wrapper.c
+rm -f /tmp/boca-submit-run-root-wrapper.c
+chown root.root /usr/bin/boca-submit-run-root-wrapper
+chmod 4555 /usr/bin/boca-submit-run-root-wrapper
+echo "*/2 * * * * root /usr/bin/boca-submit-run-cron >>/var/log/bocacron.out 2>>/var/log/bocacron.err" > /etc/cron.d/boca
cat > boca-$bocaver/src/.htaccess <<EOF
php_flag output_buffering on
diff --git a/tools/etc/icpc/setup.sh b/tools/etc/icpc/setup.sh
index da5a334..5d8838f 100755
--- a/tools/etc/icpc/setup.sh
+++ b/tools/etc/icpc/setup.sh
@@ -15,7 +15,8 @@ If this is supposed to be the server, then leave it empty\nIf there are multiple
fi
FIRSTBOCA=`echo $IP | cut -d';' -f1`
echo "BOCASERVER=$FIRSTBOCA" > /etc/icpc/bocaserver.sh
- if [ "`echo $IP | cut -d';' -f2-`" != "" ]; then
+ echo $IP | grep -q ';'
+ if [ "$?" == "0" ]; then
echo "BOCASERVERS=`echo $IP | cut -d';' -f2-`" >> /etc/icpc/bocaserver.sh
fi
echo "$FIRSTBOCA boca boca" >> /etc/hosts
diff --git a/tools/etc/icpc/update.sh.tmp b/tools/etc/icpc/update.sh.tmp
deleted file mode 100644
index 63a3858..0000000
--- a/tools/etc/icpc/update.sh.tmp
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/bash
-if [ "`id -u`" != "0" ]; then
- echo "Script must run as root"
-fi
-
-echo "==================================================="
-echo "=================== checking for updates =========="
-echo "==================================================="
-
-wget -O /tmp/.boca.tmp "http://www.ime.usp.br/~cassio/boca/update.date.txt"
-if [ $? != 0 ]; then
- echo "ERROR DOWNLOADING UPDATE"
- exit 1
-fi
-di=`cat /tmp/.boca.tmp`
-lastu=0
-if [ -r /etc/icpc/.lastupdate ]; then
- lastu=`cat /etc/icpc/.lastupdate`
-fi
-if [ "$di" == "$lastu" ]; then
- echo "NO UPDATES AVAILABLE"
- exit 0
-fi
-
-echo ">>>>>>>>>>"
-echo ">>>>>>>>>> Downloading update release `cat /tmp/.boca.tmp`"
-echo ">>>>>>>>>>"
-
-wget -O /tmp/.boca.tmp "http://www.ime.usp.br/~cassio/boca/update.sh"
-if [ $? != 0 ]; then
- echo "ERROR DOWNLOADING UPDATE"
- exit 1
-fi
-
-echo ">>>>>>>>>>"
-echo ">>>>>>>>>> Running update script"
-echo ">>>>>>>>>>"
-chmod 755 /tmp/.boca.tmp
-/tmp/.boca.tmp
-exit $?
diff --git a/tools/etc/network/if-pre-up.d/boca b/tools/etc/network/if-pre-up.d/boca
index 3e5eb5b..20ff38f 100644
--- a/tools/etc/network/if-pre-up.d/boca
+++ b/tools/etc/network/if-pre-up.d/boca
@@ -15,7 +15,7 @@ if [ "$BOCASERVER" != "" ]; then
/sbin/iptables -A INPUT -s $BOCASERVER -j ACCEPT
fi
if [ "$BOCASERVERS" != "" ]; then
- for i in `echo $BOCASERVERS | cut -d';'`; do
+ for i in `echo $BOCASERVERS | tr ';' ' '`; do
/sbin/iptables -A INPUT -s $i -j ACCEPT
done
fi
diff --git a/tools/install_14_04_3.sh b/tools/install_14_04_3.sh
index bf5ed20..d4f180e 100755
--- a/tools/install_14_04_3.sh
+++ b/tools/install_14_04_3.sh
@@ -35,7 +35,6 @@ fi
# find /usr/lib -name notify-osd | xargs chmod -x
# killall notify-osd 2>/dev/null
apt-get -y install python-software-properties 2>/dev/null
-gconftool -s -t bool /apps/update-notifier/auto_launch false
for i in id chown chmod cut awk tail grep cat sed mkdir rm mv sleep apt-get add-apt-repository update-alternatives; do
p=`which $i`
@@ -177,6 +176,8 @@ EOF
cp /usr/share/applications/gnome-terminal.desktop /etc/skel/Desktop/
chmod 755 /etc/skel/Desktop/*.desktop
+[ "`which gconftool`" == "" ] || gconftool -s -t bool /apps/update-notifier/auto_launch false
+
pass=`echo -n icpc | makepasswd --clearfrom - --crypt-md5 | cut -d'$' -f2-`
pass=\$`echo $pass`
id -u icpc >/dev/null 2>/dev/null
diff --git a/tools/installv2.sh b/tools/installv2.sh
index bf5ed20..d4f180e 100755
--- a/tools/installv2.sh
+++ b/tools/installv2.sh
@@ -35,7 +35,6 @@ fi
# find /usr/lib -name notify-osd | xargs chmod -x
# killall notify-osd 2>/dev/null
apt-get -y install python-software-properties 2>/dev/null
-gconftool -s -t bool /apps/update-notifier/auto_launch false
for i in id chown chmod cut awk tail grep cat sed mkdir rm mv sleep apt-get add-apt-repository update-alternatives; do
p=`which $i`
@@ -177,6 +176,8 @@ EOF
cp /usr/share/applications/gnome-terminal.desktop /etc/skel/Desktop/
chmod 755 /etc/skel/Desktop/*.desktop
+[ "`which gconftool`" == "" ] || gconftool -s -t bool /apps/update-notifier/auto_launch false
+
pass=`echo -n icpc | makepasswd --clearfrom - --crypt-md5 | cut -d'$' -f2-`
pass=\$`echo $pass`
id -u icpc >/dev/null 2>/dev/null