Module Name: src Committed By: mrg Date: Thu Oct 15 04:21:53 UTC 2020
Modified Files: src/libexec/httpd: CHANGES bozohttpd.8 bozohttpd.c bozohttpd.h cgi-bozo.c content-bozo.c daemon-bozo.c main.c ssl-bozo.c Log Message: various updates from <hen...@gulbra.net> / freebsd. the list from Henrik: bozohttpd.8: o Added -d flag to the man page o Moved -E flag in man page to keep alphabetic order o Grammar fix for description of -E flag in man page o Moved a word in the man description for the -f flag o Made -f imply -b as a backwards-compatible shortcut o Updated man description of -n to mention Lua scripts o Moved -z below -Z to keep the uppercase options first bozohttpd.c: o Removed obsolete comment about ~user missing cgi-bin support o Removed "/* ARGSUSED */" lines; was that a macro or a reminder? o Added USE_ARG macro call for sig, which was otherwise not used o Added USE_ARG macro call for msg (only used if debug is enabled) bozohttpd.h: o Fixed typo in the include guard (BOZOHTTOPD_H_ -> BOZOHTTPD_H_) o Renamed have_all to have_core; it didn't mean "all" options content-bozo.c: o Added USE_ARG macro call for signo, which was otherwise not used o Made -f imply -b as a backwards-compatible shortcut main.c: o Simplified -b text to be symmetric with that for the -f option o Updated -C text to make "suffix" explicit; it's better than "arg" o Changed to only show the -E description if have_user is true o Always show the -e option, which incorrectly used the -E logic o Renamed have_all to have_core; it didn't mean "all" options o Added three missing tabs for the description of the -G option o Updated -L text to make "prefix" explicit; it's better than "arg" o Updated -M text to make "suffix" explicit; it's slightly better o Added a previously missing description for the -n option o Documented the otherwise obscure valid types for the -T option o Shortened "username" to "user" to match the actual help text o Moved handling of -c below that for -C to standardize the order o Broke the enabling test for -C into two lines for consistency o Inverted the enabling test for -E; this is what was meant, right? o Removed the enabling test for -e, which should always be enabled ssl-bozo.c: o Added USE_ARG for httpd, which is not used if SSL has been excluded To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/libexec/httpd/CHANGES cvs rdiff -u -r1.85 -r1.86 src/libexec/httpd/bozohttpd.8 cvs rdiff -u -r1.122 -r1.123 src/libexec/httpd/bozohttpd.c cvs rdiff -u -r1.64 -r1.65 src/libexec/httpd/bozohttpd.h cvs rdiff -u -r1.50 -r1.51 src/libexec/httpd/cgi-bozo.c cvs rdiff -u -r1.18 -r1.19 src/libexec/httpd/content-bozo.c cvs rdiff -u -r1.21 -r1.22 src/libexec/httpd/daemon-bozo.c cvs rdiff -u -r1.24 -r1.25 src/libexec/httpd/main.c cvs rdiff -u -r1.28 -r1.29 src/libexec/httpd/ssl-bozo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/libexec/httpd/CHANGES diff -u src/libexec/httpd/CHANGES:1.43 src/libexec/httpd/CHANGES:1.44 --- src/libexec/httpd/CHANGES:1.43 Thu Oct 15 02:19:23 2020 +++ src/libexec/httpd/CHANGES Thu Oct 15 04:21:53 2020 @@ -1,4 +1,4 @@ -$NetBSD: CHANGES,v 1.43 2020/10/15 02:19:23 mrg Exp $ +$NetBSD: CHANGES,v 1.44 2020/10/15 04:21:53 mrg Exp $ changes in bozohttpd 20201014: o also set -D_GNU_SOURCE in Makefile.boot. from @@ -6,6 +6,9 @@ changes in bozohttpd 20201014: o fix array size botch (assertion, not exploitable.) from mar...@netbsd.org. o also match %2F as well as %2f. from l...@vuxu.org. + o many manual and help fixes. clean ups for higher lint levels, + consistency/style clean ups. various option fixes including made + -f imply -b. from <hen...@gulbra.net> for freebsd. changes in bozohttpd 20200912: o add .m4a and .m4v file extensions. Index: src/libexec/httpd/bozohttpd.8 diff -u src/libexec/httpd/bozohttpd.8:1.85 src/libexec/httpd/bozohttpd.8:1.86 --- src/libexec/httpd/bozohttpd.8:1.85 Thu Oct 15 02:19:23 2020 +++ src/libexec/httpd/bozohttpd.8 Thu Oct 15 04:21:53 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: bozohttpd.8,v 1.85 2020/10/15 02:19:23 mrg Exp $ +.\" $NetBSD: bozohttpd.8,v 1.86 2020/10/15 04:21:53 mrg Exp $ .\" .\" $eterna: bozohttpd.8,v 1.101 2011/11/18 01:25:11 mrg Exp $ .\" @@ -34,14 +34,14 @@ .Nd hyper text transfer protocol version 1.1 daemon .Sh SYNOPSIS .Nm -.Op Fl EGHVXefhnsu +.Op Fl EGHVXdefhnsu .Op Fl C Ar suffix cgihandler .Op Fl I Ar port .Op Fl L Ar prefix script .Op Fl M Ar suffix type encoding encoding11 .Op Fl P Ar pidfile .Op Fl R Ar readme -.Op Fl S Ar server_software +.Op Fl S Ar version .Op Fl T Ar type timeout .Op Fl U Ar username .Op Fl Z Ar cert privkey @@ -120,6 +120,14 @@ Note that the CGI/1.1 interface is avail translation using .Fl E switch. +.It Fl d +Enables debug support. +.It Fl E +Enables CGI/1.1 interface for +.Em ~user +translation. +Note that enabling this support implies that users can run commands +as the web server user. This may have security implications. .It Fl e Causes .Nm @@ -131,9 +139,11 @@ options. .It Fl f Stops the .Fl b -flag from +flag from detaching .Nm -detaching from the tty and going into the background. +from the tty and going into the background. This implies the +.Fl b +flag. .It Fl G Get the .Nm @@ -212,12 +222,10 @@ options may be passed. .It Fl n Stops .Nm -from doing IP address to name resolution of hosts for setting the +from doing IP address to name resolution of remote hosts. +This affects the .Ev REMOTE_HOST -variable before running a CGI program. -This option has no effect without the -.Fl c -option. +environment variable for CGI programs and Lua scripts. .It Fl P Ar pidfile Causes .Nm @@ -237,9 +245,9 @@ to When directory indexing is enabled, include the contents of the file .Ar readme in the footer of the directory index. -.It Fl S Ar server_software +.It Fl S Ar version Sets the internal server version to -.Ar server_software . +.Ar version . .It Fl s Forces logging to be set to stderr always. .It Fl T Ar type timeout @@ -290,12 +298,6 @@ into the directory (but see the .Fl p option above). -.It Fl E -Enables CGI/1.1 interface for -.Em ~user -translation. -Note that enabling this support implies that users can run -commands as web server user, this may have security implications. .It Fl V Sets the backup virtual host directory to the .Ar slashdir @@ -330,15 +332,15 @@ Changes the default file read for direct .Dq index.html to .Ar index . -.It Fl z Ar ciphers -Sets the list of SSL ciphers (see -.Xr SSL_CTX_set_cipher_list 3 ) . .It Fl Z Ar certificate_path privatekey_path Sets the path to the server certificate file and the private key file in PEM format. It also causes .Nm to start SSL mode. +.It Fl z Ar ciphers +Sets the list of SSL ciphers (see +.Xr SSL_CTX_set_cipher_list 3 ) . .El .Pp Note that in Index: src/libexec/httpd/bozohttpd.c diff -u src/libexec/httpd/bozohttpd.c:1.122 src/libexec/httpd/bozohttpd.c:1.123 --- src/libexec/httpd/bozohttpd.c:1.122 Thu Oct 15 02:19:23 2020 +++ src/libexec/httpd/bozohttpd.c Thu Oct 15 04:21:53 2020 @@ -1,9 +1,9 @@ -/* $NetBSD: bozohttpd.c,v 1.122 2020/10/15 02:19:23 mrg Exp $ */ +/* $NetBSD: bozohttpd.c,v 1.123 2020/10/15 04:21:53 mrg Exp $ */ /* $eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $ */ /* - * Copyright (c) 1997-2019 Matthew R. Green + * Copyright (c) 1997-2020 Matthew R. Green * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -40,7 +40,6 @@ * - CGI/1.1 this will only be provided for "system" scripts * - automatic "missing trailing slash" redirections * - configurable translation of /~user/ to ~user/public_html, - * however, this does not include cgi-bin support * - access lists via libwrap via inetd/tcpd * - virtual hosting * - not that we do not even pretend to understand MIME, but @@ -373,6 +372,7 @@ bozo_clean_request(bozo_httpreq_t *reque static void alarmer(int sig) { + USE_ARG(sig); bozo_timeout_hit = 1; } @@ -2192,7 +2192,6 @@ pfilter_notify(const int what, const int #endif /* !NO_BLOCKLIST_SUPPORT */ /* the follow functions and variables are used in handling HTTP errors */ -/* ARGSUSED */ int bozo_http_error(bozohttpd_t *httpd, int code, bozo_httpreq_t *request, const char *msg) @@ -2205,6 +2204,8 @@ bozo_http_error(bozohttpd_t *httpd, int int size; bozoheaders_t *hdr; + USE_ARG(msg); + debug((httpd, DEBUG_FAT, "bozo_http_error %d: %s", code, msg)); if (header == NULL || reason == NULL) { bozoerr(httpd, 1, Index: src/libexec/httpd/bozohttpd.h diff -u src/libexec/httpd/bozohttpd.h:1.64 src/libexec/httpd/bozohttpd.h:1.65 --- src/libexec/httpd/bozohttpd.h:1.64 Thu Oct 15 02:19:23 2020 +++ src/libexec/httpd/bozohttpd.h Thu Oct 15 04:21:53 2020 @@ -1,9 +1,9 @@ -/* $NetBSD: bozohttpd.h,v 1.64 2020/10/15 02:19:23 mrg Exp $ */ +/* $NetBSD: bozohttpd.h,v 1.65 2020/10/15 04:21:53 mrg Exp $ */ /* $eterna: bozohttpd.h,v 1.39 2011/11/18 09:21:15 mrg Exp $ */ /* - * Copyright (c) 1997-2019 Matthew R. Green + * Copyright (c) 1997-2020 Matthew R. Green * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,8 +29,8 @@ * SUCH DAMAGE. * */ -#ifndef BOZOHTTOPD_H_ -#define BOZOHTTOPD_H_ 1 +#ifndef BOZOHTTPD_H_ +#define BOZOHTTPD_H_ 1 #include "netbsd_queue.h" @@ -307,7 +307,7 @@ char *bozostrdup(bozohttpd_t *, bozo_htt #define bozo_noop do { /* nothing */ } while (/*CONSTCOND*/0) -#define have_all (1) +#define have_core (1) /* ssl-bozo.c */ #ifdef NO_SSL_SUPPORT @@ -459,4 +459,4 @@ int bozo_get_version(char */*buf*/, size extern volatile sig_atomic_t bozo_timeout_hit; -#endif /* BOZOHTTOPD_H_ */ +#endif /* BOZOHTTPD_H_ */ Index: src/libexec/httpd/cgi-bozo.c diff -u src/libexec/httpd/cgi-bozo.c:1.50 src/libexec/httpd/cgi-bozo.c:1.51 --- src/libexec/httpd/cgi-bozo.c:1.50 Thu Aug 20 05:46:31 2020 +++ src/libexec/httpd/cgi-bozo.c Thu Oct 15 04:21:53 2020 @@ -1,9 +1,9 @@ -/* $NetBSD: cgi-bozo.c,v 1.50 2020/08/20 05:46:31 spz Exp $ */ +/* $NetBSD: cgi-bozo.c,v 1.51 2020/10/15 04:21:53 mrg Exp $ */ /* $eterna: cgi-bozo.c,v 1.40 2011/11/18 09:21:15 mrg Exp $ */ /* - * Copyright (c) 1997-2019 Matthew R. Green + * Copyright (c) 1997-2020 Matthew R. Green * All rights reserved. * * Redistribution and use in source and binary forms, with or without Index: src/libexec/httpd/content-bozo.c diff -u src/libexec/httpd/content-bozo.c:1.18 src/libexec/httpd/content-bozo.c:1.19 --- src/libexec/httpd/content-bozo.c:1.18 Sat Sep 12 14:44:25 2020 +++ src/libexec/httpd/content-bozo.c Thu Oct 15 04:21:53 2020 @@ -1,9 +1,9 @@ -/* $NetBSD: content-bozo.c,v 1.18 2020/09/12 14:44:25 rhialto Exp $ */ +/* $NetBSD: content-bozo.c,v 1.19 2020/10/15 04:21:53 mrg Exp $ */ /* $eterna: content-bozo.c,v 1.17 2011/11/18 09:21:15 mrg Exp $ */ /* - * Copyright (c) 1997-2018 Matthew R. Green + * Copyright (c) 1997-2020 Matthew R. Green * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -213,7 +213,6 @@ bozo_match_content_map(bozohttpd_t *http /* * given the file name, return a valid Content-Type: value. */ -/* ARGSUSED */ const char * bozo_content_type(bozo_httpreq_t *request, const char *file) { Index: src/libexec/httpd/daemon-bozo.c diff -u src/libexec/httpd/daemon-bozo.c:1.21 src/libexec/httpd/daemon-bozo.c:1.22 --- src/libexec/httpd/daemon-bozo.c:1.21 Thu Jan 17 07:46:16 2019 +++ src/libexec/httpd/daemon-bozo.c Thu Oct 15 04:21:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: daemon-bozo.c,v 1.21 2019/01/17 07:46:16 mrg Exp $ */ +/* $NetBSD: daemon-bozo.c,v 1.22 2020/10/15 04:21:53 mrg Exp $ */ /* $eterna: daemon-bozo.c,v 1.24 2011/11/18 09:21:15 mrg Exp $ */ @@ -62,26 +62,27 @@ static void sigchild(int); /* SIGCHLD ha #ifndef INFTIM #define INFTIM -1 #endif +#ifndef USE_ARG +#define USE_ARG(x) /*LINTED*/(void)&(x) +#endif static const char* pidfile_path = NULL; static pid_t pidfile_pid = 0; -/* ARGSUSED */ static void sigchild(int signo) { - + USE_ARG(signo); while (waitpid(-1, NULL, WNOHANG) > 0) /* nothing */; } /* Signal handler to exit in a controlled manner. This ensures that * any atexit(3) handlers are properly executed. */ -/* ARGSUSED */ BOZO_DEAD static void controlled_exit(int signo) { - + USE_ARG(signo); exit(EXIT_SUCCESS); } @@ -128,9 +129,12 @@ bozo_daemon_init(bozohttpd_t *httpd) const char *portnum; int e, i, on = 1; - if (!httpd->background) + if (!httpd->background && !httpd->foreground) return; + if (!httpd->background) + httpd->background = 1; + portnum = (httpd->bindport) ? httpd->bindport : "http"; memset(&h, 0, sizeof(h)); Index: src/libexec/httpd/main.c diff -u src/libexec/httpd/main.c:1.24 src/libexec/httpd/main.c:1.25 --- src/libexec/httpd/main.c:1.24 Thu Oct 15 02:19:23 2020 +++ src/libexec/httpd/main.c Thu Oct 15 04:21:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.24 2020/10/15 02:19:23 mrg Exp $ */ +/* $NetBSD: main.c,v 1.25 2020/10/15 04:21:53 mrg Exp $ */ /* $eterna: main.c,v 1.6 2011/11/18 09:21:15 mrg Exp $ */ /* from: eterna: bozohttpd.c,v 1.159 2009/05/23 02:14:30 mrg Exp */ @@ -63,53 +63,58 @@ usage(bozohttpd_t *httpd, char *progname bozowarn(httpd, "options:"); if (have_daemon_mode) - bozowarn(httpd, " -b\t\t\tbackground and go into daemon mode"); + bozowarn(httpd, " -b\t\t\tbackground in daemon mode"); if (have_cgibin && have_dynamic_content) - bozowarn(httpd, " -C arg prog\t\tadd this CGI handler"); + bozowarn(httpd, " -C suffix handler\tadd this CGI handler " + "for paths ending with `suffix'"); if (have_cgibin) bozowarn(httpd, " -c cgibin\t\tenable cgi-bin support in " "this directory"); if (have_debug) bozowarn(httpd, " -d\t\t\tenable debug support"); - if (have_cgibin) - bozowarn(httpd, " -E\t\t\tenable CGI support for user dirs"); if (have_user && have_cgibin) + bozowarn(httpd, " -E\t\t\tenable CGI support for user dirs"); + if (have_core) bozowarn(httpd, " -e\t\t\tdon't clean the environment " "(-t and -U only)"); if (have_daemon_mode) bozowarn(httpd, " -f\t\t\tforeground in daemon mode"); - if (have_all) - bozowarn(httpd, " -G print version number and exit"); + if (have_core) + bozowarn(httpd, " -G\t\t\tprint version number and exit"); if (have_dirindex) bozowarn(httpd, " -H\t\t\thide files starting with a period " "(.) in index mode"); - if (have_all) + if (have_core) bozowarn(httpd, " -I port\t\tbind or use on this port"); if (have_daemon_mode) bozowarn(httpd, " -i address\t\tbind on this address " "(daemon mode only)"); if (have_lua) - bozowarn(httpd, " -L arg script\tadd this Lua script"); + bozowarn(httpd, " -L prefix script\tadd this Lua script for " + "paths starting with `prefix'"); if (have_dynamic_content) - bozowarn(httpd, " -M arg t c c11\tadd this mime extenstion"); + bozowarn(httpd, " -M suffix t c c11\tadd this mime entry"); + if (have_core) + bozowarn(httpd, " -n\t\t\tdon't resolve host names"); if (have_daemon_mode) bozowarn(httpd, " -P pidfile\t\tpid file path"); if (have_user) bozowarn(httpd, " -p dir\t\t\"public_html\" directory name"); - if (have_all) { + if (have_core) { bozowarn(httpd, " -S version\t\tset server version string"); bozowarn(httpd, " -s\t\t\talways log to stderr"); - bozowarn(httpd, " -T type timeout\tset `type' timeout"); + bozowarn(httpd, " -T type timeout\t" + "set <ssl|initial|header|request> timeout"); bozowarn(httpd, " -t dir\t\tchroot to `dir'"); - bozowarn(httpd, " -U username\t\tchange user to `user'"); + bozowarn(httpd, " -U user\t\tchange user to `user'"); } if (have_user) bozowarn(httpd, " -u\t\t\tenable ~user/public_html support"); - if (have_all) { + if (have_core) { bozowarn(httpd, " -V\t\t\tUnknown virtual hosts go to " "`slashdir'"); bozowarn(httpd, " -v virtualroot\tenable virtual host " @@ -118,7 +123,7 @@ usage(bozohttpd_t *httpd, char *progname if (have_dirindex) bozowarn(httpd, " -X\t\t\tdirectory index support"); - if (have_all) + if (have_core) bozowarn(httpd, " -x index\t\tdefault \"index.html\" " "file name"); @@ -178,15 +183,9 @@ main(int argc, char **argv) bozo_set_pref(&httpd, &prefs, "background", val); break; - case 'c': - if (!have_cgibin) - bozoerr(&httpd, 1, "CGI not enabled"); - - bozo_cgi_setbin(&httpd, optarg); - break; - case 'C': - if (!have_dynamic_content && !have_cgibin) + if (!have_dynamic_content || + !have_cgibin) bozoerr(&httpd, 1, "dynamic CGI handler support not enabled"); @@ -197,6 +196,13 @@ main(int argc, char **argv) argv[optind++]); break; + case 'c': + if (!have_cgibin) + bozoerr(&httpd, 1, "CGI not enabled"); + + bozo_cgi_setbin(&httpd, optarg); + break; + case 'd': if (!have_debug) bozowarn(&httpd, "Debugging not enabled"); @@ -204,8 +210,8 @@ main(int argc, char **argv) break; case 'E': - if (have_user && - have_cgibin) + if (!have_user || + !have_cgibin) bozoerr(&httpd, 1, "CGI not enabled"); bozo_set_pref(&httpd, &prefs, "enable user cgibin", @@ -213,9 +219,6 @@ main(int argc, char **argv) break; case 'e': - if (!have_daemon_mode) - goto no_daemon_mode; - bozo_set_pref(&httpd, &prefs, "dirty environment", "true"); break; Index: src/libexec/httpd/ssl-bozo.c diff -u src/libexec/httpd/ssl-bozo.c:1.28 src/libexec/httpd/ssl-bozo.c:1.29 --- src/libexec/httpd/ssl-bozo.c:1.28 Thu Oct 15 02:19:23 2020 +++ src/libexec/httpd/ssl-bozo.c Thu Oct 15 04:21:53 2020 @@ -1,9 +1,9 @@ -/* $NetBSD: ssl-bozo.c,v 1.28 2020/10/15 02:19:23 mrg Exp $ */ +/* $NetBSD: ssl-bozo.c,v 1.29 2020/10/15 04:21:53 mrg Exp $ */ /* $eterna: ssl-bozo.c,v 1.15 2011/11/18 09:21:15 mrg Exp $ */ /* - * Copyright (c) 1997-2019 Matthew R. Green + * Copyright (c) 1997-2020 Matthew R. Green * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -40,15 +40,15 @@ #include "bozohttpd.h" +#ifndef USE_ARG +#define USE_ARG(x) /*LINTED*/(void)&(x) +#endif + #ifndef NO_SSL_SUPPORT #include <openssl/ssl.h> #include <openssl/err.h> -#ifndef USE_ARG -#define USE_ARG(x) /*LINTED*/(void)&(x) -#endif - #ifndef BOZO_SSL_CIPHERS #define BOZO_SSL_CIPHERS \ "AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:" \ @@ -352,6 +352,8 @@ bozo_printf(bozohttpd_t *httpd, const ch va_list args; int cc; + USE_ARG(httpd); + va_start(args, fmt); #ifndef NO_SSL_SUPPORT if (httpd->sslinfo) @@ -370,6 +372,7 @@ bozo_read(bozohttpd_t *httpd, int fd, vo if (httpd->sslinfo) return bozo_ssl_read(httpd, fd, buf, len); #endif + USE_ARG(httpd); return read(fd, buf, len); } @@ -380,6 +383,7 @@ bozo_write(bozohttpd_t *httpd, int fd, c if (httpd->sslinfo) return bozo_ssl_write(httpd, fd, buf, len); #endif + USE_ARG(httpd); return write(fd, buf, len); } @@ -390,5 +394,6 @@ bozo_flush(bozohttpd_t *httpd, FILE *fp) if (httpd->sslinfo) return 0; #endif + USE_ARG(httpd); return fflush(fp); }