Module Name: src Committed By: snj Date: Fri Dec 23 07:42:09 UTC 2016
Modified Files: src/libexec/httpd [netbsd-7]: CHANGES bozohttpd.8 bozohttpd.c bozohttpd.h cgi-bozo.c content-bozo.c main.c src/libexec/httpd/testsuite [netbsd-7]: Makefile test-bigfile Added Files: src/libexec/httpd/testsuite [netbsd-7]: test-simple Log Message: Pull up following revision(s) (requested by mrg in ticket #1309): libexec/httpd/CHANGES: revisions 1.23, 1.24 libexec/httpd/bozohttpd.8: revisions 1.60-1.62 libexec/httpd/bozohttpd.c: revisions 1.81-1.84 libexec/httpd/bozohttpd.h: revision 1.46 libexec/httpd/cgi-bozo.c: revision 1.35 libexec/httpd/content-bozo.c: revision 1.14 libexec/httpd/main.c: revisions 1.14-1.16 libexec/httpd/testsuite/Makefile: revision 1.6 libexec/httpd/testsuite/test-bigfile: revision 1.3 libexec/httpd/testsuite/test-simple: revisions 1.1, 1.2 update bozohttpd to 2016072: - fix memory leak - addd -G option to display version - fix some content type issues - fix issues in testsuite To generate a diff of this commit: cvs rdiff -u -r1.19.2.3 -r1.19.2.4 src/libexec/httpd/CHANGES cvs rdiff -u -r1.46.4.6 -r1.46.4.7 src/libexec/httpd/bozohttpd.8 cvs rdiff -u -r1.56.2.6 -r1.56.2.7 src/libexec/httpd/bozohttpd.c cvs rdiff -u -r1.33.2.4 -r1.33.2.5 src/libexec/httpd/bozohttpd.h cvs rdiff -u -r1.25.2.5 -r1.25.2.6 src/libexec/httpd/cgi-bozo.c cvs rdiff -u -r1.10.2.3 -r1.10.2.4 src/libexec/httpd/content-bozo.c cvs rdiff -u -r1.8.2.1 -r1.8.2.2 src/libexec/httpd/main.c cvs rdiff -u -r1.4.24.1 -r1.4.24.2 src/libexec/httpd/testsuite/Makefile cvs rdiff -u -r1.1.1.1.30.1 -r1.1.1.1.30.2 \ src/libexec/httpd/testsuite/test-bigfile cvs rdiff -u -r0 -r1.2.4.2 src/libexec/httpd/testsuite/test-simple 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.19.2.3 src/libexec/httpd/CHANGES:1.19.2.4 --- src/libexec/httpd/CHANGES:1.19.2.3 Fri Apr 15 19:01:05 2016 +++ src/libexec/httpd/CHANGES Fri Dec 23 07:42:09 2016 @@ -1,4 +1,7 @@ -$eterna: CHANGES,v 1.78 2011/11/18 01:25:11 mrg Exp $ +$NetBSD: CHANGES,v 1.19.2.4 2016/12/23 07:42:09 snj Exp $ + +changes in bozohttpd 20160517: + o add a bozo_get_version() function which returns the version number changes in bozohttpd 20160415: o add search-word support for CGI Index: src/libexec/httpd/bozohttpd.8 diff -u src/libexec/httpd/bozohttpd.8:1.46.4.6 src/libexec/httpd/bozohttpd.8:1.46.4.7 --- src/libexec/httpd/bozohttpd.8:1.46.4.6 Fri Apr 15 19:01:05 2016 +++ src/libexec/httpd/bozohttpd.8 Fri Dec 23 07:42:09 2016 @@ -1,8 +1,8 @@ -.\" $NetBSD: bozohttpd.8,v 1.46.4.6 2016/04/15 19:01:05 snj Exp $ +.\" $NetBSD: bozohttpd.8,v 1.46.4.7 2016/12/23 07:42:09 snj Exp $ .\" .\" $eterna: bozohttpd.8,v 1.101 2011/11/18 01:25:11 mrg Exp $ .\" -.\" Copyright (c) 1997-2015 Matthew R. Green +.\" Copyright (c) 1997-2016 Matthew R. Green .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -26,7 +26,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd December 12, 2015 +.Dd December 11, 2016 .Dt BOZOHTTPD 8 .Os .Sh NAME @@ -34,7 +34,7 @@ .Nd hyper text transfer protocol version 1.1 daemon .Sh SYNOPSIS .Nm -.Op Fl EHVXefhnsu +.Op Fl EGHVXefhnsu .Op Fl C Ar suffix cgihandler .Op Fl I Ar port .Op Fl L Ar prefix script @@ -132,6 +132,10 @@ Stops the flag from .Nm detaching from the tty and going into the background. +.It Fl G +Get the +.Nm +version string, print it on standard output, and exit. .It Fl H Causes directory index mode to hide files and directories that start with a period, except for @@ -272,8 +276,9 @@ 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 default virtual host directory to -.Ar slashdir . +Sets the backup virtual host directory to the +.Ar slashdir +argument. If no directory exists in .Ar virtualroot for the request, then @@ -526,7 +531,7 @@ The focus has always been simplicity and and regular code audits. This manual documents .Nm -version 20150501. +version 20160720. .Sh AUTHORS .An -nosplit .Nm Index: src/libexec/httpd/bozohttpd.c diff -u src/libexec/httpd/bozohttpd.c:1.56.2.6 src/libexec/httpd/bozohttpd.c:1.56.2.7 --- src/libexec/httpd/bozohttpd.c:1.56.2.6 Fri Apr 15 19:01:05 2016 +++ src/libexec/httpd/bozohttpd.c Fri Dec 23 07:42:09 2016 @@ -1,9 +1,9 @@ -/* $NetBSD: bozohttpd.c,v 1.56.2.6 2016/04/15 19:01:05 snj Exp $ */ +/* $NetBSD: bozohttpd.c,v 1.56.2.7 2016/12/23 07:42:09 snj Exp $ */ /* $eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $ */ /* - * Copyright (c) 1997-2015 Matthew R. Green + * Copyright (c) 1997-2016 Matthew R. Green * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -109,7 +109,7 @@ #define INDEX_HTML "index.html" #endif #ifndef SERVER_SOFTWARE -#define SERVER_SOFTWARE "bozohttpd/20160415" +#define SERVER_SOFTWARE "bozohttpd/20160720" #endif #ifndef DIRECT_ACCESS_FILE #define DIRECT_ACCESS_FILE ".bzdirect" @@ -2244,6 +2244,7 @@ bozo_setup(bozohttpd_t *httpd, bozoprefs extern char **environ; static char *cleanenv[1] = { NULL }; uid_t uid; + int uidset = 0; char *chrootdir; char *username; char *portnum; @@ -2339,6 +2340,7 @@ bozo_setup(bozohttpd_t *httpd, bozoprefs bozoerr(httpd, 1, "setgid(%u): %s", pw->pw_gid, strerror(errno)); uid = pw->pw_uid; + uidset = 1; } /* * handle chroot. @@ -2353,7 +2355,7 @@ bozo_setup(bozohttpd_t *httpd, bozoprefs strerror(errno)); } - if (username != NULL && setuid(uid) == -1) + if (uidset && setuid(uid) == -1) bozoerr(httpd, 1, "setuid(%d): %s", uid, strerror(errno)); /* @@ -2375,3 +2377,9 @@ bozo_setup(bozohttpd_t *httpd, bozoprefs return 1; } + +int +bozo_get_version(char *buf, size_t size) +{ + return snprintf(buf, size, "%s", SERVER_SOFTWARE); +} Index: src/libexec/httpd/bozohttpd.h diff -u src/libexec/httpd/bozohttpd.h:1.33.2.4 src/libexec/httpd/bozohttpd.h:1.33.2.5 --- src/libexec/httpd/bozohttpd.h:1.33.2.4 Fri Apr 15 19:01:05 2016 +++ src/libexec/httpd/bozohttpd.h Fri Dec 23 07:42:09 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: bozohttpd.h,v 1.33.2.4 2016/04/15 19:01:05 snj Exp $ */ +/* $NetBSD: bozohttpd.h,v 1.33.2.5 2016/12/23 07:42:09 snj Exp $ */ /* $eterna: bozohttpd.h,v 1.39 2011/11/18 09:21:15 mrg Exp $ */ @@ -367,4 +367,6 @@ bozoheaders_t *addmerge_replheader(bozo_ int bozo_set_pref(bozohttpd_t *, bozoprefs_t *, const char *, const char *); char *bozo_get_pref(bozoprefs_t *, const char *); +int bozo_get_version(char */*buf*/, size_t /*size*/); + #endif /* BOZOHTTOPD_H_ */ Index: src/libexec/httpd/cgi-bozo.c diff -u src/libexec/httpd/cgi-bozo.c:1.25.2.5 src/libexec/httpd/cgi-bozo.c:1.25.2.6 --- src/libexec/httpd/cgi-bozo.c:1.25.2.5 Fri Apr 15 20:24:30 2016 +++ src/libexec/httpd/cgi-bozo.c Fri Dec 23 07:42:09 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgi-bozo.c,v 1.25.2.5 2016/04/15 20:24:30 mrg Exp $ */ +/* $NetBSD: cgi-bozo.c,v 1.25.2.6 2016/12/23 07:42:09 snj Exp $ */ /* $eterna: cgi-bozo.c,v 1.40 2011/11/18 09:21:15 mrg Exp $ */ @@ -333,12 +333,12 @@ parse_search_string(bozo_httpreq_t *requ parse_err: - free (*args); free (str); - *args = NULL; + free (*args); + free(args); *args_len = 0; - return 0; + return NULL; } Index: src/libexec/httpd/content-bozo.c diff -u src/libexec/httpd/content-bozo.c:1.10.2.3 src/libexec/httpd/content-bozo.c:1.10.2.4 --- src/libexec/httpd/content-bozo.c:1.10.2.3 Sun Apr 10 10:33:11 2016 +++ src/libexec/httpd/content-bozo.c Fri Dec 23 07:42:09 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: content-bozo.c,v 1.10.2.3 2016/04/10 10:33:11 martin Exp $ */ +/* $NetBSD: content-bozo.c,v 1.10.2.4 2016/12/23 07:42:09 snj Exp $ */ /* $eterna: content-bozo.c,v 1.17 2011/11/18 09:21:15 mrg Exp $ */ @@ -62,16 +62,16 @@ static bozo_content_map_t static_content { ".pac", "application/x-ns-proxy-autoconfig", "", "", NULL }, { ".pa", "application/x-ns-proxy-autoconfig", "", "", NULL }, { ".tar", "multipart/x-tar", "", "", NULL }, - { ".gtar", "multipart/x-gtar", "", "", NULL }, - { ".tar.Z", "multipart/x-tar", "x-compress", "compress", NULL }, - { ".tar.gz", "multipart/x-tar", "x-gzip", "gzip", NULL }, - { ".taz", "multipart/x-tar", "x-gzip", "gzip", NULL }, - { ".tgz", "multipart/x-tar", "x-gzip", "gzip", NULL }, - { ".tar.z", "multipart/x-tar", "x-pack", "x-pack", NULL }, - { ".Z", "application/x-compress", "x-compress", "compress", NULL }, - { ".gz", "application/x-gzip", "x-gzip", "gzip", NULL }, - { ".z", "unknown", "x-pack", "x-pack", NULL }, - { ".bz2", "application/x-bzip2", "x-bzip2", "x-bzip2", NULL }, + { ".gtar", "application/x-gtar-compressed", "", "", NULL }, + { ".tar.Z", "application/x-gtar-compressed", "", "", NULL }, + { ".tar.gz", "application/x-gtar-compressed", "", "", NULL }, + { ".taz", "application/x-gtar-compressed", "", "", NULL }, + { ".tgz", "application/x-gtar-compressed", "", "", NULL }, + { ".tar.z", "application/x-gtar-compressed", "", "", NULL }, + { ".Z", "application/x-compress", "", "", NULL }, + { ".gz", "application/x-gzip", "", "", NULL }, + { ".z", "unknown", "", "", NULL }, + { ".bz2", "application/x-bzip2", "", "", NULL }, { ".ogg", "application/x-ogg", "", "", NULL }, { ".mkv", "video/x-matroska", "", "", NULL }, { ".xbel", "text/xml", "", "", NULL }, Index: src/libexec/httpd/main.c diff -u src/libexec/httpd/main.c:1.8.2.1 src/libexec/httpd/main.c:1.8.2.2 --- src/libexec/httpd/main.c:1.8.2.1 Sun Apr 10 10:33:11 2016 +++ src/libexec/httpd/main.c Fri Dec 23 07:42:09 2016 @@ -1,10 +1,10 @@ -/* $NetBSD: main.c,v 1.8.2.1 2016/04/10 10:33:11 martin Exp $ */ +/* $NetBSD: main.c,v 1.8.2.2 2016/12/23 07:42:09 snj 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 */ /* - * Copyright (c) 1997-2014 Matthew R. Green + * Copyright (c) 1997-2016 Matthew R. Green * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -101,6 +101,7 @@ usage(bozohttpd_t *httpd, char *progname bozowarn(httpd, " -v virtualroot\tenable virtual host support " "in this directory"); + bozowarn(httpd, " -V\t\tUnknown virtual hosts go to `slashdir'"); #ifndef NO_DIRINDEX_SUPPORT bozowarn(httpd, " -X\t\t\tenable automatic directory index support"); @@ -118,6 +119,7 @@ usage(bozohttpd_t *httpd, char *progname " and private key file\n" "\t\t\tin pem format and enable bozohttpd in SSL mode"); #endif /* NO_SSL_SUPPORT */ + bozowarn(httpd, " -G print version number and exit"); bozoerr(httpd, 1, "%s failed to start", progname); } @@ -148,7 +150,7 @@ main(int argc, char **argv) */ while ((c = getopt(argc, argv, - "C:EHI:L:M:P:S:U:VXZ:bc:defhi:np:st:uv:x:z:")) != -1) { + "C:EGHI:L:M:P:S:U:VXZ:bc:defhi:np:st:uv:x:z:")) != -1) { switch (c) { case 'L': @@ -351,6 +353,15 @@ main(int argc, char **argv) #endif /* NO_DIRINDEX_SUPPORT */ + case 'G': + { + char version[128]; + + bozo_get_version(version, sizeof(version)); + printf("bozohttpd version %s\n", version); + } + return 0; + default: usage(&httpd, progname); /* NOTREACHED */ Index: src/libexec/httpd/testsuite/Makefile diff -u src/libexec/httpd/testsuite/Makefile:1.4.24.1 src/libexec/httpd/testsuite/Makefile:1.4.24.2 --- src/libexec/httpd/testsuite/Makefile:1.4.24.1 Sun Apr 10 10:33:11 2016 +++ src/libexec/httpd/testsuite/Makefile Fri Dec 23 07:42:09 2016 @@ -7,26 +7,31 @@ BOZOHTTPD?= ../bozohttpd BOZOHTTPD?= ../debug/bozohttpd-debug WGET?= wget DATA?= $(.CURDIR)/data +VERBOSE?= yes + +.if ${VERBOSE} != "yes" +SILENT= @ +.else +SILENT= +.endif + all: clean: - for a in $(SIMPLETESTS); do \ - rm -f tmp.$$a.out; \ + for a in $(SIMPLETESTS) $(BIGFILETESTS); do \ + rm -f tmp.$$a.out tmp.$$a.err; \ done check: check-simple check-bigfile check-simple: .for a in $(SIMPLETESTS) - echo "Running test $a" - $(BOZOHTTPD) "$(DATA)" < $(.CURDIR)/$a.in > tmp.$a.out || true - $(.CURDIR)/html_cmp $(.CURDIR)/$a.out tmp.$a.out + ${SILENT}$(.CURDIR)/test-simple "$a" "${BOZOHTTPD}" "${DATA}" "${VERBOSE}" .endfor check-bigfile: .for a in $(BIGFILETESTS) - echo "Running test $a" - $(.CURDIR)/test-bigfile "$a" "${BOZOHTTPD}" "${WGET}" "$(DATA)" + ${SILENT}$(.CURDIR)/test-bigfile "$a" "${BOZOHTTPD}" "${WGET}" "${DATA}" "${VERBOSE}" .endfor .include <bsd.obj.mk> Index: src/libexec/httpd/testsuite/test-bigfile diff -u src/libexec/httpd/testsuite/test-bigfile:1.1.1.1.30.1 src/libexec/httpd/testsuite/test-bigfile:1.1.1.1.30.2 --- src/libexec/httpd/testsuite/test-bigfile:1.1.1.1.30.1 Sun Apr 10 10:33:11 2016 +++ src/libexec/httpd/testsuite/test-bigfile Fri Dec 23 07:42:09 2016 @@ -1,9 +1,17 @@ #! /bin/sh +# $NetBSD: test-bigfile,v 1.1.1.1.30.2 2016/12/23 07:42:09 snj Exp $ test="$1" # partial4000 or partial8000 bozohttpd="$2" wget="$3" datadir="$4" +verbose="$5" + +if [ "yes" = "$verbose" ]; then + echo "Running test $test" +else + exec 2>tmp.$test.err +fi bozotestport=11111 @@ -23,5 +31,6 @@ if cmp ./bigfile ${datadir}/bigfile; the exit 0 else rm -f ./bigfile + [ "yes" = "$verbose" ] || echo "Failed test $test: `cat tmp.$test.err`" exit 1 fi Added files: Index: src/libexec/httpd/testsuite/test-simple diff -u /dev/null src/libexec/httpd/testsuite/test-simple:1.2.4.2 --- /dev/null Fri Dec 23 07:42:09 2016 +++ src/libexec/httpd/testsuite/test-simple Fri Dec 23 07:42:09 2016 @@ -0,0 +1,23 @@ +#! /bin/sh +# $NetBSD: test-simple,v 1.2.4.2 2016/12/23 07:42:09 snj Exp $ + +test="$1" +bozohttpd="$2" +datadir="$3" +verbose="$4" + +if [ "yes" = "$verbose" ]; then + echo "Running test $test" +else + exec 2>tmp.$test.err +fi + +bozotestport=11111 + +${bozohttpd} ${datadir} < $test.in > tmp.$test.out +if ./html_cmp $test.out tmp.$test.out; then + exit 0 +else + [ "yes" = "$verbose" ] || echo "Failed test $test: `cat tmp.$test.err; echo; cat $test.out`" + exit 1 +fi