From e2b9b733afcffb0b8dab52bb96cf2cdf45edda3d Mon Sep 17 00:00:00 2001 From: a1346054 <36859588+a1346054@users.noreply.github.com> Date: Fri, 20 Aug 2021 13:11:46 +0000 Subject: [PATCH] use proper check for root privileges The root user is not guaranteed to be named 'root' --- get_region.sh | 4 ++-- get_token.sh | 4 ++-- run_setup.sh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/get_region.sh b/get_region.sh index 9027d2d..c9de0f2 100755 --- a/get_region.sh +++ b/get_region.sh @@ -77,8 +77,8 @@ if test -t 1; then fi fi -# Only allow script to run as -if [ "$(whoami)" != "root" ]; then +# Only allow script to run as root +if (( EUID != 0 )); then echo -e "${RED}This script needs to be run as root. Try again with 'sudo $0'${NC}" exit 1 fi diff --git a/get_token.sh b/get_token.sh index d593f6f..0f04790 100755 --- a/get_token.sh +++ b/get_token.sh @@ -53,8 +53,8 @@ if test -t 1; then fi fi -# Only allow script to run as -if [ "$(whoami)" != "root" ]; then +# Only allow script to run as root +if (( EUID != 0 )); then echo -e "${RED}This script needs to be run as root. Try again with 'sudo $0'${NC}" exit 1 fi diff --git a/run_setup.sh b/run_setup.sh index 823a6d8..2a39f07 100755 --- a/run_setup.sh +++ b/run_setup.sh @@ -37,8 +37,8 @@ fi intCheck='^[0-9]+$' floatCheck='^[0-9]+([.][0-9]+)?$' -# Only allow script to run as -if [ "$(whoami)" != "root" ]; then +# Only allow script to run as root +if (( EUID != 0 )); then echo -e "${RED}This script needs to be run as root. Try again with 'sudo $0'${NC}" exit 1 fi