forked from DOMjudge/domjudge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Collect compiler and runner versions before compilation.
Progress towards DOMjudge#1241 Each language has canonical information while we store the latest info per judgehost in a separate table. The information from the judgehost is currently just informative, a next step would be to actually disable judging from this judgehost in case of a version mismatch. The canonical information can be exposed to the teams via a config option.
- Loading branch information
Showing
19 changed files
with
1,089 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#!/bin/sh | ||
|
||
# Script to verify compiler versions. | ||
|
||
# Exit automatically, whenever a simple command fails and trap it: | ||
set -e | ||
trap error EXIT | ||
|
||
cleanexit () | ||
{ | ||
trap - EXIT | ||
|
||
chmod go= "$WORKDIR/vcheck" "$WORKDIR/vcheck-script" | ||
logmsg $LOG_DEBUG "exiting, code = '$1'" | ||
exit $1 | ||
} | ||
|
||
# Error and logging functions | ||
# shellcheck disable=SC1090 | ||
. "$DJ_LIBDIR/lib.error.sh" | ||
|
||
# Logging: | ||
LOGFILE="$DJ_LOGDIR/judge.$(hostname | cut -d . -f 1).log" | ||
LOGLEVEL=$LOG_DEBUG | ||
PROGNAME="$(basename "$0")" | ||
|
||
# Check for judge backend debugging: | ||
if [ "$DEBUG" ]; then | ||
export DEBUG | ||
export VERBOSE=$LOG_DEBUG | ||
logmsg $LOG_NOTICE "debugging enabled, DEBUG='$DEBUG'" | ||
else | ||
export VERBOSE=$LOG_ERR | ||
fi | ||
|
||
# Location of scripts/programs: | ||
SCRIPTDIR="$DJ_LIBJUDGEDIR" | ||
GAINROOT="sudo -n" | ||
RUNGUARD="$DJ_BINDIR/runguard" | ||
|
||
logmsg $LOG_INFO "starting '$0', PID = $$" | ||
|
||
[ $# -ge 2 ] || error "not enough arguments. See script-code for usage." | ||
VERSION_CHECK_SCRIPT="$1"; shift | ||
WORKDIR="$1"; shift | ||
logmsg $LOG_DEBUG "arguments: '$VERSION_CHECK_SCRIPT' '$WORKDIR'" | ||
|
||
if [ ! -d "$WORKDIR" ] || [ ! -w "$WORKDIR" ] || [ ! -x "$WORKDIR" ]; then | ||
error "Workdir not found or not writable: $WORKDIR" | ||
fi | ||
[ -x "$VERSION_CHECK_SCRIPT" ] || error "compile script not found or not executable: $VERSION_CHECK_SCRIPT" | ||
[ -x "$RUNGUARD" ] || error "runguard not found or not executable: $RUNGUARD" | ||
|
||
OLDDIR="$PWD" | ||
cd "$WORKDIR" | ||
|
||
# Make compile dir accessible and writable for RUNUSER: | ||
mkdir -p "$WORKDIR/vcheck" | ||
chmod a+rwx "$WORKDIR/vcheck" | ||
|
||
# Create files which are expected to exist: compiler output and runtime | ||
touch vcheck.out vcheck.meta | ||
|
||
# Copy compile script into chroot | ||
# shellcheck disable=SC2174 | ||
if [ -e "$WORKDIR/vcheck-script" ]; then | ||
mv "$WORKDIR/vcheck-script" "$WORKDIR/vcheck-script-old" | ||
fi | ||
mkdir -m 0777 -p "$WORKDIR/vcheck-script" | ||
cp -a "$VERSION_CHECK_SCRIPT" "$PWD/vcheck-script/" | ||
|
||
cd "$WORKDIR/vcheck" | ||
|
||
logmsg $LOG_INFO "starting version checking" | ||
|
||
if [ -n "$DEBUG" ]; then | ||
ENVIRONMENT_VARS="$ENVIRONMENT_VARS -V DEBUG=$DEBUG" | ||
fi | ||
|
||
exitcode=0 | ||
$GAINROOT "$RUNGUARD" ${DEBUG:+-v} $CPUSET_OPT -u "$RUNUSER" -g "$RUNGROUP" \ | ||
-r "$PWD/.." -d "/vcheck" \ | ||
-m $SCRIPTMEMLIMIT -t $SCRIPTTIMELIMIT -c -f $SCRIPTFILELIMIT -s $SCRIPTFILELIMIT \ | ||
-M "$WORKDIR/vcheck.meta" $ENVIRONMENT_VARS -- \ | ||
"/vcheck-script/$(basename $VERSION_CHECK_SCRIPT)" >"$WORKDIR/vcheck.tmp" 2>&1 || \ | ||
exitcode=$? | ||
|
||
# Make sure that all files are owned by the current user/group, so | ||
# that we can delete the judging output tree without root access. | ||
# We also remove group RUNGROUP so that this can safely be shared | ||
# across multiple judgedaemons, and remove write permissions. | ||
$GAINROOT chown -R "$(id -un):" "$WORKDIR/vcheck" | ||
chmod -R go-w "$WORKDIR/vcheck" | ||
|
||
cd "$WORKDIR" | ||
|
||
if [ $exitcode -ne 0 ] && [ ! -s vcheck.meta ]; then | ||
echo "internal-error: runguard crashed" > vcheck.meta | ||
echo "Runguard exited with code $exitcode and 'vcheck.meta' is empty, it likely crashed." >vcheck.out | ||
echo "Version check output:" >>vcheck.out | ||
cat vcheck.tmp >>vcheck.out | ||
cleanexit ${E_INTERNAL_ERROR:-1} | ||
fi | ||
|
||
if [ $exitcode -ne 0 ]; then | ||
echo "Version checking failed with exitcode $exitcode, version check output:" >vcheck.out | ||
cat vcheck.tmp >>vcheck.out | ||
cleanexit ${E_COMPILER_ERROR:-1} | ||
fi | ||
cat vcheck.tmp >>vcheck.out | ||
|
||
logmsg $LOG_INFO "Version check successful" | ||
cleanexit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20230507123700 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->addSql('CREATE TABLE version (versionid INT UNSIGNED AUTO_INCREMENT NOT NULL COMMENT \'Version ID\', langid VARCHAR(32) DEFAULT NULL COMMENT \'Language ID (string)\', judgehostid INT UNSIGNED DEFAULT NULL COMMENT \'Judgehost ID\', compiler_version LONGBLOB DEFAULT NULL COMMENT \'Compiler version(DC2Type:blobtext)\', runner_version LONGBLOB DEFAULT NULL COMMENT \'Runner version(DC2Type:blobtext)\', runner_version_command VARCHAR(255) DEFAULT NULL COMMENT \'Runner version command\', compiler_version_command VARCHAR(255) DEFAULT NULL COMMENT \'Compiler version command\', last_changed_time NUMERIC(32, 9) UNSIGNED DEFAULT NULL COMMENT \'Time this version command output was last updated\', INDEX IDX_BF1CD3C32271845 (langid), INDEX IDX_BF1CD3C3E0E4FC3E (judgehostid), PRIMARY KEY(versionid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'Runner and compiler version commands per language.\' '); | ||
$this->addSql('ALTER TABLE version ADD CONSTRAINT FK_BF1CD3C32271845 FOREIGN KEY (langid) REFERENCES language (langid)'); | ||
$this->addSql('ALTER TABLE version ADD CONSTRAINT FK_BF1CD3C3E0E4FC3E FOREIGN KEY (judgehostid) REFERENCES judgehost (judgehostid)'); | ||
$this->addSql('ALTER TABLE immutable_executable ADD compiler_version LONGBLOB DEFAULT NULL COMMENT \'Compiler version(DC2Type:blobtext)\', ADD compiler_version_command VARCHAR(255) DEFAULT NULL COMMENT \'Compiler version command\', ADD runner_version LONGBLOB DEFAULT NULL COMMENT \'Runner version(DC2Type:blobtext)\', ADD runner_version_command VARCHAR(255) DEFAULT NULL COMMENT \'Runner version command\''); | ||
$this->addSql('ALTER TABLE language ADD compiler_version LONGBLOB DEFAULT NULL COMMENT \'Compiler version(DC2Type:blobtext)\', ADD runner_version LONGBLOB DEFAULT NULL COMMENT \'Runner version(DC2Type:blobtext)\', ADD runner_version_command VARCHAR(255) DEFAULT NULL COMMENT \'Runner version command\', ADD compiler_version_command VARCHAR(255) DEFAULT NULL COMMENT \'Compiler version command\''); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE version DROP FOREIGN KEY FK_BF1CD3C32271845'); | ||
$this->addSql('ALTER TABLE version DROP FOREIGN KEY FK_BF1CD3C3E0E4FC3E'); | ||
$this->addSql('DROP TABLE version'); | ||
$this->addSql('ALTER TABLE language DROP compiler_version, DROP runner_version, DROP runner_version_command, DROP compiler_version_command'); | ||
$this->addSql('ALTER TABLE immutable_executable DROP compiler_version, DROP compiler_version_command, DROP runner_version, DROP runner_version_command'); | ||
} | ||
|
||
public function isTransactional(): bool | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.