diff --git a/install_minimal/airtime-install b/install_minimal/airtime-install index 57f912c1c..6b54a9573 100755 --- a/install_minimal/airtime-install +++ b/install_minimal/airtime-install @@ -2,7 +2,7 @@ #-e Causes bash script to exit if any of the installers #return with a non-zero return value. -if [ `whoami` != 'root' ]; then +if [[ $EUID -ne 0 ]]; then echo "Please run as root user." exit 1 fi diff --git a/install_minimal/airtime-uninstall b/install_minimal/airtime-uninstall index fb5af754f..b99f04246 100755 --- a/install_minimal/airtime-uninstall +++ b/install_minimal/airtime-uninstall @@ -1,7 +1,7 @@ #!/bin/bash #Check if root user -if [ `whoami` != 'root' ]; then +if [[ $EUID -ne 0 ]]; then echo "Please run as root user." exit 1 fi diff --git a/install_minimal/include/AirtimeInstall.php b/install_minimal/include/AirtimeInstall.php index dc5869165..35567004a 100644 --- a/install_minimal/include/AirtimeInstall.php +++ b/install_minimal/include/AirtimeInstall.php @@ -33,7 +33,7 @@ class AirtimeInstall public static function ExitIfNotRoot() { // Need to check that we are superuser before running this. - if(exec("whoami") != "root"){ + if(posix_geteuid() != 0){ echo "Must be root user.\n"; exit(1); } diff --git a/install_minimal/include/airtime-copy-files.sh b/install_minimal/include/airtime-copy-files.sh index ad4f571d4..57339eff5 100755 --- a/install_minimal/include/airtime-copy-files.sh +++ b/install_minimal/include/airtime-copy-files.sh @@ -2,7 +2,7 @@ #-e Causes bash script to exit if any of the installers #return with a non-zero return value. -if [ `whoami` != 'root' ]; then +if [[ $EUID -ne 0 ]]; then echo "Please run as root user." exit 1 fi diff --git a/install_minimal/include/airtime-initialize.sh b/install_minimal/include/airtime-initialize.sh index 56be18066..82b03ee88 100755 --- a/install_minimal/include/airtime-initialize.sh +++ b/install_minimal/include/airtime-initialize.sh @@ -2,7 +2,7 @@ #-e Causes bash script to exit if any of the installers #return with a non-zero return value. -if [ `whoami` != 'root' ]; then +if [[ $EUID -ne 0 ]]; then echo "Please run as root user." exit 1 fi diff --git a/install_minimal/include/airtime-remove-files.sh b/install_minimal/include/airtime-remove-files.sh index 93e9efb60..11d9f93ad 100755 --- a/install_minimal/include/airtime-remove-files.sh +++ b/install_minimal/include/airtime-remove-files.sh @@ -2,7 +2,7 @@ #-e Causes bash script to exit if any of the installers #return with a non-zero return value. -if [ `whoami` != 'root' ]; then +if [[ $EUID -ne 0 ]]; then echo "Please run as root user." exit 1 fi diff --git a/install_minimal/include/airtime-uninitialize.sh b/install_minimal/include/airtime-uninitialize.sh index d26256367..1713ae7f2 100755 --- a/install_minimal/include/airtime-uninitialize.sh +++ b/install_minimal/include/airtime-uninitialize.sh @@ -2,7 +2,7 @@ #-e Causes bash script to exit if any of the installers #return with a non-zero return value. -if [ `whoami` != 'root' ]; then +if [[ $EUID -ne 0 ]]; then echo "Please run as root user." exit 1 fi diff --git a/install_minimal/include/airtime-upgrade.php b/install_minimal/include/airtime-upgrade.php index 5b356c225..f4d03c3c3 100644 --- a/install_minimal/include/airtime-upgrade.php +++ b/install_minimal/include/airtime-upgrade.php @@ -11,7 +11,7 @@ require_once(__DIR__.'/airtime-constants.php'); require_once(dirname(__FILE__).'/AirtimeIni.php'); require_once(dirname(__FILE__).'/AirtimeInstall.php'); -if(exec("whoami") != "root"){ +if(posix_geteuid() != 0){ echo "Must be root user.\n"; exit(1); } diff --git a/utils/airtime-check-system.php b/utils/airtime-check-system.php index 4f7237fc0..3ed877cd4 100644 --- a/utils/airtime-check-system.php +++ b/utils/airtime-check-system.php @@ -32,7 +32,7 @@ class AirtimeCheck { public static function ExitIfNotRoot() { // Need to check that we are superuser before running this. - $user = exec("whoami"); + $user = posix_getlogin(); if($user != "root" && $user != "www-data"){ echo "Must be root user.\n"; exit(1); diff --git a/utils/airtime-import/airtime-import.py b/utils/airtime-import/airtime-import.py index 083156192..6340da445 100644 --- a/utils/airtime-import/airtime-import.py +++ b/utils/airtime-import/airtime-import.py @@ -18,7 +18,7 @@ logging.disable(50) # add ch to logger logger.addHandler(ch) -if (commands.getoutput("whoami") != 'root'): +if (posix_geteuid() != 0): print 'Must be a root user.' sys.exit() diff --git a/utils/airtime-log.php b/utils/airtime-log.php index 476824cee..3e13ca502 100644 --- a/utils/airtime-log.php +++ b/utils/airtime-log.php @@ -30,7 +30,7 @@ array_filter($log_files, "file_exists"); function exitIfNotRoot() { // Need to check that we are superuser before running this. - if(exec("whoami") != "root"){ + if(posix_geteuid() != 0){ echo "Must be root user.\n"; exit(1); } diff --git a/utils/phone_home_stat.php b/utils/phone_home_stat.php index 98bc242f5..3a0e6526a 100644 --- a/utils/phone_home_stat.php +++ b/utils/phone_home_stat.php @@ -101,7 +101,7 @@ if(Application_Model_Preference::GetPlanLevel() == 'disabled'){ function exitIfNotRoot() { // Need to check that we are superuser before running this. - if(exec("whoami") != "root"){ + if(posix_geteuid() != 0){ echo "Must be root user.\n"; exit(1); }