diff options
| author | mrg <mrg@NetBSD.org> | 2019-01-22 05:32:57 +0000 |
|---|---|---|
| committer | mrg <mrg@NetBSD.org> | 2019-01-22 05:32:57 +0000 |
| commit | 16ebe93fc1424e85cc6665917b4328023781485a (patch) | |
| tree | b2f638729f6458e9357e55ea3ad972398c5daad5 /libexec | |
| parent | 72b1bacc6a1f214b94cacb1d7fde41e3a325e2f1 (diff) | |
o don't display special files in the directory index. they aren't
served, but links to them are generated.
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/httpd/CHANGES | 6 | ||||
| -rw-r--r-- | libexec/httpd/auth-bozo.c | 4 | ||||
| -rw-r--r-- | libexec/httpd/bozohttpd.c | 24 | ||||
| -rw-r--r-- | libexec/httpd/bozohttpd.h | 6 | ||||
| -rw-r--r-- | libexec/httpd/dir-index-bozo.c | 5 |
5 files changed, 30 insertions, 15 deletions
diff --git a/libexec/httpd/CHANGES b/libexec/httpd/CHANGES index 384ff969f56..b8cf9e968b9 100644 --- a/libexec/httpd/CHANGES +++ b/libexec/httpd/CHANGES @@ -1,4 +1,8 @@ -$NetBSD: CHANGES,v 1.36 2019/01/17 07:46:16 mrg Exp $ +$NetBSD: CHANGES,v 1.37 2019/01/22 05:32:57 mrg Exp $ + +changes in bozohttpd 20190121: + o don't display special files in the directory index. they aren't + served, but links to them are generated. changes in bozohttpd 20190116: o fix CGI '+' parameter handling, some error checking, and a double diff --git a/libexec/httpd/auth-bozo.c b/libexec/httpd/auth-bozo.c index f8d96692044..ee83281c332 100644 --- a/libexec/httpd/auth-bozo.c +++ b/libexec/httpd/auth-bozo.c @@ -1,4 +1,4 @@ -/* $NetBSD: auth-bozo.c,v 1.22 2018/11/22 08:54:08 mrg Exp $ */ +/* $NetBSD: auth-bozo.c,v 1.23 2019/01/22 05:32:57 mrg Exp $ */ /* $eterna: auth-bozo.c,v 1.17 2011/11/18 09:21:15 mrg Exp $ */ @@ -64,7 +64,7 @@ bozo_auth_check(bozo_httpreq_t *request, const char *file) strcpy(dir, "."); else { *basename++ = '\0'; - if (bozo_check_special_files(request, basename)) + if (bozo_check_special_files(request, basename, true)) return 1; } request->hr_authrealm = bozostrdup(httpd, request, dir); diff --git a/libexec/httpd/bozohttpd.c b/libexec/httpd/bozohttpd.c index 23d2bfa0893..6a07302fbf2 100644 --- a/libexec/httpd/bozohttpd.c +++ b/libexec/httpd/bozohttpd.c @@ -1,4 +1,4 @@ -/* $NetBSD: bozohttpd.c,v 1.110 2019/01/18 06:04:10 mrg Exp $ */ +/* $NetBSD: bozohttpd.c,v 1.111 2019/01/22 05:32:57 mrg Exp $ */ /* $eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $ */ @@ -109,7 +109,7 @@ #define INDEX_HTML "index.html" #endif #ifndef SERVER_SOFTWARE -#define SERVER_SOFTWARE "bozohttpd/20190116" +#define SERVER_SOFTWARE "bozohttpd/20190121" #endif #ifndef PUBLIC_HTML #define PUBLIC_HTML "public_html" @@ -140,7 +140,6 @@ #include <signal.h> #include <stdarg.h> #include <stdlib.h> -#include <stdbool.h> #include <strings.h> #include <string.h> #include <syslog.h> @@ -1461,7 +1460,7 @@ check_bzredirect(bozo_httpreq_t *request) *basename++ = '\0'; strcpy(path, dir); } - if (bozo_check_special_files(request, basename)) + if (bozo_check_special_files(request, basename, true)) return -1; debug((httpd, DEBUG_FAT, "check_bzredirect: path %s", path)); @@ -1913,17 +1912,24 @@ bozo_process_request(bozo_httpreq_t *request) /* make sure we're not trying to access special files */ int -bozo_check_special_files(bozo_httpreq_t *request, const char *name) +bozo_check_special_files(bozo_httpreq_t *request, const char *name, bool doerror) { bozohttpd_t *httpd = request->hr_httpd; size_t i; + int error = 0; - for (i = 0; specials[i].file; i++) - if (strcmp(name, specials[i].file) == 0) - return bozo_http_error(httpd, 403, request, + for (i = 0; specials[i].file; i++) { + if (strcmp(name, specials[i].file) == 0) { + if (doerror) { + error = bozo_http_error(httpd, 403, request, specials[i].name); + } else { + error = -1; + } + } + } - return 0; + return error; } /* generic header printing routine */ diff --git a/libexec/httpd/bozohttpd.h b/libexec/httpd/bozohttpd.h index 45654d5f603..2045f9398f3 100644 --- a/libexec/httpd/bozohttpd.h +++ b/libexec/httpd/bozohttpd.h @@ -1,4 +1,4 @@ -/* $NetBSD: bozohttpd.h,v 1.57 2018/11/24 13:02:46 christos Exp $ */ +/* $NetBSD: bozohttpd.h,v 1.58 2019/01/22 05:32:57 mrg Exp $ */ /* $eterna: bozohttpd.h,v 1.39 2011/11/18 09:21:15 mrg Exp $ */ @@ -34,6 +34,8 @@ #include "netbsd_queue.h" +#include <stdbool.h> + #include <sys/stat.h> #ifndef NO_LUA_SUPPORT @@ -259,7 +261,7 @@ void debug__(bozohttpd_t *, int, const char *, ...) BOZO_PRINTFLIKE(3, 4); /* be sure to always return this error up */ int bozo_http_error(bozohttpd_t *, int, bozo_httpreq_t *, const char *); -int bozo_check_special_files(bozo_httpreq_t *, const char *) BOZO_CHECKRET; +int bozo_check_special_files(bozo_httpreq_t *, const char *, bool) BOZO_CHECKRET; char *bozo_http_date(char *, size_t); void bozo_print_header(bozo_httpreq_t *, struct stat *, const char *, const char *); diff --git a/libexec/httpd/dir-index-bozo.c b/libexec/httpd/dir-index-bozo.c index 1c0aa01e966..07ba72143dc 100644 --- a/libexec/httpd/dir-index-bozo.c +++ b/libexec/httpd/dir-index-bozo.c @@ -1,4 +1,4 @@ -/* $NetBSD: dir-index-bozo.c,v 1.30 2019/01/17 07:46:16 mrg Exp $ */ +/* $NetBSD: dir-index-bozo.c,v 1.31 2019/01/22 05:32:57 mrg Exp $ */ /* $eterna: dir-index-bozo.c,v 1.20 2011/11/18 09:21:15 mrg Exp $ */ @@ -148,6 +148,9 @@ bozo_dir_index(bozo_httpreq_t *request, const char *dirpath, int isindex) httpd->hide_dots && name[0] == '.')) continue; + if (bozo_check_special_files(request, name, false)) + continue; + snprintf(buf, sizeof buf, "%s/%s", dirpath, name); if (stat(buf, &sb)) nostat = 1; |
