From caaee8a55e4ce0a3e4324c6bb43a32794e212a8b Mon Sep 17 00:00:00 2001 From: embr Date: Wed, 28 Apr 2021 22:49:55 +0200 Subject: [PATCH 1/7] bozohttpd: init --- .../bozohttpd/0001-include-stdint.h.patch | 12 +++ .../bozohttpd/0002-dont-use-host-BUFSIZ.patch | 88 ++++++++++++++++++ pkgs/servers/http/bozohttpd/default.nix | 91 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 4 files changed, 193 insertions(+) create mode 100644 pkgs/servers/http/bozohttpd/0001-include-stdint.h.patch create mode 100644 pkgs/servers/http/bozohttpd/0002-dont-use-host-BUFSIZ.patch create mode 100644 pkgs/servers/http/bozohttpd/default.nix diff --git a/pkgs/servers/http/bozohttpd/0001-include-stdint.h.patch b/pkgs/servers/http/bozohttpd/0001-include-stdint.h.patch new file mode 100644 index 00000000000..1d0d716290d --- /dev/null +++ b/pkgs/servers/http/bozohttpd/0001-include-stdint.h.patch @@ -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 + #include + #include ++#include + #include + #include + #include diff --git a/pkgs/servers/http/bozohttpd/0002-dont-use-host-BUFSIZ.patch b/pkgs/servers/http/bozohttpd/0002-dont-use-host-BUFSIZ.patch new file mode 100644 index 00000000000..9a01a4adce7 --- /dev/null +++ b/pkgs/servers/http/bozohttpd/0002-dont-use-host-BUFSIZ.patch @@ -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, + "%s\n" + "

%s

\n" + "%s%s:
%s
\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 + + 404 Not Found +

404 Not Found

+-/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +\ No newline at end of file diff --git a/pkgs/servers/http/bozohttpd/default.nix b/pkgs/servers/http/bozohttpd/default.nix new file mode 100644 index 00000000000..12aa438cf12 --- /dev/null +++ b/pkgs/servers/http/bozohttpd/default.nix @@ -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 ` + # 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; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f2a6953067e..f6444216f40 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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 { }); From 28508dce6a7e192339caacdb9dc7dd3d3e2e408c Mon Sep 17 00:00:00 2001 From: embr Date: Mon, 24 May 2021 13:35:09 +0200 Subject: [PATCH 2/7] bozohttpd: use bmake flags instead of a custom installPhase --- pkgs/servers/http/bozohttpd/default.nix | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pkgs/servers/http/bozohttpd/default.nix b/pkgs/servers/http/bozohttpd/default.nix index 12aa438cf12..0e97910e6f1 100644 --- a/pkgs/servers/http/bozohttpd/default.nix +++ b/pkgs/servers/http/bozohttpd/default.nix @@ -59,17 +59,12 @@ stdenv.mkDerivation rec { _LDADD = [ "-lcrypt" "-lm" ] ++ optional (luaSupport) "-llua" ++ optionals (sslSupport) [ "-lssl" "-lcrypto" ]; - makeFlags = [ "LDADD=$(_LDADD)" ]; + makeFlags = [ "LDADD=$(_LDADD)" "prefix=$(out)" "MANDIR=$(out)/share/man" "BINOWN=" ]; 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 = '' From 77acedc33b2a90f9eab71a4582e655ea5c840869 Mon Sep 17 00:00:00 2001 From: embr Date: Mon, 24 May 2021 13:35:38 +0200 Subject: [PATCH 3/7] bozohttpd: remove unnecessary checkFlags --- pkgs/servers/http/bozohttpd/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/servers/http/bozohttpd/default.nix b/pkgs/servers/http/bozohttpd/default.nix index 0e97910e6f1..e934f86f2c1 100644 --- a/pkgs/servers/http/bozohttpd/default.nix +++ b/pkgs/servers/http/bozohttpd/default.nix @@ -63,7 +63,7 @@ stdenv.mkDerivation rec { doCheck = true; checkInputs = [ inetutils wget ]; - checkFlags = [ "-dx" "VERBOSE=yes" ] ++ optional (!cgiSupport) "CGITESTS="; + checkFlags = optional (!cgiSupport) "CGITESTS="; meta = with lib; { description = "Bozotic HTTP server; small and secure"; From dc9165346e18665191b39e2ae5309e1e50b7ff40 Mon Sep 17 00:00:00 2001 From: embr Date: Wed, 26 May 2021 11:20:59 +0200 Subject: [PATCH 4/7] bozohttpd: resolve warnings, serve >2GB files on 32bit host -D_DEFAULT_SOURCE *and* -D_GNU_SOURCE together resolve all warnings about implicitly defined functions. -D_LARGEFILE_SOURCE and -D_FILE_OFFSET_BITS=64 enable gcc's Large File Extensions to allow a 32-bit host to serve files larger than 2GB. Based on what Makefile.boot does, for platforms without bmake: http://cvsweb.netbsd.org/bsdweb.cgi/src/libexec/httpd/Makefile.boot --- pkgs/servers/http/bozohttpd/default.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/servers/http/bozohttpd/default.nix b/pkgs/servers/http/bozohttpd/default.nix index e934f86f2c1..6d403756bd2 100644 --- a/pkgs/servers/http/bozohttpd/default.nix +++ b/pkgs/servers/http/bozohttpd/default.nix @@ -46,7 +46,15 @@ stdenv.mkDerivation rec { COPTS = [ - "-DNO_BLOCKLIST_SUPPORT" # unpackaged dependency: https://man.netbsd.org/blocklist.3 + "-D_DEFAULT_SOURCE" + "-D_GNU_SOURCE" + + # Ensure that we can serve >2GB files even on 32-bit systems. + "-D_LARGEFILE_SOURCE" + "-D_FILE_OFFSET_BITS=64" + + # unpackaged dependency: https://man.netbsd.org/blocklist.3 + "-DNO_BLOCKLIST_SUPPORT" ] ++ optional (!userSupport) "-DNO_USER_SUPPORT" ++ optional (!dirIndexSupport) "-DNO_DIRINDEX_SUPPORT" From f4f05481e325aa8d5975f11f46340ca04ff729d6 Mon Sep 17 00:00:00 2001 From: embr Date: Wed, 26 May 2021 11:38:57 +0200 Subject: [PATCH 5/7] bozohttpd: add bozohttpd-minimal target --- pkgs/servers/http/bozohttpd/default.nix | 15 ++++++++------- pkgs/top-level/all-packages.nix | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pkgs/servers/http/bozohttpd/default.nix b/pkgs/servers/http/bozohttpd/default.nix index 6d403756bd2..32a21f84264 100644 --- a/pkgs/servers/http/bozohttpd/default.nix +++ b/pkgs/servers/http/bozohttpd/default.nix @@ -6,14 +6,15 @@ , inetutils , wget , openssl -, userSupport ? true -, cgiSupport ? true -, dirIndexSupport ? true -, dynamicContentSupport ? true -, sslSupport ? true -, luaSupport ? true +, minimal ? false +, userSupport ? !minimal +, cgiSupport ? !minimal +, dirIndexSupport ? !minimal +, dynamicContentSupport ? !minimal +, sslSupport ? !minimal +, luaSupport ? !minimal , lua -, htpasswdSupport ? true +, htpasswdSupport ? !minimal }: let inherit (lib) optional optionals; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f6444216f40..a86f41e44f2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1954,6 +1954,7 @@ in boxfs = callPackage ../tools/filesystems/boxfs { }; bozohttpd = callPackage ../servers/http/bozohttpd { }; + bozohttpd-minimal = callPackage ../servers/http/bozohttpd { minimal = true; }; bpytop = callPackage ../tools/system/bpytop { }; From ee4b583ae8b11a38065ed7aa3eef01389f44b30f Mon Sep 17 00:00:00 2001 From: embr Date: Mon, 31 May 2021 10:47:46 +0200 Subject: [PATCH 6/7] bozohttpd: minor formatting The Nix style guide isn't exactly comprehensive, but this at least seems slightly closer to the examples: https://nixos.org/manual/nixpkgs/stable/#sec-syntax I'm annoyed that nixpkgs-fmt as of writing won't accept: COPTS = [ # ... ] ++ optional (...) "..." ++ optional (...) "..."; ...which seems to be the actual convention, looking at eg. pkgs.nginx. --- pkgs/servers/http/bozohttpd/default.nix | 33 ++++++++++++------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/pkgs/servers/http/bozohttpd/default.nix b/pkgs/servers/http/bozohttpd/default.nix index 32a21f84264..9a3526d380e 100644 --- a/pkgs/servers/http/bozohttpd/default.nix +++ b/pkgs/servers/http/bozohttpd/default.nix @@ -45,25 +45,24 @@ stdenv.mkDerivation rec { buildInputs = [ openssl ] ++ optional (luaSupport) lua; nativeBuildInputs = [ bmake groff ]; - COPTS = - [ - "-D_DEFAULT_SOURCE" - "-D_GNU_SOURCE" + COPTS = [ + "-D_DEFAULT_SOURCE" + "-D_GNU_SOURCE" - # Ensure that we can serve >2GB files even on 32-bit systems. - "-D_LARGEFILE_SOURCE" - "-D_FILE_OFFSET_BITS=64" + # ensure that we can serve >2GB files even on 32-bit systems. + "-D_LARGEFILE_SOURCE" + "-D_FILE_OFFSET_BITS=64" - # unpackaged dependency: https://man.netbsd.org/blocklist.3 - "-DNO_BLOCKLIST_SUPPORT" - ] - ++ 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"; + # unpackaged dependency: https://man.netbsd.org/blocklist.3 + "-DNO_BLOCKLIST_SUPPORT" + ] + ++ 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" From a75c0a7f8702f62258300de15ce99216d0a12e92 Mon Sep 17 00:00:00 2001 From: embr Date: Mon, 31 May 2021 10:53:33 +0200 Subject: [PATCH 7/7] bozohttpd: experimental darwin compat patch As far as I can tell, libSystem on darwin provides a libm compatibility symlink, but not a libcrypt one. Prior art (eg. CPython) appears to use `stdenv.isDarwin` as a proxy for `stdenv.hostPlatform.libc == "libSystem"`, but the latter also works in cases where we're building on Darwin, but with eg. musl for some reason. --- pkgs/servers/http/bozohttpd/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/servers/http/bozohttpd/default.nix b/pkgs/servers/http/bozohttpd/default.nix index 9a3526d380e..c01be041e86 100644 --- a/pkgs/servers/http/bozohttpd/default.nix +++ b/pkgs/servers/http/bozohttpd/default.nix @@ -64,7 +64,8 @@ stdenv.mkDerivation rec { ++ optional (!cgiSupport) "-DNO_CGIBIN_SUPPORT" ++ optional (htpasswdSupport) "-DDO_HTPASSWD"; - _LDADD = [ "-lcrypt" "-lm" ] + _LDADD = [ "-lm" ] + ++ optional (stdenv.hostPlatform.libc != "libSystem") "-lcrypt" ++ optional (luaSupport) "-llua" ++ optionals (sslSupport) [ "-lssl" "-lcrypto" ]; makeFlags = [ "LDADD=$(_LDADD)" "prefix=$(out)" "MANDIR=$(out)/share/man" "BINOWN=" ];