Skip to content

Commit dbf87cf

Browse files
committed
feat: guard root privileges on (un)install (fix #55)
1 parent 1d97e2d commit dbf87cf

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ubuntu-mainline-kernel.sh

+11
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,13 @@ check_environment () {
415415
fi
416416
}
417417

418+
guard_run_as_root () {
419+
if [ "$(id -u)" -ne 0 ]; then
420+
echo "The '$run_action' command requires root privileges"
421+
exit 2
422+
fi
423+
}
424+
418425
# execute requested action
419426
case $run_action in
420427
help)
@@ -529,6 +536,9 @@ Optional:
529536
done) | $column
530537
;;
531538
install)
539+
# only ensure running if the kernel files should be installed
540+
[ $do_install -eq 1 ] && guard_run_as_root
541+
532542
check_environment
533543
load_local_versions
534544

@@ -738,6 +748,7 @@ Optional:
738748
fi
739749
;;
740750
uninstall)
751+
guard_run_as_root
741752
load_local_versions
742753

743754
if [ ${#LOCAL_VERSIONS[@]} -eq 0 ]; then

0 commit comments

Comments
 (0)