Prevent root from running the enter.sh helper script (#4216)

* Prevent root from running the enter.sh helper script

Since configure doesn't like being ran as root, check in the enter.sh script
that the user running it is not UID/GID 0. The script itself takes care of
running what needs to be executed privileged with explicit sudo commands.

Fixes #4214

* Reword the error message


Co-authored-by: Stefan Agner <stefan@agner.ch>
This commit is contained in:
Jan Čermák 2025-08-06 17:27:44 +02:00 committed by GitHub
parent e7f314273d
commit 4c09ceb656
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,6 +7,11 @@ CACHE_DIR="${CACHE_DIR:-$HOME/hassos-cache}"
ARGS="$*"
COMMAND="${ARGS:-bash}"
if [ "$BUILDER_UID" -eq "0" ] || [ "$BUILDER_GID" == "0" ]; then
echo "ERROR: Please run this script as a regular (non-root) user with sudo privileges."
exit 1
fi
sudo mkdir -p "${CACHE_DIR}"
sudo chown -R "${BUILDER_UID}:${BUILDER_GID}" "${CACHE_DIR}"
sudo docker build -t hassos:local .