Fix NeoForge installer failing under runuser

mktemp -d creates a 0700 directory owned by root, so handing the downloaded
installer jar to the minecraft user via runuser failed with "Unable to access
jarfile". Relax the temp path to 0755/0644 — the installer is a public
download and holds nothing sensitive.

Also set HOME explicitly for the runuser invocation, since it otherwise
inherits root's and the installer writes a cache alongside it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
main
Amir Alexander Abdelbaki 2026-08-05 22:33:08 +02:00
parent 1f50667d36
commit c9da65d7ce
1 changed files with 10 additions and 2 deletions

View File

@ -130,9 +130,17 @@ if [ -n "$NFVER" ]; then
curl -fsSL -o "$tmp/installer.jar" "$url" \ curl -fsSL -o "$tmp/installer.jar" "$url" \
|| die "could not download $url — check the version number exists" || die "could not download $url — check the version number exists"
# mktemp -d gives root a 0700 directory, so the service user cannot read the
# jar out of it. Open up the path — the installer is a public download.
chmod 0755 "$tmp"
chmod 0644 "$tmp/installer.jar"
# The installer writes into the working directory, so run it as the service # The installer writes into the working directory, so run it as the service
# user to avoid leaving root-owned files scattered through the share. # user to avoid leaving root-owned files scattered through the share. HOME is
( cd "$SHARE" && runuser -u "$MCUSER" -- java -jar "$tmp/installer.jar" --installServer ) \ # set explicitly because runuser otherwise leaves root's, and the installer
# writes a cache next to it.
( cd "$SHARE" && runuser -u "$MCUSER" -- \
env HOME="$SHARE" java -jar "$tmp/installer.jar" --installServer ) \
|| die "NeoForge installer failed" || die "NeoForge installer failed"
rm -rf "$tmp"; trap - EXIT rm -rf "$tmp"; trap - EXIT
fi fi