Skip to content

Commit f54d632

Browse files
authored
v2.0 - improve root check
1 parent 6e79d1b commit f54d632

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

prefsCleaner.sh

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,12 @@
22

33
## prefs.js cleaner for Linux/Mac
44
## author: @claustromaniac
5-
## version: 1.9
5+
## version: 2.0
66

77
## special thanks to @overdodactyl and @earthlng for a few snippets that I stol..*cough* borrowed from the updater.sh
88

99
## DON'T GO HIGHER THAN VERSION x.9 !! ( because of ASCII comparison in update_prefsCleaner() )
1010

11-
# Check if running as root and if any files have the owner/group as root/wheel.
12-
if [ "${EUID:-"$(id -u)"}" -eq 0 ]; then
13-
printf "You shouldn't run this with elevated privileges (such as with doas/sudo).\n"
14-
exit 1
15-
elif [ -n "$(find ./ -user 0 -o -group 0)" ]; then
16-
printf 'It looks like this script was previously run with elevated privileges,
17-
you will need to change ownership of the following files to your user:\n'
18-
find . -user 0 -o -group 0
19-
exit 1
20-
fi
21-
2211
readonly CURRDIR=$(pwd)
2312

2413
## get the full path of this script (readlink for Linux, greadlink for Mac with coreutils installed)
@@ -143,13 +132,23 @@ done
143132
## change directory to the Firefox profile directory
144133
cd "$(dirname "${SCRIPT_FILE}")"
145134

135+
# Check if running as root and if any files have the owner/group as root/wheel.
136+
if [ "${EUID:-"$(id -u)"}" -eq 0 ]; then
137+
fQuit 1 "You shouldn't run this with elevated privileges (such as with doas/sudo)."
138+
elif [ -n "$(find ./ -user 0 -o -group 0)" ]; then
139+
printf 'It looks like this script was previously run with elevated privileges,
140+
you will need to change ownership of the following files to your user:\n'
141+
find . -user 0 -o -group 0
142+
fQuit 1
143+
fi
144+
146145
[ "$AUTOUPDATE" = true ] && update_prefsCleaner "$@"
147146

148147
echo -e "\n\n"
149148
echo " ╔══════════════════════════╗"
150149
echo " ║ prefs.js cleaner ║"
151150
echo " ║ by claustromaniac ║"
152-
echo "v1.9"
151+
echo "v2.0"
153152
echo " ╚══════════════════════════╝"
154153
echo -e "\nThis script should be run from your Firefox profile directory.\n"
155154
echo "It will remove any entries from prefs.js that also exist in user.js."

0 commit comments

Comments
 (0)