From bfc10ee6b315fb282bdcdb3652370b6e85c274f5 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Mon, 16 Jul 2018 15:56:58 +0100 Subject: removed -c from netcat options (using fifos) --- gosher | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/gosher b/gosher index b4263c0..a099731 100755 --- a/gosher +++ b/gosher @@ -22,6 +22,19 @@ ## server... ## +NETCAT=netcat +OPREFIX=/tmp/outf_ +IPREFIX=/tmp/inf_ + + +## function +cleanup(){ + [ -p "${OPREFIX}$$" ] && rm -f ${OPREFIX}$$ + [ -p "${IPREFIX}$$" ] && rm -f ${IPREFIX}$$ + exit 1 + +} + MYNAME=$(basename $0) if [ -z "${MYNAME#gosher}" ]; then @@ -30,8 +43,15 @@ if [ -z "${MYNAME#gosher}" ]; then PORT=${1:-70} GOPHERDIR=${2:-"./"} + trap cleanup 0 HUP INT TRAP TERM QUIT + while [ 1 -eq 1 ]; do - netcat -vv -k -l -p ${PORT} -c "./gosher_serve ${GOPHERDIR}" + OUTF=${OPREFIX}$$ + INF=${IPREFIX}$$ + mkfifo -m 600 $OUTF $INF + ./gosher_serve ${GOPHERDIR} <$INF >$OUTF & + ${NETCAT} -vv -l -p ${PORT} >$INF <$OUTF + rm $OUTF $INF ret=$? done exit 0 -- cgit v1.2.3