The attached patch provides the following output when run with the -G option (for 'G'et version): % /usr/build/obj/x86_64/usr/src/libexec/httpd/bozohttpd -G bozohttpd version bozohttpd/20160415 % Does anyone have any objections to adding this? I want most pieces of network-facing software and/or high-value target clients to be able to self-identify. Thanks, Al Index: CHANGES =================================================================== RCS file: /cvsroot/src/libexec/httpd/CHANGES,v retrieving revision 1.22 diff -u -r1.22 CHANGES --- CHANGES 15 Apr 2016 17:57:21 -0000 1.22 +++ CHANGES 17 May 2016 16:29:16 -0000 @@ -1,5 +1,8 @@ $eterna: CHANGES,v 1.78 2011/11/18 01:25:11 mrg 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 o fix a security issue in CGI suffix handler support which would Index: bozohttpd.8 =================================================================== RCS file: /cvsroot/src/libexec/httpd/bozohttpd.8,v retrieving revision 1.59 diff -u -r1.59 bozohttpd.8 --- bozohttpd.8 15 Apr 2016 17:57:21 -0000 1.59 +++ bozohttpd.8 17 May 2016 16:29:16 -0000 @@ -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 May 17, 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 @@ 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 Index: bozohttpd.c =================================================================== RCS file: /cvsroot/src/libexec/httpd/bozohttpd.c,v retrieving revision 1.80 diff -u -r1.80 bozohttpd.c --- bozohttpd.c 15 Apr 2016 17:57:21 -0000 1.80 +++ bozohttpd.c 17 May 2016 16:29:16 -0000 @@ -2375,3 +2375,9 @@ return 1; } + +int +bozo_get_version(char *buf, size_t size) +{ + return snprintf(buf, size, "%s", SERVER_SOFTWARE); +} Index: bozohttpd.h =================================================================== RCS file: /cvsroot/src/libexec/httpd/bozohttpd.h,v retrieving revision 1.45 diff -u -r1.45 bozohttpd.h --- bozohttpd.h 15 Apr 2016 17:57:21 -0000 1.45 +++ bozohttpd.h 17 May 2016 16:29:16 -0000 @@ -367,4 +367,6 @@ 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: main.c =================================================================== RCS file: /cvsroot/src/libexec/httpd/main.c,v retrieving revision 1.13 diff -u -r1.13 main.c --- main.c 28 Dec 2015 07:37:59 -0000 1.13 +++ main.c 17 May 2016 16:29:16 -0000 @@ -118,6 +118,7 @@ " 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 +149,7 @@ */ 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 +352,15 @@ #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 */