From f54d632da585a08185c6164017d79315c331181f Mon Sep 17 00:00:00 2001 From: earthlng Date: Sat, 7 Oct 2023 10:33:49 +0000 Subject: [PATCH] v2.0 - improve root check --- prefsCleaner.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/prefsCleaner.sh b/prefsCleaner.sh index f36732c..6586609 100755 --- a/prefsCleaner.sh +++ b/prefsCleaner.sh @@ -2,23 +2,12 @@ ## prefs.js cleaner for Linux/Mac ## author: @claustromaniac -## version: 1.9 +## version: 2.0 ## special thanks to @overdodactyl and @earthlng for a few snippets that I stol..*cough* borrowed from the updater.sh ## DON'T GO HIGHER THAN VERSION x.9 !! ( because of ASCII comparison in update_prefsCleaner() ) -# Check if running as root and if any files have the owner/group as root/wheel. -if [ "${EUID:-"$(id -u)"}" -eq 0 ]; then - printf "You shouldn't run this with elevated privileges (such as with doas/sudo).\n" - exit 1 -elif [ -n "$(find ./ -user 0 -o -group 0)" ]; then - printf 'It looks like this script was previously run with elevated privileges, -you will need to change ownership of the following files to your user:\n' - find . -user 0 -o -group 0 - exit 1 -fi - readonly CURRDIR=$(pwd) ## get the full path of this script (readlink for Linux, greadlink for Mac with coreutils installed) @@ -143,13 +132,23 @@ done ## change directory to the Firefox profile directory cd "$(dirname "${SCRIPT_FILE}")" +# Check if running as root and if any files have the owner/group as root/wheel. +if [ "${EUID:-"$(id -u)"}" -eq 0 ]; then + fQuit 1 "You shouldn't run this with elevated privileges (such as with doas/sudo)." +elif [ -n "$(find ./ -user 0 -o -group 0)" ]; then + printf 'It looks like this script was previously run with elevated privileges, +you will need to change ownership of the following files to your user:\n' + find . -user 0 -o -group 0 + fQuit 1 +fi + [ "$AUTOUPDATE" = true ] && update_prefsCleaner "$@" echo -e "\n\n" echo " ╔══════════════════════════╗" echo " ║ prefs.js cleaner ║" echo " ║ by claustromaniac ║" -echo " ║ v1.9 ║" +echo " ║ v2.0 ║" echo " ╚══════════════════════════╝" echo -e "\nThis script should be run from your Firefox profile directory.\n" echo "It will remove any entries from prefs.js that also exist in user.js."