summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2018-08-14 07:01:14 +0100
committerKatolaZ <katolaz@freaknet.org>2018-08-14 07:01:14 +0100
commite8292927e355e6d5499ff5691482923ffc576202 (patch)
tree21cb23c1751e823d0c66456b62315dfa7c44df9d
parent02f1dc94fdad9b09db9cd4f40d8bf3ce02142da2 (diff)
added check of nc implementationHEADmaster
-rwxr-xr-xgosher24
1 files changed, 20 insertions, 4 deletions
diff --git a/gosher b/gosher
index 16d2d83..73f5255 100755
--- a/gosher
+++ b/gosher
@@ -51,7 +51,7 @@ NETCAT="nc"
##
## NETCAT_OPTS: any additional options to netcat
##
-NETCAT_OPTS=""
+NETCAT_OPTS="-v"
##
## STYLE: The way in which netcat will talk to gosher_serve
@@ -94,20 +94,36 @@ if [ -z "${MYNAME#gosher}" ]; then
echo "Wrong NETCAT -- Exiting" >&2
exit 2
}
+ is_openbsd=$(echo "${NETCAT}" | grep -i "certfile")
if [ -f "${MYDIR}/gosher_serve" ] || [ -h "${MYDIR}/gosher_serve" ]; then
GOSHER_SERVE="${MYDIR}/gosher_serve"
trap cleanup 0 HUP INT TRAP TERM QUIT
INF="${IPREFIX}$$"
- [ "$STYLE" = "pipe" ] && {
+ [ "$STYLE" = "pipe" -a -n "${is_openbsd}" ] && {
+ echo "Genuine OpenBSD nc detected" >&2
mkfifo -m 600 "$INF"
# shellcheck disable=SC2050
while :; do
# shellcheck disable=SC2094
${GOSHER_SERVE} "${GOPHERDIR}" \
"${HOSTNAME}" "${PORT}" <"$INF" |\
- ${NETCAT} -vvvvv -l "${HOSTNAME}" "${PORT}" >"$INF"
+ ${NETCAT} ${NETCAT_OPTS} -l "${HOSTNAME}" "${PORT}" >"$INF"
+ sleep 1
+ done
+ rm -f $INF
+ exit 0
+ }
+ [ "$STYLE" = "pipe" -a -z "${is_openbsd}" ] && {
+ echo "Other nc implementation detected" >&2
+ mkfifo -m 600 "$INF"
+# shellcheck disable=SC2050
+ while :; do
+# shellcheck disable=SC2094
+ ${GOSHER_SERVE} "${GOPHERDIR}" \
+ "${HOSTNAME}" "${PORT}" <"$INF" |\
+ ${NETCAT} ${NETCAT_OPTS} -l -p "${PORT}" >"$INF"
sleep 1
done
rm -f $INF
@@ -116,7 +132,7 @@ if [ -z "${MYNAME#gosher}" ]; then
[ "$STYLE" = 'fork' ] && {
# shellcheck disable=SC2050
while :; do
- ${NETCAT} -vv -l -p "$PORT" -c \
+ ${NETCAT} ${NETCAT_OPTS} -l -p "$PORT" -c \
"${GOSHER_SERVE} ${GOPHERDIR} ${HOSTNAME} ${PORT}"
sleep 1
done