From 1edc4dff7748d31a78fb3d6ec5dac215befb3ace Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Wed, 7 Nov 2012 19:23:28 -0700 Subject: [PATCH] Log directory indexes, add webfs script --- contrib/webfs | 14 ++++++++++++++ eris.c | 6 ++++-- test.sh | 5 ++++- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100755 contrib/webfs diff --git a/contrib/webfs b/contrib/webfs new file mode 100755 index 0000000..9678e09 --- /dev/null +++ b/contrib/webfs @@ -0,0 +1,14 @@ +#! /bin/sh + +PORT=8888 + +if [ $# = 0 ]; then + ARGS=-d +fi + +addr=$(ifconfig | awk -F '[: ]+' '/inet addr/ {print $4;}' \ + | grep -Fv 127.0.0.1 | head -n 1) + +echo Listening on http://$addr:$PORT/ + +tcpsvd 0 $PORT eris -. $ARGS "$@" diff --git a/eris.c b/eris.c index 3c77310..d5cd6e0 100644 --- a/eris.c +++ b/eris.c @@ -616,7 +616,7 @@ serve_idx(int fd, char *path) html_esc(stdout, path); printf("

Directory Listing: "); html_esc(stdout, path); - printf("

");
+    printf("
\n");
     if (path[1]) {
         printf("Parent Directory\n");
     }
@@ -661,7 +661,9 @@ serve_idx(int fd, char *path)
         url_esc(stdout, name);
         printf("\n");
     }
-    printf("
"); + printf("
\n"); + + dolog(200, 0); } void diff --git a/test.sh b/test.sh index e7ca56d..c1b8d7d 100755 --- a/test.sh +++ b/test.sh @@ -180,11 +180,14 @@ printf 'GET / HTTP/1.1\r\nIf-Modified-Since: %s\r\n\r\nGET / HTTP/1.0\r\n\r\n' " H "Directory indexing" title "Basic index" -printf 'GET /empty/ HTTP/1.0\r\n\r\n' | $HTTPD_IDX 2>/dev/null | d | grep -Fq '

Directory Listing: /empty/

Parent Directory%
' && pass || fail +printf 'GET /empty/ HTTP/1.0\r\n\r\n' | $HTTPD_IDX 2>/dev/null | d | grep -Fq '

Directory Listing: /empty/

%Parent Directory%
' && pass || fail title "Hidden file" printf 'GET /subdir/ HTTP/1.0\r\n\r\n' | $HTTPD_IDX 2>/dev/null | grep -q 'hidden' && fail || pass +title "Logging" +(printf 'GET /empty/ HTTP/1.0\r\n\r\n' | + PROTO=TCP TCPREMOTEPORT=1234 TCPREMOTEIP=10.0.0.2 $HTTPD_IDX >/dev/null) 2>&1 | grep -q '^10.0.0.2:1234 200 0 (null) (null) (null) /empty/$' && pass || fail H "CGI"