diff --git a/judge/build_executable.sh b/judge/build_executable.sh index 437b017684..e5b0c494e4 100755 --- a/judge/build_executable.sh +++ b/judge/build_executable.sh @@ -76,7 +76,9 @@ logmsg $LOG_INFO "starting build" exitcode=0 $GAINROOT "$RUNGUARD" ${DEBUG:+-v} -u "$RUNUSER" -g "$RUNGROUP" \ - -r "$CHROOTDIR" -d '/build' --no-core -- \ + -r "$CHROOTDIR" -d '/build' \ + -m $SCRIPTMEMLIMIT -t $SCRIPTTIMELIMIT --no-core -f $SCRIPTFILELIMIT -s $SCRIPTFILELIMIT \ + -- \ './build' > 'build.log' 2>&1 || \ exitcode=$? diff --git a/judge/judgedaemon.main.php b/judge/judgedaemon.main.php index 93c07f5639..9d129d604b 100644 --- a/judge/judgedaemon.main.php +++ b/judge/judgedaemon.main.php @@ -439,6 +439,11 @@ function fetch_executable_internal( if ($do_compile) { logmsg(LOG_DEBUG, "Building executable in $execdir, under 'build/'"); + + putenv('SCRIPTTIMELIMIT=' . djconfig_get_value('script_timelimit')); + putenv('SCRIPTMEMLIMIT=' . djconfig_get_value('script_memory_limit')); + putenv('SCRIPTFILELIMIT=' . djconfig_get_value('script_filesize_limit')); + system(LIBJUDGEDIR . '/build_executable.sh ' . dj_escapeshellarg($execdir), $retval); if ($retval !== 0) { return [null, "Failed to build executable in $execdir.", "$execdir/build.log"];