add: sudowarning

master
zeus 2023-04-27 10:44:02 +02:00
parent 844c879f2d
commit 1dc5b0b858
1 changed files with 13 additions and 0 deletions

13
bash/sudowarning.sh Normal file
View File

@ -0,0 +1,13 @@
#!/bin/bash
# sudowarning this perferably goes to /etc/bash.bashrc
# This shows a custom warning before executeing sudo. Ideal to prevent sudo-usage on host, where this is unwanted (like jumphosts)
sudo () {
local command=$@
read -rp "You are about to run the command $(echo -e "\e[1;34;33m$command\e[0m") on the Jumphost. As root. Are you really sure? (y/N):"
if [[ "$REPLY" = [yY]* ]]; then
command sudo "$@"
else
return $?
fi
}