diff options
| author | cassiopc <cassiopc@gmail.com> | 2012-10-20 12:24:23 +0000 |
|---|---|---|
| committer | cassiopc <cassiopc@gmail.com> | 2012-10-20 12:24:23 +0000 |
| commit | 9e75d473525446d0961a7567bcb8a1e672949df8 (patch) | |
| tree | a054cab8f262a6e9230bc572ecae25513572c99b /boca-1.5.1/tools | |
| parent | e457938928ba589b16f12a2e6d38922dd94b2a51 (diff) | |
| download | boca-9e75d473525446d0961a7567bcb8a1e672949df8.tar.gz boca-9e75d473525446d0961a7567bcb8a1e672949df8.zip | |
fixed team login issue, included empty default options in submission tab, included extra-packages and links in ICPC Linux
Diffstat (limited to 'boca-1.5.1/tools')
| -rwxr-xr-x | boca-1.5.1/tools/etc/icpc/becomeserver.sh | 10 | ||||
| -rwxr-xr-x | boca-1.5.1/tools/etc/icpc/doclean.sh | 5 | ||||
| -rwxr-xr-x | boca-1.5.1/tools/etc/icpc/installboca.sh | 26 | ||||
| -rw-r--r-- | boca-1.5.1/tools/icpc.etc.tgz | bin | 8653 -> 9583 bytes | |||
| -rwxr-xr-x | boca-1.5.1/tools/installv2.sh | 40 | ||||
| -rw-r--r-- | boca-1.5.1/tools/safeexec.c | 22 |
6 files changed, 89 insertions, 14 deletions
diff --git a/boca-1.5.1/tools/etc/icpc/becomeserver.sh b/boca-1.5.1/tools/etc/icpc/becomeserver.sh index 33bebea..4de2084 100755 --- a/boca-1.5.1/tools/etc/icpc/becomeserver.sh +++ b/boca-1.5.1/tools/etc/icpc/becomeserver.sh @@ -95,6 +95,16 @@ for i in `ls /etc/postgresql/*/main/pg_hba.conf`; do echo "==> IF YOU HAVE MULTIPLE AUTOJUDGE MACHINES, WRITE ONE LINE FOR EACH IP ADDRESS THERE IN THE FILE <==" echo "############" echo "host bocadb bocauser 0/0 md5" >> $i + else + echo "############" + echo "IT SEEMS YOU ALREADY HAVE MODIFIED THE FILE $i WITH BOCA'S INFORMATION" + echo "I WOULD USE THE LINE:" + echo "" + echo -e "echo \"host bocadb bocauser 0/0 md5\" >> $i" + echo "" + echo "to give access to the database to other computers, but" + echo ">>> I'M NOT DOING IT -- PLEASE CHECK IT <<<" + echo "############" fi done diff --git a/boca-1.5.1/tools/etc/icpc/doclean.sh b/boca-1.5.1/tools/etc/icpc/doclean.sh index ea7d517..40b49c1 100755 --- a/boca-1.5.1/tools/etc/icpc/doclean.sh +++ b/boca-1.5.1/tools/etc/icpc/doclean.sh @@ -4,11 +4,11 @@ if [ -f /home/icpc/.cleandisk.sh ]; then rm -rf /home/icpc find /home -user icpc -delete if [ -x /usr/bin/makepasswd ]; then - pass=`echo -n icpc | makepasswd --clearfrom - --crypt-md5 | cut -d'$' -f2-` + pass=`echo -n icpc | /usr/bin/makepasswd --clearfrom - --crypt-md5 | cut -d'$' -f2-` pass=\$`echo $pass` id -u icpc >/dev/null 2>/dev/null if [ $? != 0 ]; then - useradd -d /home/icpc -m -p "$pass" -s /bin/bash -g users icpc + useradd -d /home/icpc -k /etc/skel -m -p "$pass" -s /bin/bash -g users icpc else usermod -d /home/icpc -p "$pass" -s /bin/bash -g users icpc fi @@ -23,6 +23,7 @@ if [ ! -d /home/icpc ]; then mv /home/skel /home/icpc fi chown -R icpc.users /home/icpc +chmod -R u+rwx /home/icpc fi cd - >/dev/null exit 0 diff --git a/boca-1.5.1/tools/etc/icpc/installboca.sh b/boca-1.5.1/tools/etc/icpc/installboca.sh index 8f35e74..d1cb842 100755 --- a/boca-1.5.1/tools/etc/icpc/installboca.sh +++ b/boca-1.5.1/tools/etc/icpc/installboca.sh @@ -1,4 +1,8 @@ #!/bin/bash +if [ "`id -u`" != "0" ]; then + echo "Script must run as root" +fi + di=`date +%s` echo "===================================================" echo "=================== obtaining BOCA ===============" @@ -15,7 +19,7 @@ bocaver=`cat /tmp/.boca.tmp` else bocaver=$1 fi -echo "Looking for BOCA version $bocaver from http://www.ime.usp.br/~cassio/boca/" + if [ "$2" == "" ]; then basedir=/var/www else @@ -27,6 +31,16 @@ exit 1 fi fi +OK=y +read -p "I will install boca at $basedir is it correct (otherwise, run this script as: $0 $bocaver <installdir> to choose the place) [Y/n]? " OK +if [ "$OK" == "y" -o "$OK" == "Y" ]; then +echo "Install directory is $basedir" +else +echo "Aborted" +exit 1 +fi + +echo "Looking for BOCA version $bocaver from http://www.ime.usp.br/~cassio/boca/" cd $basedir rm -f boca-$bocaver.tgz wget -O boca-$bocaver.tgz "http://www.ime.usp.br/~cassio/boca/download.php?filename=boca-$bocaver.tgz" @@ -55,7 +69,11 @@ echo "=================== EXTRACTING BOCA ===============" echo "=====================================================" OK=x -if [ -f boca-$bocaver.$di/src/private/conf.php ]; then +conffile=boca/src/private/conf.php +if [ ! -f $conffile ]; then +conffile=boca-$bocaver.$di/src/private/conf.php +fi +if [ -f $conffile ]; then echo "OLD CONFIG FILE EXISTS" OK=x while [ "$OK" != "y" -a "$OK" != "n" ]; do @@ -65,6 +83,8 @@ if [ -f boca-$bocaver.$di/src/private/conf.php ]; then if [ "$OK" == "n" ]; then echo "You probably need to update the new file boca-$bocaver/src/private/conf.php with the correct passwords - PLEASE CHECK IT - NOT DONE AUTOMATICALLY" fi +else + echo "OLD Config file not found -- you must set up the new private/conf.php file properly" fi apacheuser= @@ -83,7 +103,7 @@ 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 boca-$bocaver.$di/src/private/conf.php boca-$bocaver/src/private/conf.php + cp -f $conffile boca-$bocaver/src/private/conf.php fi chmod 700 boca-$bocaver/tools/*.sh diff --git a/boca-1.5.1/tools/icpc.etc.tgz b/boca-1.5.1/tools/icpc.etc.tgz Binary files differindex 97af0a4..4151601 100644 --- a/boca-1.5.1/tools/icpc.etc.tgz +++ b/boca-1.5.1/tools/icpc.etc.tgz diff --git a/boca-1.5.1/tools/installv2.sh b/boca-1.5.1/tools/installv2.sh index 03cbd29..85886b6 100755 --- a/boca-1.5.1/tools/installv2.sh +++ b/boca-1.5.1/tools/installv2.sh @@ -108,7 +108,7 @@ echo "=====================================================================" echo "================= installing packages needed by BOCA ===============" echo "=====================================================================" -apt-get -y install zenity apache2 eclipse-pde eclipse-rcp eclipse-platform eclipse-jdt eclipse emacs \ +apt-get -y install zenity apache2 eclipse-pde eclipse-rcp eclipse-platform eclipse-jdt eclipse-cdt eclipse emacs \ evince g++ gcc gedit scite libstdc++6 makepasswd manpages-dev mii-diag php5-cli php5-mcrypt openjdk-6-dbg \ php5 php5-pgsql postgresql postgresql-client postgresql-contrib quota sharutils default-jdk openjdk-6-doc \ vim-gnome geany geany-plugin-addons geany-plugin-gdb geany-plugins default-jre sysstat \ @@ -134,11 +134,45 @@ echo "==================================================================" echo "============= creating user icpc with password icpc =============" echo "==================================================================" +mkdir -p /etc/skel/Desktop/ +cat <<EOF > /etc/skel/Desktop/javadoc.desktop +[Desktop Entry] +Version=1.5.1 +Name=Java API +Comment=Java API +Exec=firefox /usr/share/doc/openjdk-6-jre-headless/api/index.html +Terminal=false +Type=Application +EOF +cat <<EOF > /etc/skel/Desktop/stldoc.desktop +[Desktop Entry] +Version=1.5.1 +Name=C++ STL +Comment=C++ STL +Exec=firefox /usr/share/doc/stl-manual/html/index.html +Terminal=false +Type=Application +EOF +cat <<EOF > /etc/skel/Desktop/cppannotations.desktop +[Desktop Entry] +Version=1.5.1 +Name=C++ Annotations +Comment=C++ Annotations +Exec=firefox /usr/share/doc/c++-annotations/html/index.html +Terminal=false +Type=Application +EOF +cp /usr/share/applications/eclipse.desktop /etc/skel/Desktop/ +cp /usr/share/applications/gedit.desktop /etc/skel/Desktop/ +cp /usr/share/applications/emacs23.desktop /etc/skel/Desktop/ +cp /usr/share/applications/gnome-terminal.desktop /etc/skel/Desktop/ +chmod 755 /etc/skel/Desktop/*.desktop + pass=`echo -n icpc | makepasswd --clearfrom - --crypt-md5 | cut -d'$' -f2-` pass=\$`echo $pass` id -u icpc >/dev/null 2>/dev/null if [ $? != 0 ]; then - useradd -d /home/icpc -m -p "$pass" -s /bin/bash -g users icpc + useradd -d /home/icpc -k /etc/skel -m -p "$pass" -s /bin/bash -g users icpc else usermod -d /home/icpc -p "$pass" -s /bin/bash -g users icpc echo "user icpc already exists" @@ -230,7 +264,7 @@ echo "====================== EXTRACTING CONFIG FILES ===============" tar -xkvzf /tmp/icpc.etc.tgz for i in \`tar tvzf /tmp/icpc.etc.tgz | awk '{ print \$6; }'\`; do chown root.root \$i - chmod o-w,u+x \$i + chmod o-w,u+rx \$i done EOF chmod 750 /etc/icpc/installscripts.sh diff --git a/boca-1.5.1/tools/safeexec.c b/boca-1.5.1/tools/safeexec.c index 0dfa867..33f16b7 100644 --- a/boca-1.5.1/tools/safeexec.c +++ b/boca-1.5.1/tools/safeexec.c @@ -32,6 +32,7 @@ pid_t child_pid; /* pid of the child process */ +double cpu_timeoutdouble = 5.0; struct rlimit cpu_timeout = {5,5}; /* max cpu time (seconds) */ struct rlimit max_nofile = {64,64}; /* max number of open files */ struct rlimit max_fsize = {128*MBYTE,128*MBYTE}; /* max filesize */ @@ -52,7 +53,7 @@ int killallproc; int bequiet; int checknchild; int user, group; -const char vers[] = "1.5.0"; +const char vers[] = "1.5.1"; #define BUFFSIZE 256 char curdir[BUFFSIZE], rootdir[BUFFSIZE], saida[BUFFSIZE], entrada[BUFFSIZE], erro[BUFFSIZE]; @@ -230,6 +231,8 @@ int testsystem(pid_t p, pid_t pp, int userid, int groupid, double memlim, double return ret; } +char timekill=0; + /* alarm handler */ void handle_alarm(int sig) { static int iter=0; @@ -241,6 +244,7 @@ void handle_alarm(int sig) { if(!bequiet) fprintf(stderr, "safeexec: timed-out (realtime) after %d seconds\n", real_timeout); fflush(stderr); + timekill=1; kill(child_pid,9); /* kill child */ exitandkill(3); } @@ -293,7 +297,7 @@ int main(int argc, char **argv) { int currun = 0; struct stat sstat; double dt; - + setvbuf(stderr, NULL, _IONBF, 0); entrada[0] = saida[0] = erro[0] = rootdir[0] = curdir[0] = 0; user = group = -1; allproc = 1; @@ -329,7 +333,8 @@ int main(int argc, char **argv) { break; case 'm': max_rss.rlim_max = max_rss.rlim_cur = KBYTE*atoi(optarg); break; - case 't': cpu_timeout.rlim_max = cpu_timeout.rlim_cur = atoi(optarg); + case 't': cpu_timeout.rlim_max = cpu_timeout.rlim_cur = 1 + ((int) atof(optarg)); + cpu_timeoutdouble = atof(optarg); break; case 'T': real_timeout = atoi(optarg); break; @@ -415,6 +420,8 @@ Use -U and -G for that, but you might need to have root privilegies.\n"); alarm(1); /* set alarm and wait for child execution */ signal(SIGALRM, handle_alarm); while(waitpid(child_pid, &status, 0) != child_pid) ; + if(timekill) exitandkill(3); + testsystem(child_pid,getpid(),allproc?user:-1,allproc?group:-1,max_data.rlim_max,max_rss.rlim_max); getrusage(RUSAGE_CHILDREN, &uso); @@ -424,12 +431,12 @@ Use -U and -G for that, but you might need to have root privilegies.\n"); // printf("system runnning time: %.4lf\n",uso.ru_stime.tv_sec+(double)uso.ru_stime.tv_usec/1000000.0); // printf("total runnning time: %.4lf\n",dt); - if (dt + EPSILON >= cpu_timeout.rlim_max) { + if (dt >= cpu_timeoutdouble) { // 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, "safeexec: timed-out (cputime) after %d seconds\n", (int) cpu_timeout.rlim_max); + fprintf(stderr, "safeexec: timed-out (cputime) after %.2lf seconds\n", cpu_timeoutdouble); fflush(stderr); -// fprintf(stdout, "timed-out (cputime) after %d seconds\n", (int) cpu_timeout.rlim_max); +// fprintf(stdout, "timed-out (cputime) after %d seconds\n", cpu_timeoutint); // fflush(stdout); exitandkill(3); } @@ -489,6 +496,9 @@ Use -U and -G for that, but you might need to have root privilegies.\n"); /* attempt to change the hard limits */ /*******Note that currently Linux does not support memory usage limits********/ + + cpu_timeout.rlim_max+=1; cpu_timeout.rlim_cur+=1; + if( setrlimit(RLIMIT_CPU, &cpu_timeout) || setrlimit(RLIMIT_DATA, &max_data) || setrlimit(RLIMIT_STACK, &max_data) || |