Skip to content

Commit

Permalink
Stop build if running under root
Browse files Browse the repository at this point in the history
Running as root messes up the file permission. Disable it to prevent future support issue.
  • Loading branch information
RadxaYuntian committed Oct 18, 2022
1 parent 68c8ee8 commit 2734453
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions rbuild
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ EXIT_UNSUPPORTED_OPTION=3
EXIT_SUDO_PERMISSION=4
EXIT_SHRINK_NO_ROOTDEV=5
EXIT_DEV_SHM_TOO_SMALL=6
EXIT_RBUILD_AS_ROOT=7

error() {
case "$1" in
Expand All @@ -30,6 +31,12 @@ error() {
$EXIT_DEV_SHM_TOO_SMALL)
echo "Your /dev/shm is too small. Current '$2', require '$3'." >&2
;;
$EXIT_RBUILD_AS_ROOT)
cat << EOF >&2
You are running $(basename "$0") with root permission, which is not supported.
If you need root permission to run docker, please add your account to docker group, reboot, and try again.
EOF
;;
*)
echo "Unknown error code $1." >&2
;;
Expand Down Expand Up @@ -512,6 +519,11 @@ LANGUAGE="C"

SCRIPT_DIR="$(dirname "$(realpath "$0")")"

if (( EUID == 0 ))
then
error $EXIT_RBUILD_AS_ROOT
fi

if command -v notify-send >/dev/null
then
NOTIFY_SEND=notify-send
Expand Down

0 comments on commit 2734453

Please sign in to comment.