Skip to content

Commit 1668e03

Browse files
authored
Merge branch 'main' into jh_saferun
2 parents e246a89 + 1e706f0 commit 1668e03

36 files changed

+270
-255
lines changed

.github/jobs/baseinstall.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ password=${MYSQL_ROOT_PASSWORD}
6767
EOF
6868
cat ~/.my.cnf
6969

70+
# TODO: Remove after fixing https://github.com/DOMjudge/domjudge/issues/2848
71+
mysql_root "SET GLOBAL innodb_snapshot_isolation = OFF;"
72+
7073
mysql_root "CREATE DATABASE IF NOT EXISTS \`$DATABASE_NAME\` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
7174
mysql_root "CREATE USER IF NOT EXISTS \`domjudge\`@'%' IDENTIFIED BY 'domjudge';"
7275
mysql_root "GRANT SELECT, INSERT, UPDATE, DELETE ON \`$DATABASE_NAME\`.* TO 'domjudge'@'%';"
@@ -79,6 +82,7 @@ mysql_root "SELECT USER();"
7982
mysql_root "SELECT user,host FROM mysql.user"
8083
mysql_root "SET GLOBAL max_allowed_packet=1073741824"
8184
mysql_root "SHOW GLOBAL STATUS LIKE 'Connection_errors_%'"
85+
mysql_root "SHOW VARIABLES LIKE 'innodb_snapshot_isolation'"
8286
mysql_root "SHOW VARIABLES LIKE '%_timeout'"
8387
echo "unused:sqlserver:$DATABASE_NAME:domjudge:domjudge:3306" > /opt/domjudge/domserver/etc/dbpasswords.secret
8488
mysql_user "SELECT CURRENT_USER();"

.github/jobs/webstandard.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ if [ "$TEST" = "w3cval" ]; then
117117
118118
section_start "Install testsuite"
119119
cd "$DIR"
120-
wget https://github.com/validator/validator/releases/latest/download/vnu.linux.zip
120+
wget https://github.com/validator/validator/releases/download/latest/vnu.linux.zip
121121
unzip -q vnu.linux.zip
122+
# Remove a warning by creating an empty config.
123+
touch vnu.properties
122124
section_end
123125
124126
FLTR='--filterpattern .*autocomplete.*|.*role=tab.*|.*descendant.*|.*Stray.*|.*attribute.*|.*Forbidden.*|.*stream.*|.*obsolete.*'
@@ -128,7 +130,7 @@ if [ "$TEST" = "w3cval" ]; then
128130
# shellcheck disable=SC2086
129131
"$DIR"/vnu-runtime-image/bin/vnu --errors-only --exit-zero-always --skip-non-$typ --format json $FLTR "$URL" 2> result.json
130132
# shellcheck disable=SC2086
131-
NEWFOUNDERRORS=$("$DIR"/vnu-runtime-image/bin/vnu --errors-only --exit-zero-always --skip-non-$typ --format gnu $FLTR "$URL" 2>&1 | wc -l)
133+
NEWFOUNDERRORS=$("$DIR"/vnu-runtime-image/bin/vnu --errors-only --exit-zero-always --skip-non-$typ --format gnu $FLTR "$URL" 2>&1 | tee "$ARTIFACTS/w3c_${typ}_${URL}.log" | wc -l)
132134
FOUNDERR=$((NEWFOUNDERRORS+FOUNDERR))
133135
python3 -m "json.tool" < result.json > "$ARTIFACTS/w3c$typ$URL.json"
134136
trace_off; python3 .github/jobs/jsontogha.py "$ARTIFACTS/w3c$typ$URL.json"; trace_on

judge/judgedaemon.main.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ function read_credentials(): void
3333
global $endpoints;
3434

3535
$credfile = ETCDIR . '/restapi.secret';
36-
$credentials = @file($credfile);
37-
if (!$credentials) {
38-
error("Cannot read REST API credentials file " . $credfile);
36+
if (!is_readable($credfile)) {
37+
error("REST API credentials file " . $credfile . " is not readable or does not exist.");
38+
}
39+
$credentials = file($credfile);
40+
if ($credentials === false) {
41+
error("Error reading REST API credentials file " . $credfile);
3942
}
4043
$lineno = 0;
4144
foreach ($credentials as $credential) {
@@ -1524,8 +1527,8 @@ function judge(array $judgeTask): bool
15241527
$runtime = null;
15251528
$metadata = read_metadata($passdir . '/program.meta');
15261529

1527-
if (isset($metadata['time-used'])) {
1528-
$runtime = @$metadata[$metadata['time-used']];
1530+
if (isset($metadata['time-used']) && array_key_exists($metadata['time-used'], $metadata)) {
1531+
$runtime = $metadata[$metadata['time-used']];
15291532
}
15301533

15311534
if ($result === 'compare-error') {

judge/runguard.cc

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,6 @@ FILE *metafile;
117117
char cgroupname[255];
118118
const char *cpuset;
119119

120-
/* Linux Out-Of-Memory adjustment for current process. */
121-
#define OOM_PATH_NEW "/proc/self/oom_score_adj"
122-
#define OOM_PATH_OLD "/proc/self/oom_adj"
123-
#define OOM_RESET_VALUE 0
124-
125120
char *runuser;
126121
char *rungroup;
127122
int runuid;
@@ -1288,24 +1283,23 @@ int main(int argc, char **argv)
12881283
}
12891284

12901285
/* Check if any Linux Out-Of-Memory killer adjustments have to
1291-
* be made. The oom_adj or oom_score_adj is inherited by child
1292-
* processes, and at least older versions of sshd seemed to set
1286+
* be made. The oom_score_adj is inherited by child
1287+
* processes, and at least some configurations of sshd set
12931288
* it, leading to processes getting a timelimit instead of memory
12941289
* exceeded, when running via SSH. */
12951290
FILE *fp = nullptr;
1296-
char *oom_path;
1297-
if ( !fp && (fp = fopen(OOM_PATH_NEW,"r+")) ) oom_path = strdup(OOM_PATH_NEW);
1298-
if ( !fp && (fp = fopen(OOM_PATH_OLD,"r+")) ) oom_path = strdup(OOM_PATH_OLD);
1299-
if ( fp!=nullptr ) {
1300-
if ( fscanf(fp,"%d",&ret)!=1 ) error(errno,"cannot read from `%s'",oom_path);
1291+
const char *oom_score_path = "/proc/self/oom_score_adj";
1292+
if ( (fp = fopen(oom_score_path, "r+"))!=nullptr ) {
1293+
if ( fscanf(fp,"%d", &ret)!=1 ) error(errno,"cannot read from `%s'", oom_score_path);
13011294
if ( ret<0 ) {
1302-
verbose("resetting `%s' from %d to %d",oom_path,ret,OOM_RESET_VALUE);
1295+
int oom_reset_value = 0;
1296+
verbose("resetting `%s' from %d to %d", oom_score_path, ret, oom_reset_value);
13031297
rewind(fp);
1304-
if ( fprintf(fp,"%d\n",OOM_RESET_VALUE)<=0 ) {
1305-
error(errno,"cannot write to `%s'",oom_path);
1298+
if ( fprintf(fp,"%d\n", oom_reset_value) <= 0 ) {
1299+
error(errno, "cannot write to `%s'", oom_score_path);
13061300
}
13071301
}
1308-
if ( fclose(fp)!=0 ) error(errno,"closing file `%s'",oom_path);
1302+
if ( fclose(fp)!=0 ) error(errno, "closing file `%s'", oom_score_path);
13091303
}
13101304

13111305
switch ( child_pid = fork() ) {

0 commit comments

Comments
 (0)