Skip to content

Commit 4c09ceb

Browse files
saironagners
andauthored
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 <[email protected]>
1 parent e7f3142 commit 4c09ceb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

scripts/enter.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ CACHE_DIR="${CACHE_DIR:-$HOME/hassos-cache}"
77
ARGS="$*"
88
COMMAND="${ARGS:-bash}"
99

10+
if [ "$BUILDER_UID" -eq "0" ] || [ "$BUILDER_GID" == "0" ]; then
11+
echo "ERROR: Please run this script as a regular (non-root) user with sudo privileges."
12+
exit 1
13+
fi
14+
1015
sudo mkdir -p "${CACHE_DIR}"
1116
sudo chown -R "${BUILDER_UID}:${BUILDER_GID}" "${CACHE_DIR}"
1217
sudo docker build -t hassos:local .

0 commit comments

Comments
 (0)