diff options
author | Leah Neukirchen <leah@vuxu.org> | 2020-05-09 18:56:36 +0200 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2020-05-09 18:56:36 +0200 |
commit | 0eb07e4d8f1603fdecd41bee72dd080a50e5e12a (patch) | |
tree | ec7d2c44d8b0685fe5b3ea707decb7d879ce5d21 | |
parent | 8fb0184621448f8c536a7c9a6000587345a0d8e7 (diff) | |
download | hittpd-0eb07e4d8f1603fdecd41bee72dd080a50e5e12a.tar.gz hittpd-0eb07e4d8f1603fdecd41bee72dd080a50e5e12a.tar.xz hittpd-0eb07e4d8f1603fdecd41bee72dd080a50e5e12a.zip |
add -I to disable directory indexes
-rw-r--r-- | hittpd.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/hittpd.c b/hittpd.c index 122d28d..d6c507c 100644 --- a/hittpd.c +++ b/hittpd.c @@ -101,6 +101,7 @@ char *wwwroot = default_wwwroot; int tilde = 0; int vhost = 0; int quiet = 0; +int show_index = 1; static int on_url(http_parser *p, const char *s, size_t l) @@ -610,6 +611,9 @@ on_message_complete(http_parser *p) { return 0; } + if (!show_index) + return send_error(p, 403, "Forbidden"); + char *buf; size_t len; @@ -867,18 +871,19 @@ main(int argc, char *argv[]) char *uds = 0; int c; - while ((c = getopt(argc, argv, "h:p:qu:HV")) != -1) + while ((c = getopt(argc, argv, "h:p:qu:IHV")) != -1) switch (c) { case 'h': host = optarg; break; case 'p': port = optarg; break; case 'u': uds = optarg; break; case 'q': quiet = 1; break; + case 'I': show_index = 0; break; case 'H': tilde = 1; break; case 'V': vhost = 1; break; default: fprintf(stderr, "Usage: %s [-h HOST] [-p PORT] [-u SOCKET] " - "[-HVq] [DIRECTORY]\n", argv[0]); + "[-IHVq] [DIRECTORY]\n", argv[0]); exit(1); } |