Process rcon password as regular user (#2511)

This commit is contained in:
Geoff Bourne
2023-11-25 18:30:18 -06:00
committed by GitHub
parent 051436c1df
commit 9d7232c8b8
4 changed files with 51 additions and 40 deletions

View File

@@ -9,18 +9,13 @@
umask 0002
if isTrue "${ENABLE_RCON:-true}" && ! [ -v RCON_PASSWORD ] && ! [ -v RCON_PASSWORD_FILE ]; then
RCON_PASSWORD=$(openssl rand -hex 12)
export RCON_PASSWORD
fi
# Remove from previous run and do this as elevated user since file used to be created before demoting
rm -f "$HOME/.rcon-cli.env"
if ! isTrue "${SKIP_SUDO:-false}" && [ "$(id -u)" = 0 ]; then
runAsUser=minecraft
runAsGroup=minecraft
# For rcon-cli access running via exec, which by default is running as root
echo "password=${RCON_PASSWORD}" > "$HOME/.rcon-cli.env"
if [[ -v UID ]]; then
if [[ $UID != 0 ]]; then
if [[ $UID != $(id -u minecraft) ]]; then