From 83858b60dffca6249f763e89a3a49c323dd76331 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Mon, 2 Jul 2018 13:37:46 +0200 Subject: [PATCH 1/1] auto recognize inetd mode, enabling use with busybox nc -ll --- cgilite.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cgilite.sh b/cgilite.sh index f0f2fa9..cac905f 100755 --- a/cgilite.sh +++ b/cgilite.sh @@ -49,7 +49,9 @@ HEX_DECODE(){ ')" } -if [ "$1" = '--inetd' -a -z "$REQUEST_METHOD" ]; then +if [ -z "$REQUEST_METHOD" -a -z "$SERVER_PROTOCOL" ]; then + # no webserver variables means we are running via inetd / ncat + # so use builtin web server REMOTE_ADDR="${TCPREMOTEIP:-$NCAT_REMOTE_ADDR}" SERVER_NAME="${TCPLOCALIP:-$NCAT_LOCAL_ADDR}" SERVER_PORT="${TCPLOCALPORT:-$NCAT_LOCAL_PORT}" @@ -60,13 +62,11 @@ if [ "$1" = '--inetd' -a -z "$REQUEST_METHOD" ]; then cgilite_headers="$(sed -u '/^\r\?$/q')" HTTP_CONTENT_LENGTH="$(HEADER Content-Length |grep -xE '[0-9]+')" - HTTP_COOKIE="$(HEADER Cookie)" export REMOTE_ADDR SERVER_NAME SERVER_PORT REQUEST_METHOD REQUEST_URI SERVER_PROTOCOL \ - PATH_INFO QUERY_STRING HTTP_CONTENT_LENGTH HTTP_COOKIE + PATH_INFO QUERY_STRING HTTP_CONTENT_LENGTH - . "$0" |sed '1{s;^Status: ;HTTP/1.0 ;; t; iHTTP/1.0 200 OK\r - }' + . "$0" |sed '1{s;^Status: ;HTTP/1.0 ;; t; s;^;HTTP/1.0 200 OK\r\n;;}' exit $? fi -- 2.39.2