Skip to content

Commit 85648d5

Browse files
authored
Remove all use of sudoers file (#3477)
1 parent 3616847 commit 85648d5

File tree

5 files changed

+6
-11
lines changed

5 files changed

+6
-11
lines changed

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ RUN --mount=target=/build,source=build \
1919
RUN --mount=target=/build,source=build \
2020
/build/run.sh setup-user
2121

22-
COPY --chmod=644 files/sudoers* /etc/sudoers.d
23-
2422
EXPOSE 25565
2523

2624
ARG APPS_REV=1

bin/mc-send-to-console

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ if [ ! -p "${CONSOLE_IN_NAMED_PIPE}" ]; then
1717
exit 1
1818
fi
1919

20-
if [ "$(id -u)" = 0 -a $UID != 0 ]; then
21-
exec $(getSudoFromDistro) minecraft bash -c "echo '$*' > '${CONSOLE_IN_NAMED_PIPE}'"
20+
if [[ "$(id -u)" = 0 ]] && [[ $UID != 0 ]]; then
21+
error "Exec needs to be run with user ID $UID"
22+
exit 2
2223
else
2324
echo "$@" >"${CONSOLE_IN_NAMED_PIPE}"
2425
fi

docs/commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ _The `-i` is not needed in this case._
2424
If rcon is disabled you can send commands by passing them as arguments to the packaged `mc-send-to-console` script after setting the env var `CREATE_CONSOLE_IN_PIPE` to "true". For example, a player can be op'ed in the container `mc` with:
2525

2626
```shell
27-
docker exec mc mc-send-to-console op player
27+
docker exec --user 1000 mc mc-send-to-console op player
2828
| |
2929
+- container name +- Minecraft commands start here
3030
```

files/auto/stop.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,5 @@ if isTrue "${DEBUG_AUTOSTOP}"; then
66
fi
77

88
logAutostopAction "Stopping Java process"
9-
if isTrue "${AUTOSTOP_PKILL_USE_SUDO:-false}"; then
10-
sudo pkill -f --signal SIGTERM mc-server-runner
11-
else
12-
pkill -f --signal SIGTERM mc-server-runner
13-
fi
9+
pkill -f --signal SIGTERM mc-server-runner
10+

files/sudoers-mc

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)