bozohttpd: init

This commit is contained in:
embr 2021-04-28 22:49:55 +02:00
parent 0b6531b9e8
commit caaee8a55e
4 changed files with 193 additions and 0 deletions

View File

@ -0,0 +1,12 @@
diff --git a/libexec/httpd/bozohttpd.c b/libexec/httpd/bozohttpd.c
index 67083b2c6782..273cb5f5a42b 100644
--- a/libexec/httpd/bozohttpd.c
+++ b/libexec/httpd/bozohttpd.c
@@ -138,6 +138,7 @@
#include <grp.h>
#include <stdarg.h>
#include <stdlib.h>
+#include <stdint.h>
#include <strings.h>
#include <string.h>
#include <syslog.h>

View File

@ -0,0 +1,88 @@
diff --git a/libexec/httpd/auth-bozo.c b/libexec/httpd/auth-bozo.c
index a2f2ee4304c1..c9eefe3313dd 100644
--- a/libexec/httpd/auth-bozo.c
+++ b/libexec/httpd/auth-bozo.c
@@ -54,7 +54,7 @@ bozo_auth_check(bozo_httpreq_t *request, const char *file)
bozohttpd_t *httpd = request->hr_httpd;
struct stat sb;
char dir[MAXPATHLEN], authfile[MAXPATHLEN], *basename;
- char user[BUFSIZ], *pass;
+ char user[BOZO_MINBUFSIZE], *pass;
FILE *fp;
int len;
@@ -144,7 +144,7 @@ bozo_auth_check_headers(bozo_httpreq_t *request, char *val, char *str,
if (strcasecmp(val, "authorization") == 0 &&
strncasecmp(str, "Basic ", 6) == 0) {
- char authbuf[BUFSIZ];
+ char authbuf[BOZO_MINBUFSIZE];
char *pass = NULL;
ssize_t alen;
diff --git a/libexec/httpd/bozohttpd.c b/libexec/httpd/bozohttpd.c
index 273cb5f5a42b..f619567ba822 100644
--- a/libexec/httpd/bozohttpd.c
+++ b/libexec/httpd/bozohttpd.c
@@ -2275,7 +2275,7 @@ bozo_http_error(bozohttpd_t *httpd, int code, bozo_httpreq_t *request,
}
#endif /* !NO_USER_SUPPORT */
- size = snprintf(httpd->errorbuf, BUFSIZ,
+ size = snprintf(httpd->errorbuf, BOZO_MINBUFSIZE,
"<html><head><title>%s</title></head>\n"
"<body><h1>%s</h1>\n"
"%s%s: <pre>%s</pre>\n"
@@ -2285,10 +2285,10 @@ bozo_http_error(bozohttpd_t *httpd, int code, bozo_httpreq_t *request,
user ? user : "", file,
reason, hostname, portbuf, hostname, portbuf);
free(user);
- if (size >= (int)BUFSIZ) {
+ if (size >= (int)BOZO_MINBUFSIZE) {
bozowarn(httpd,
"bozo_http_error buffer too small, truncated");
- size = (int)BUFSIZ;
+ size = (int)BOZO_MINBUFSIZE;
}
if (file_alloc)
@@ -2515,7 +2515,7 @@ bozo_init_httpd(bozohttpd_t *httpd)
httpd->mmapsz = BOZO_MMAPSZ;
/* error buffer for bozo_http_error() */
- if ((httpd->errorbuf = malloc(BUFSIZ)) == NULL) {
+ if ((httpd->errorbuf = malloc(BOZO_MINBUFSIZE)) == NULL) {
fprintf(stderr,
"bozohttpd: memory_allocation failure\n");
return 0;
diff --git a/libexec/httpd/bozohttpd.h b/libexec/httpd/bozohttpd.h
index c83bd112d9d7..7b19494cf5ad 100644
--- a/libexec/httpd/bozohttpd.h
+++ b/libexec/httpd/bozohttpd.h
@@ -227,6 +227,8 @@ typedef struct bozoprefs_t {
/* only allow this many total headers bytes */
#define BOZO_HEADERS_MAX_SIZE (16 * 1024)
+#define BOZO_MINBUFSIZE (4 * 1024)
+
/* debug flags */
#define DEBUG_NORMAL 1
#define DEBUG_FAT 2
diff --git a/libexec/httpd/testsuite/t10.out b/libexec/httpd/testsuite/t10.out
index cf410110627c..b3ab88f94fb9 100644
--- a/libexec/httpd/testsuite/t10.out
+++ b/libexec/httpd/testsuite/t10.out
@@ -1,8 +1,8 @@
HTTP/1.0 404 Not Found
Content-Type: text/html
-Content-Length: 1024
-Server: bozohttpd/20140708
+Content-Length: 4096
+Server: bozohttpd/20210403
<html><head><title>404 Not Found</title></head>
<body><h1>404 Not Found</h1>
-/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
\ No newline at end of file

View File

@ -0,0 +1,91 @@
{ lib
, stdenv
, fetchurl
, bmake
, groff
, inetutils
, wget
, openssl
, userSupport ? true
, cgiSupport ? true
, dirIndexSupport ? true
, dynamicContentSupport ? true
, sslSupport ? true
, luaSupport ? true
, lua
, htpasswdSupport ? true
}:
let inherit (lib) optional optionals;
in
stdenv.mkDerivation rec {
pname = "bozohttpd";
version = "20210227";
# bozohttpd is developed in-tree in pkgsrc, canonical hashes can be found at:
# http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/www/bozohttpd/distinfo
src = fetchurl {
url = "http://www.eterna.com.au/${pname}/${pname}-${version}.tar.bz2";
sha512 = "b838498626ffb7f7e84f31611e0e99aaa3af64bd9376e1a13ec16313c182eebfd9ea2c2d03904497239af723bf34a3d2202dac1f2d3e55f9fd076f6d45ccfa33";
};
# backport two unreleased commits to fix builds on non-netbsd platforms.
patches = [
# add missing `#include <stdint.h>`
# https://freshbsd.org/netbsd/src/commit/qMGNoXfgeieZBVRC
./0001-include-stdint.h.patch
# BUFSIZ is not guaranteed to be large enough
# https://freshbsd.org/netbsd/src/commit/A4ueIHIp3JgjNVRC
./0002-dont-use-host-BUFSIZ.patch
];
patchFlags = [ "-p3" ];
buildInputs = [ openssl ] ++ optional (luaSupport) lua;
nativeBuildInputs = [ bmake groff ];
COPTS =
[
"-DNO_BLOCKLIST_SUPPORT" # unpackaged dependency: https://man.netbsd.org/blocklist.3
]
++ optional (!userSupport) "-DNO_USER_SUPPORT"
++ optional (!dirIndexSupport) "-DNO_DIRINDEX_SUPPORT"
++ optional (!dynamicContentSupport) "-DNO_DYNAMIC_CONTENT"
++ optional (!luaSupport) "-DNO_LUA_SUPPORT"
++ optional (!sslSupport) "-DNO_SSL_SUPPORT"
++ optional (!cgiSupport) "-DNO_CGIBIN_SUPPORT"
++ optional (htpasswdSupport) "-DDO_HTPASSWD";
_LDADD = [ "-lcrypt" "-lm" ]
++ optional (luaSupport) "-llua"
++ optionals (sslSupport) [ "-lssl" "-lcrypto" ];
makeFlags = [ "LDADD=$(_LDADD)" ];
doCheck = true;
checkInputs = [ inetutils wget ];
checkFlags = [ "-dx" "VERBOSE=yes" ] ++ optional (!cgiSupport) "CGITESTS=";
installPhase = ''
install -m755 -Dt $out/bin bozohttpd
install -m644 -Dt $out/share/man/man8 bozohttpd.8
'';
meta = with lib; {
description = "Bozotic HTTP server; small and secure";
longDescription = ''
bozohttpd is a small and secure HTTP version 1.1 server. Its main
feature is the lack of features, reducing the code size and improving
verifiability.
It supports CGI/1.1, HTTP/1.1, HTTP/1.0, HTTP/0.9, ~user translations,
virtual hosting support, as well as multiple IP-based servers on a
single machine. It is capable of servicing pages via the IPv6 protocol.
It has SSL support. It has no configuration file by design.
'';
homepage = "http://www.eterna.com.au/bozohttpd/";
changelog = "http://www.eterna.com.au/bozohttpd/CHANGES";
license = licenses.bsd2;
maintainers = [ maintainers.embr ];
platforms = platforms.all;
};
}

View File

@ -1953,6 +1953,8 @@ in
boxfs = callPackage ../tools/filesystems/boxfs { };
bozohttpd = callPackage ../servers/http/bozohttpd { };
bpytop = callPackage ../tools/system/bpytop { };
brasero-original = lowPrio (callPackage ../tools/cd-dvd/brasero { });