lbmk: run ./build dependencies *before* root check
After that, do not allow anything to run if the user is root. This logic flow is more robust, and reduces the chance of bugs in the future. We must not permit the user to run lbmk as root. Running it as root *is* possible, by just removing the check, and wily enough users will do that, but this behaviour in lbmk is good practise because it prevents accidentally running as root. If the user went into root just for installing dependencies, they might accidentally forget to switch back. This is a safeguard against such folly. Signed-off-by: Leah Rowe <leah@libreboot.org>btrfsvols
parent
6722624dfc
commit
c6fd4d2ad3
20
lbmk
20
lbmk
|
@ -40,8 +40,19 @@ main()
|
|||
[ $# -lt 1 ] && err "Too few arguments. Try: ${0} help"
|
||||
|
||||
mode="${1}"
|
||||
if [ "$(id -u)" = "0" ] && [ "${mode}" != "dependencies" ]; then
|
||||
err "running lbmk as root is not permitted"
|
||||
if [ "${mode}" = "dependencies" ]; then
|
||||
if [ $# -lt 2 ]; then
|
||||
printf "You must specify a distro, namely:\n" 1>&2
|
||||
printf "Look at files under resources/dependencies/\n" \
|
||||
1>&2
|
||||
printf "Example: ./build dependencies debian\n" 1>&2
|
||||
err "target not specified"
|
||||
fi
|
||||
install_dependencies $@ || err "Could not install dependencies"
|
||||
exit 0
|
||||
fi
|
||||
if [ "$(id -u)" = "0" ]; then
|
||||
err "running this command as root is not permitted"
|
||||
fi
|
||||
|
||||
buildpath="./script/${0##*/}"
|
||||
|
@ -51,11 +62,6 @@ main()
|
|||
exit 0
|
||||
[ $# -lt 2 ] && usage ${0} && exit 1
|
||||
|
||||
if [ "${mode}" = "dependencies" ]; then
|
||||
install_dependencies $@ || err "Could not install dependencies"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
./checkgit || err "Please read: https://libreboot.org/docs/build/"
|
||||
|
||||
option="${2}"
|
||||
|
|
Loading…
Reference in New Issue