build: Make enter_chroot.sh fail if run as root.

BUG=684

Review URL: http://codereview.chromium.org/429006

git-svn-id: svn://chrome-svn/chromeos/trunk@304 06c00378-0e64-4dae-be16-12b19f9950a1
This commit is contained in:
derat@google.com 2009-11-21 19:49:49 +00:00
parent a9948c6336
commit 86dcc8e68b
2 changed files with 9 additions and 1 deletions

View File

@ -171,6 +171,13 @@ function assert_outside_chroot {
fi
}
function assert_not_root_user {
if [ `id -u` = 0 ]; then
echo "This script must be run as a non-root user."
exit 1
fi
}
# Install a package if it's not already installed
function install_if_missing {
# Positional parameters from calling script. :? means "fail if unset".

View File

@ -10,8 +10,9 @@
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# Script must be run outside the chroot
# Script must be run outside the chroot and as a regular user.
assert_outside_chroot
assert_not_root_user
# Define command line flags
# See http://code.google.com/p/shflags/wiki/Documentation10x