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 ++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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +\ 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..c01be041e86 --- /dev/null +++ b/pkgs/servers/http/bozohttpd/default.nix @@ -0,0 +1,95 @@ +{ lib +, stdenv +, fetchurl +, bmake +, groff +, inetutils +, wget +, openssl +, minimal ? false +, userSupport ? !minimal +, cgiSupport ? !minimal +, dirIndexSupport ? !minimal +, dynamicContentSupport ? !minimal +, sslSupport ? !minimal +, luaSupport ? !minimal +, lua +, htpasswdSupport ? !minimal +}: + +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 = [ + "-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" + ++ 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 = [ "-lm" ] + ++ optional (stdenv.hostPlatform.libc != "libSystem") "-lcrypt" + ++ optional (luaSupport) "-llua" + ++ optionals (sslSupport) [ "-lssl" "-lcrypto" ]; + makeFlags = [ "LDADD=$(_LDADD)" "prefix=$(out)" "MANDIR=$(out)/share/man" "BINOWN=" ]; + + doCheck = true; + checkInputs = [ inetutils wget ]; + checkFlags = optional (!cgiSupport) "CGITESTS="; + + 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 a247d7abafc..088b49e1038 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1973,6 +1973,9 @@ in boxfs = callPackage ../tools/filesystems/boxfs { }; + bozohttpd = callPackage ../servers/http/bozohttpd { }; + bozohttpd-minimal = callPackage ../servers/http/bozohttpd { minimal = true; }; + bpytop = callPackage ../tools/system/bpytop { }; brasero-original = lowPrio (callPackage ../tools/cd-dvd/brasero { });