From 0ff690a2f0d25b1092a00ba28162df94ac4a3b2d Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 15:43:36 -0500 Subject: [PATCH 1/4] check for root --- gravity-sync.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gravity-sync.sh b/gravity-sync.sh index 89f3185..28bcc3b 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -1353,6 +1353,16 @@ function echo_need { MESSAGE="Evaluating Arguments" echo_stat + if [ ! "$EUID" -ne 0 ] + then + echo_fail + + MESSAGE="Root User Detected" + echo_warn + + exit_nochange + fi + case $# in 0) From 71827c613a6f98e3b0e9fe93cc30f03037cd7712 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 15:45:41 -0500 Subject: [PATCH 2/4] Must not run as root --- gravity-sync.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 28bcc3b..fe6a5c4 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -1355,9 +1355,10 @@ function echo_need { if [ ! "$EUID" -ne 0 ] then + MESSAGE="${MESSAGE} ROOT" echo_fail - MESSAGE="Root User Detected" + MESSAGE="${PROGRAM} Must Not Run as Root" echo_warn exit_nochange From c8207a48e14ecd3444f4e9fe591cbc3cf1cacfc8 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 15:47:20 -0500 Subject: [PATCH 3/4] Root function --- gravity-sync.sh | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index fe6a5c4..4cbd949 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -1345,6 +1345,21 @@ function echo_need { echo -en "${NEED} ${MESSAGE}: " } +# Root Check +function root_check { + if [ ! "$EUID" -ne 0 ] + then + TASKTYPE='ROOT' + MESSAGE="${MESSAGE} ${TASKTYPE}" + echo_fail + + MESSAGE="${PROGRAM} Must Not Run as Root" + echo_warn + + exit_nochange + fi +} + # SCRIPT EXECUTION ########################### MESSAGE="${PROGRAM} ${VERSION} Executing" @@ -1353,16 +1368,7 @@ function echo_need { MESSAGE="Evaluating Arguments" echo_stat - if [ ! "$EUID" -ne 0 ] - then - MESSAGE="${MESSAGE} ROOT" - echo_fail - - MESSAGE="${PROGRAM} Must Not Run as Root" - echo_warn - - exit_nochange - fi + root_check case $# in From 64afbd4e8d8040f65c9dd8981dc8e2be835d40e2 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 15:52:36 -0500 Subject: [PATCH 4/4] 1.8.1 --- ADVANCED.md | 4 ++-- CHANGELOG.md | 4 ++++ VERSION | 2 +- gravity-sync.sh | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ADVANCED.md b/ADVANCED.md index 2424cd9..eeb79dd 100644 --- a/ADVANCED.md +++ b/ADVANCED.md @@ -14,8 +14,8 @@ Download the latest release from [GitHub](https://github.com/vmstan/gravity-sync ```bash cd ~ -wget https://github.com/vmstan/gravity-sync/archive/v1.8.0.zip -unzip v1.8.0.zip -d gravity-sync +wget https://github.com/vmstan/gravity-sync/archive/v1.8.1.zip +unzip v1.8.1.zip -d gravity-sync cd gravity-sync ``` diff --git a/CHANGELOG.md b/CHANGELOG.md index 2838506..5a0e4db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 1.8 ### The Logical Release + **Features** There is nothing really sexy here, but a lot of changes under the covers to improve reliablity between different SSH client types. A lot of the logic and functions are more consistent and cleaner. In some cultures, fewer bugs and more reliablity are considered features. Much of this will continue through the 1.8.x line. @@ -11,6 +12,9 @@ There is nothing really sexy here, but a lot of changes under the covers to impr - Adds custom port specification to ssh-copy-id and dropbearkey commands during configuration generation. - Generally better error handling of configuration options. +#### 1.8.1 +- Detects if script is running as the root user or via `sudo ./gravity-sync.sh` and exits on error. + ## 1.7 ### The Andrew Release diff --git a/VERSION b/VERSION index afa2b35..b9268da 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.0 \ No newline at end of file +1.8.1 \ No newline at end of file diff --git a/gravity-sync.sh b/gravity-sync.sh index 4cbd949..8ca504a 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -3,7 +3,7 @@ SCRIPT_START=$SECONDS # GRAVITY SYNC BY VMSTAN ##################### PROGRAM='Gravity Sync' -VERSION='1.8.0' +VERSION='1.8.1' # Execute from the home folder of the user who owns it (ex: 'cd ~/gravity-sync') # For documentation or downloading updates visit https://github.com/vmstan/gravity-sync