Created
October 22, 2012 08:43
-
-
Save Raven24/3930399 to your computer and use it in GitHub Desktop.
root inhibition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# Don't allow a given command to be run as root. | |
# This script will output an error message, in case the current | |
# user is identified as root (also works in case of 'sudo') | |
# do we have color ? | |
case "$TERM" in | |
xterm*|rxvt*) | |
read -r red RED blue BLUE cyan CYAN NC <<EOF | |
\033[0;31m \033[1;31m \033[0;34m \033[1;34m \033[0;36m \033[1;36m \033[0m | |
EOF | |
;; | |
esac | |
# don't allow root to run this command | |
if [ `whoami` = "root" ] ; then | |
printf "${red}don't run '${cyan}$*${red}' as ${RED}root${red}!${NC}\n" | |
exit 1 | |
fi | |
# show time | |
eval $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment