Run root check before attempting nonint functions

Fixes #191, fixes #113
This commit is contained in:
Serge Schneider 2022-04-25 15:00:59 +01:00
parent 2be7313596
commit 73e3017715
2 changed files with 12 additions and 6 deletions

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
raspi-config (20220425) UNRELEASED; urgency=medium
* Run root check before attempting nonint functions
-- Serge Schneider <serge@raspberrypi.com> Mon, 25 Apr 2022 15:00:17 +0100
raspi-config (20220419) bullseye; urgency=medium
* Reinstate -R parameter for xcompmgr

View File

@ -2809,6 +2809,12 @@ nonint() {
"$@"
}
# Everything needs to be run as root
if [ $(id -u) -ne 0 ]; then
printf "Script must be run as root. Try 'sudo raspi-config'\n"
exit 1
fi
#
# Command line options for non-interactive use
#
@ -2854,12 +2860,6 @@ done
# exit 0
#fi
# Everything else needs to be run as root
if [ $(id -u) -ne 0 ]; then
printf "Script must be run as root. Try 'sudo raspi-config'\n"
exit 1
fi
if [ -n "${OPT_MEMORY_SPLIT:-}" ]; then
set -e # Fail when a command errors
set_memory_split "${OPT_MEMORY_SPLIT}"