diff --git a/eris.c b/eris.c index 450b146..28c0a7e 100644 --- a/eris.c +++ b/eris.c @@ -75,6 +75,7 @@ int doauth = 0; int docgi = 0; int doidx = 0; +int nochdir = 0; int redirect = 0; int portappend = 0; @@ -244,7 +245,7 @@ parse_options(int argc, char *argv[]) { int opt; - while (-1 != (opt = getopt(argc, argv, "acdhkprv"))) { + while (-1 != (opt = getopt(argc, argv, "acdhkprv."))) { switch (opt) { case 'a': doauth = 1; @@ -255,6 +256,9 @@ parse_options(int argc, char *argv[]) case 'd': doidx = 1; break; + case '.': + nochdir = 1; + break; case 'p': portappend = 1; break; @@ -264,6 +268,7 @@ parse_options(int argc, char *argv[]) case 'v': printf(FNORD "\n"); exit(0); + case 'h': default: fprintf(stderr, "Usage: %s [OPTIONS]\n", argv[0]); @@ -271,6 +276,7 @@ parse_options(int argc, char *argv[]) fprintf(stderr, "-a Enable authentication\n"); fprintf(stderr, "-c Enable CGI\n"); fprintf(stderr, "-d Enable directory listing\n"); + fprintf(stderr, "-. Serve out of ./ (no vhosting)\n"); fprintf(stderr, "-p Append port to hostname directory\n"); fprintf(stderr, "-r Enable symlink redirection\n"); fprintf(stderr, "-v Print version and exit\n"); @@ -711,7 +717,7 @@ handle_request() } /* Try to change into the appropriate directory */ - { + if (! nochdir) { char fn[PATH_MAX]; if (host) { diff --git a/test.sh b/test.sh index b32c114..e5a2719 100755 --- a/test.sh +++ b/test.sh @@ -110,6 +110,13 @@ title "Logging busybox" +H "Options" + +title "-." +printf 'GET /eris HTTP/1.0\r\n\r\n' | $HTTPD -. 2>/dev/null | grep -q 'HTTP/1.. 200 OK' && pass || fail + + + H "Tomfoolery" title "Non-header" @@ -150,7 +157,7 @@ title "ANSI C Date" printf 'GET / HTTP/1.0\r\nIf-Modified-Since: Sun Feb 27 12:12:12 2030\r\n\r\n' | $HTTPD 2>/dev/null | grep -q 'HTTP/1.. 304 ' && pass || fail title "ims persist" -printf 'GET / HTTP/1.0\r\nIf-Modified-Since: %s\r\n\r\nGET / HTTP/1.0\r\n\r\n' | $HTTPD 2>/dev/null | d | grep -q 'HTTP/1.. 304.*HTTP/1.. 200' +printf 'GET / HTTP/1.1\r\nIf-Modified-Since: %s\r\n\r\nGET / HTTP/1.0\r\n\r\n' "$ims" | $HTTPD 2>/dev/null | d | grep -q 'HTTP/1.. 304.*HTTP/1.. 200' && pass || fail @@ -214,6 +221,11 @@ printf 'GET / HTTP/1.0\r\nHost: empty\r\n\r\n' | $HTTPD_IDX 2>/dev/null | grep - title "CGI output bare newlines" printf 'GET /a.cgi HTTP/1.0\r\n\r\n' | $HTTPD_CGI 2>/dev/null | d | grep -q '#%#%' && pass || fail +## Note: fnord gets a pass on this since it only claims to be an HTTP/1.0 +## server. Eris is not 1.1 compliant either, but it at least tries to fake it. You +## should consider how much of HTTP/1.1 you want before deploying either. In practice, +## with browsers, both seems sufficient. Some tools, notably httperf, fail +## with fnord. # 3. Should process both requests; instead drops second title "Multiple requests in one packet" printf 'GET / HTTP/1.1\r\nHost: a\r\nConnection: keep-alive\r\n\r\nGET / HTTP/1.1\r\nHost: a\r\nConnection: keep-alive\r\n\r\n' | $HTTPD 2>/dev/null | grep -c '^HTTP/1.' | grep -q 2 && pass || fail