check if user can sudo/doas

main
Robert 4 weeks ago
parent 108b061201
commit bef4c6465e
  1. 16
      .bash_aliases
  2. 2
      .gitignore

@ -12,23 +12,24 @@ toggle_protection() {
local choice local choice
mkdir -p ~/.data mkdir -p ~/.data
if id -nG | grep -qwE 'sudo|wheel|doas|admin|root'; then
while true; do while true; do
echo "Do you want protection ON or OFF?" echo "Do you want protection ON or OFF?"
echo "Protection will look for changes in the system, if found it will alert you. Its not perfect, but a smiple check." echo "Protection will look for changes in the system, if found it will alert you. Its not perfect, but a smiple check."
echo "Note if truning on, please be an SUDOer or tell root what your doing! This is a global setting!"
echo "1) ON" echo "1) ON"
echo "2) OFF" echo "2) OFF"
read -p "Enter your choice (1 or 2): " choice read -p "Enter your choice (1 or 2): " choice
case "$choice" in case "$choice" in
1|on|ON|On|yes|y) 1|on|ON|On|yes|y)
touch ~/.data/protectionON touch ~/.data/${USER}_protectionON
echo "✓ Protection is now ON" echo "✓ Protection is now ON"
return 0 return 0
;; ;;
2|off|OFF|Off|no|n) 2|off|OFF|Off|no|n)
touch ~/.data/protectionOFF touch ~/.data/${USER}_protectionOFF
echo "✓ Protection is now OFF" echo "✓ Protection is now OFF"
return 0 return 0
;; ;;
@ -38,12 +39,17 @@ toggle_protection() {
;; ;;
esac esac
done done
else
echo "You cannot become root, so disabling extra protection..." touch ~/.data/${USER}_protectionOFF
fi
} }
if [[ -f ~/scripts/helper/scan_aliases.sh && -f ~/.data/protectionON ]]; then if [[ -f ~/scripts/helper/scan_aliases.sh && -f ~/.data/${USER}_protectionON ]]; then
source ~/scripts/helper/scan_aliases.sh source ~/scripts/helper/scan_aliases.sh
else else
if [ -f ~/.data/protectionOFF ]; then if [ -f ~/.data/${USER}_protectionOFF ]; then
SANE_TEST_FAILED=0 SANE_TEST_FAILED=0
else else
toggle_protection toggle_protection

2
.gitignore vendored

@ -1,2 +1,2 @@
.data/*.sum .data/*.sum
.data/protection* .data/*_protection*

Loading…
Cancel
Save