Skip to content

Commit b6ae271

Browse files
tom93vmcj
authored andcommitted
Preserve ownership of /opt/domjudge set by make install-*
Previously, the DOMjudge Docker scripts changed the ownership of /opt/domjudge to "domjudge" recursively, overriding the ownership set by the DOMjudge installation commands (`make install-domserver` and `make install-judgehost`), which mostly set the owner to "root". It is unclear why the Docker scripts did that, since the DOMjudge installation commands should be responsible for installing with the correct ownership. This commit removes the `chown -R` calls from the Docker scripts in order to preserve the ownership set by the DOMjudge installation commands and avoid security issues. Note that the new behaviour is slightly fragile because it relies on Docker's `COPY --from` directive to preserve the ownership when copying files between build stages, and that only works if the numerical user and group IDs are the same. We plan to add a check that the IDs are the same.
1 parent 5c995f5 commit b6ae271

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

docker/domserver/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ ENV DEBIAN_FRONTEND=noninteractive \
5151
FPM_MAX_CHILDREN=40 \
5252
DJ_DB_INSTALL_BARE=0
5353

54+
# Set up user
55+
RUN useradd -m domjudge
56+
5457
# Install required packages for running of domserver
5558
RUN apt-get update \
5659
&& apt-get install --no-install-recommends --no-install-suggests -y \

docker/domserver/configure.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#!/bin/sh -eu
22

3-
# Add user, create PHP FPM socket dir, change permissions for domjudge directory and fix scripts
4-
useradd -m domjudge
3+
# Create PHP FPM socket dir, change permissions for some domjudge directories and fix scripts
54
mkdir -p /run/php
6-
chown -R domjudge: /opt/domjudge
75
chown -R www-data: /opt/domjudge/domserver/tmp
86
# for DOMjudge <= 7.2 (submitdir was removed in commit DOMjudge/domjudge@d66725038)
97
if [ -d /opt/domjudge/domserver/submissions ]

docker/judgehost/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ ENV DEBIAN_FRONTEND=noninteractive \
1010
DOMJUDGE_CREATE_WRITABLE_TEMP_DIR=0 \
1111
RUN_USER_UID_GID=62860
1212

13+
# Set up user
14+
RUN useradd -m domjudge
15+
1316
# Install required packages for running of judgehost
1417
RUN apt-get update \
1518
&& apt-get install --no-install-recommends --no-install-suggests -y \
@@ -31,7 +34,7 @@ COPY judgehost/scripts /scripts/
3134
# Make the scripts available to the root user
3235
ENV PATH="$PATH:/opt/domjudge/judgehost/bin"
3336

34-
# Change start script permissions, add user and fix permissions
37+
# Run customizations
3538
COPY judgehost/configure.sh /configure.sh
3639
RUN chmod 700 /configure.sh && /configure.sh && rm -f /configure.sh
3740

docker/judgehost/configure.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/bin/bash -e
22

3-
useradd -m domjudge
4-
chown -R domjudge: /opt/domjudge
5-
63
chmod 755 /scripts/start.sh
74
for script in /scripts/bin/*
85
do

0 commit comments

Comments
 (0)