added further checks

master 0.2
KatolaZ 7 years ago
parent fe87591ab6
commit 1df4353134
  1. 2
      TODO
  2. 24
      gosher

@ -1,5 +1,5 @@
- use getopt
- add chroot and privilege drop - add chroot and privilege drop
- allow on-the-fly creation of gopherfle from a folder (set it active - allow on-the-fly creation of gopherfle from a folder (set it active
through an option) through an option)

@ -43,7 +43,7 @@ NETCAT="nc.openbsd"
### use named pipes (Does *not* work with original netcat!!!!!) ### use named pipes (Does *not* work with original netcat!!!!!)
STYLE='pipe' STYLE='pipe'
OPREFIX=/tmp/outf_ ### prefix of the input FIFO
IPREFIX=/tmp/inf_ IPREFIX=/tmp/inf_
DEBUG= DEBUG=
@ -63,6 +63,8 @@ cleanup(){
} }
MYNAME=$(basename $0) MYNAME=$(basename $0)
MYDIR=$(dirname $(realpath $0))
NETCAT=$(which $NETCAT)
if [ -z "${MYNAME#gosher}" ]; then if [ -z "${MYNAME#gosher}" ]; then
## we are called as gosher -- launch the server ## we are called as gosher -- launch the server
@ -70,28 +72,38 @@ if [ -z "${MYNAME#gosher}" ]; then
PORT=${1:-70} PORT=${1:-70}
GOPHERDIR=${2:-"./"} GOPHERDIR=${2:-"./"}
[ ! -f "${NETCAT}" -o ! -x "${NETCAT}" ] && {
echo "Wrong NETCAT -- Exiting" >&2
exit 2
}
if [ -f "${MYDIR}/gosher_serve" -o -h "${MYDIR}/gosher_serve" ]; then
GOSHER_SERVE="${MYDIR}/gosher_serve"
trap cleanup 0 HUP INT TRAP TERM QUIT trap cleanup 0 HUP INT TRAP TERM QUIT
INF=${IPREFIX}$$ INF=${IPREFIX}$$
[ "$STYLE" = "pipe" ] && { [ "$STYLE" = "pipe" ] && {
mkfifo -m 600 $INF mkfifo -m 600 $INF
while [ 1 -eq 1 ]; do while [ 1 -eq 1 ]; do
./gosher_serve ${GOPHERDIR} <$INF | ${NETCAT} -vvvvv -l -p ${PORT} >$INF ${GOSHER_SERVE} ${GOPHERDIR} <$INF | ${NETCAT} -vvvvv -l -p ${PORT} >$INF
done done
rm -f $INF rm -f $INF
exit 0 exit 0
} }
[ "$STYLE" = 'fork' ] && { [ "$STYLE" = 'fork' ] && {
while [ 1 -eq 1 ]; do while [ 1 -eq 1 ]; do
${NETCAT} -vv -l -p $PORT -c "~/gosher_serve ${GOPHERDIR}" ${NETCAT} -vv -l -p $PORT -c "${GOSHERSERVE} ${GOPHERDIR}"
done done
exit 0 exit 0
} }
echo "Error!!! wrong STYLE specified!!!" >&2 echo "Wrong STYLE specified -- Exiting" >&2
exit 1 exit 2
else
echo "Cannot find gosher_serve -- Exiting">&2
exit 3
fi
fi fi
###################### ######################
## ##

Loading…
Cancel
Save