Skip to content

Commit f2e4a79

Browse files
Celestial Nebulatriallaxearthlng
authored
updater.sh/prefsCleaner.sh: Check for root and abort (#1651)
* updater.sh/prefsCleaner.sh: Check for root and abort Check if running as root and if any files have the owner/group as root|wheel. Abort on both. Should (hopefully) prevent stuff like: #1587 Discussion: #1595 --------- Co-authored-by: Mohammed Anas <triallax@tutanota.com> Co-authored-by: earthlng <earthlng@users.noreply.github.com>
1 parent c84c419 commit f2e4a79

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

prefsCleaner.sh

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

33
## prefs.js cleaner for Linux/Mac
44
## author: @claustromaniac
5-
## version: 1.6
5+
## version: 1.7
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+
1122
readonly CURRDIR=$(pwd)
1223
1324
## get the full path of this script (readlink for Linux, greadlink for Mac with coreutils installed)
@@ -138,7 +149,7 @@ echo -e "\n\n"
138149
echo " ╔══════════════════════════╗"
139150
echo " ║ prefs.js cleaner ║"
140151
echo " ║ by claustromaniac ║"
141-
echo " ║ v1.6"
152+
echo " ║ v1.7 ║"
142153
echo " ╚══════════════════════════╝"
143154
echo -e "\nThis script should be run from your Firefox profile directory.\n"
144155
echo "It will remove any entries from prefs.js that also exist in user.js."

updater.sh

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

33
## arkenfox user.js updater for macOS and Linux
44

5-
## version: 3.5
5+
## version: 3.6
66
## Author: Pat Johnson (@overdodactyl)
77
## Additional contributors: @earthlng, @ema-pe, @claustromaniac, @infinitewarp
88

99
## DON'T GO HIGHER THAN VERSION x.9 !! ( because of ASCII comparison in update_updater() )
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+
1122
readonly CURRDIR=$(pwd)
1223
1324
SCRIPT_FILE=$(readlink -f "${BASH_SOURCE[0]}" 2>/dev/null || greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null)

0 commit comments

Comments
 (0)