Compare commits

...

2 Commits

Author SHA1 Message Date
randomuser 5af4557c03 check uid before executing netcat 2021-02-17 19:42:23 -06:00
randomuser f77f3fbe2e add readme 2021-02-17 19:30:20 -06:00
2 changed files with 24 additions and 0 deletions

14
README Normal file
View File

@ -0,0 +1,14 @@
shellgopher
===========
shell script based gopher server
invocation
+------------------------------------------------------------+
| # sh shellgopher.sh |
+------------------------------------------------------------+
testing
+------------------------------------------------------------+
| $ lynx gopher://localhost |
+------------------------------------------------------------+

View File

@ -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