diff --git a/shellgopher.sh b/shellgopher.sh index 1caca7a..d912e76 100644 --- a/shellgopher.sh +++ b/shellgopher.sh @@ -11,6 +11,15 @@ createsrv () { nc -l "$1" <"$2" >>"$3" & exec 3>"$2" } +die () { + # $1 - error message + printf "%s\n" $1 + exit 1 +} +checkuid () { + [ $(whoami) = "root" ] && \ + die "You must execute shellgopher as root." +} writefile () { # $1 - file foo cat "$1" >&3 @@ -34,6 +43,7 @@ tmplocation=$(mktmp) writelocation="${tmplocation}/write" readlocation="${tmplocation}/read" +checkuid createsrv 70 "${writelocation}" "${readlocation}" printf "server created\n" while true; do