Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

update to bozohttpd 20111118. nothing major is missing here but

the changes since the prior import were:

        o  add -P <pidfile> option, from jmmv@netbsd.org
        o  avoid crashes with http basic auth, from pooka@netbsd.org
        o  add support for REDIRECT_STATUS variable, from tls@netbsd.org
        o  support .mp4 files in the default map
        o  directory indexes with files with : are now displayed properly, from
           reed@netbsd.org
        o  allow -I option to be useful in non-inetd mode as well
  • Loading branch information...
commit 3d88b78cabafd45d9d6a135bd509bce95af14b30 1 parent 3238216
mrg authored
View
11 libexec/httpd/CHANGES
@@ -1,4 +1,13 @@
-$eterna: CHANGES,v 1.77 2010/09/20 22:26:28 mrg Exp $
+$eterna: CHANGES,v 1.78 2011/11/18 01:25:11 mrg Exp $
+
+changes since bozohttpd 20100920:
+ o add -P <pidfile> option, from jmmv@netbsd.org
+ o avoid crashes with http basic auth, from pooka@netbsd.org
+ o add support for REDIRECT_STATUS variable, from tls@netbsd.org
+ o support .mp4 files in the default map
+ o directory indexes with files with : are now displayed properly, from
+ reed@netbsd.org
+ o allow -I option to be useful in non-inetd mode as well
changes since bozohttpd 20100617:
o properly fully disable multi-file mode for now
View
4 libexec/httpd/auth-bozo.c
@@ -1,7 +1,7 @@
-/* $eterna: auth-bozo.c,v 1.16 2010/05/10 14:36:37 mrg Exp $ */
+/* $eterna: auth-bozo.c,v 1.17 2011/11/18 09:21:15 mrg Exp $ */
/*
- * Copyright (c) 1997-2010 Matthew R. Green
+ * Copyright (c) 1997-2011 Matthew R. Green
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
View
75 libexec/httpd/bozohttpd.8
@@ -1,4 +1,4 @@
-.\" $eterna: bozohttpd.8,v 1.99 2010/09/20 22:26:28 mrg Exp $
+.\" $eterna: bozohttpd.8,v 1.101 2011/11/18 01:25:11 mrg Exp $
.\"
.\" Copyright (c) 1997-2010 Matthew R. Green
.\" All rights reserved.
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd September 20, 2010
+.Dd November 17, 2011
.Dt BOZOHTTPD 8
.Os BOZOS
.Sh NAME
@@ -36,6 +36,7 @@
.Op Fl C Ar suffix cgihandler
.Op Fl I Ar port
.Op Fl M Ar suffix type encoding encoding11
+.Op Fl P Ar pidfile
.Op Fl S Ar server_software
.Op Fl c Ar cgibin
.Op Fl i Ar address
@@ -76,12 +77,12 @@ hopefully increasing its security.
The following options are available:
.Bl -tag -width xxxcgibin
.It Fl b
-This option enables daemon mode, where
+Enables daemon mode, where
.Nm
detaches from the current terminal, running in the background and
servicing HTTP requests.
.It Fl C Ar suffix cgihandler
-This option adds a new CGI handler program for a particular file type.
+Adds a new CGI handler program for a particular file type.
The
.Ar suffix
should be any normal file suffix, and the
@@ -93,7 +94,7 @@ Multiple
.Fl C
options may be passed.
.It Fl c Ar cgibin
-This option enables the CGI/1.1 interface.
+Enables the CGI/1.1 interface.
The
.Ar cgibin
directory is expected to contain the CGI programs to be used.
@@ -111,7 +112,7 @@ Note that the CGI/1.1 interface is not available with
.Em ~user
translation.
.It Fl e
-This option causes
+Causes
.Nm
to not clear the environment when used with either the
.Fl t
@@ -119,32 +120,29 @@ or
.Fl U
options.
.It Fl f
-This option stops the
+Stops the
.Fl b
flag from
.Nm
detaching from the tty and going into the background.
.It Fl H
-This option causes directory index mode to hide files and directories
+Causes directory index mode to hide files and directories
that start with a period, except for
.Pa .. .
Also see
.Fl X .
.It Fl I Ar port
-This option is only valid with the
-.Fl b
-option.
-It causes
+Causes
.Ar port
to use used as the port to bind daemon mode.
The default is the
.Dq http
port.
-.It Fl i Ar address
This option is only valid with the
.Fl b
option.
-It causes
+.It Fl i Ar address
+Causes
.Ar address
to use used as the address to bind daemon mode.
If otherwise unspecified, the address used to bind is derived from the
@@ -154,8 +152,11 @@ which defaults to the name returned by
Only the last
.Fl i
option is used.
+This option is only valid with the
+.Fl b
+option.
.It Fl M Ar suffix type encoding encoding11
-This option adds a new entry to the table that converts file suffixes to
+Adds a new entry to the table that converts file suffixes to
content type and encoding.
This option takes four additional arguments containing
the file prefix, its
@@ -171,7 +172,7 @@ Multiple
.Fl M
options may be passed.
.It Fl n
-This option stops
+Stops
.Nm
from doing IP address to name resolution of hosts for setting the
.Ev REMOTE_HOST
@@ -179,15 +180,23 @@ variable before running a CGI program.
This option has no effect without the
.Fl c
option.
+.It Fl P Ar pidfile
+Causes
+.Nm
+to create a pid file in
+.Ar pidfile
+when run in daemon mode with the
+.Fl b
+option.
.It Fl p Ar pubdir
-This option changes the default user directory for
+Changes the default user directory for
.Em /~user/
translations from
.Dq public_html
to
.Ar pubdir .
.It Fl r
-This option forces pages besides the
+Forces pages besides the
.Dq index.html
(see the
.Fl X
@@ -196,14 +205,14 @@ refer to this web server, otherwise a redirect to the
.Dq index.html
page will be returned instead.
.It Fl S Ar server_software
-This option sets the internal server version to
+Sets the internal server version to
.Ar server_software .
.It Fl s
-This option forces logging to be set to stderr always.
+Forces logging to be set to stderr always.
.It Fl t Ar chrootdir
-When this option is used,
+Makes
.Nm
-will chroot to the specified directory
+chroot to the specified directory
before answering requests.
Every other path should be specified relative
to the new root, if this option is used.
@@ -212,7 +221,7 @@ is normally replaced with an empty environment with this option, unless the
.Fl e
option is also used.
.It Fl U Ar username
-This option causes
+Causes
.Nm
to switch to the user and the groups of
.Ar username
@@ -225,7 +234,7 @@ to clear the environment unless the
.Fl e
option is given.
.It Fl u
-This option enables the transformation of Uniform Resource Locators of
+Enables the transformation of Uniform Resource Locators of
the form
.Em /~user/
into the the directory
@@ -234,7 +243,7 @@ into the the directory
.Fl p
option above).
.It Fl V
-This option sets the default virtual host directory to
+Sets the default virtual host directory to
.Ar slashdir .
If no directory exists in
.Ar virtualroot
@@ -243,7 +252,7 @@ for the request, then
will be used.
The default behaviour is to return 404 (Not Found.)
.It Fl v Ar virtualroot
-This option enables virtual hosting support.
+Enables virtual hosting support.
Directories in
.Ar virtualroot
will be searched for a matching virtual host name, when parsing
@@ -257,17 +266,17 @@ See the
.Sx EXAMPLES
section for an example of using this option.
.It Fl X
-This option enables directory indexing.
+Enables directory indexing.
A directory index will be generated only when the default file (i.e.
.Pa index.html
normally) is not present.
.It Fl x Ar index
-This option changes the default file read for directories from
+Changes the default file read for directories from
.Dq index.html
to
.Ar index .
.It Fl Z Ar certificate_path privatekey_path
-This option sets the path to the server certificate file and the private key file
+Sets the path to the server certificate file and the private key file
in pem format.
It also causes
.Nm
@@ -438,7 +447,7 @@ To use
with PHP, one must use the
.Fl C
option to specify a CGI handler for a particular file type.
-Typically this, this will be like:
+Typically this will be like:
.Bd -literal
bozohttpd -C .php /usr/pkg/bin/php /var/www
.Ed
@@ -475,7 +484,7 @@ provided Range: header support
.It
Sean Boudreau
.Aq seanb@NetBSD.org
-provided an security fix for virtual hosting
+provided a security fix for virtual hosting
.It
Julian Coleman
.Aq jdc@coris.org.uk
@@ -577,6 +586,8 @@ provided http authorisation fixes
provided chroot and change-to-user support, and other various fixes
.It
Coyote Point provided various CGI fixes
+.It
+Julio Merino added pidfile support and provided some man page fixes
.El
.Pp
There are probably others I have forgotten (let me know if you care)
@@ -588,4 +599,4 @@ to
for inclusion in future releaases.
.Sh BUGS
.Nm
-does not handled HTTP/1.1 chunked input from the client yet.
+does not handle HTTP/1.1 chunked input from the client yet.
View
47 libexec/httpd/bozohttpd.c
@@ -1,7 +1,7 @@
-/* $eterna: bozohttpd.c,v 1.176 2010/09/20 22:26:28 mrg Exp $ */
+/* $eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $ */
/*
- * Copyright (c) 1997-2010 Matthew R. Green
+ * Copyright (c) 1997-2011 Matthew R. Green
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -107,7 +107,7 @@
#define INDEX_HTML "index.html"
#endif
#ifndef SERVER_SOFTWARE
-#define SERVER_SOFTWARE "bozohttpd/20100920"
+#define SERVER_SOFTWARE "bozohttpd/20111118"
#endif
#ifndef DIRECT_ACCESS_FILE
#define DIRECT_ACCESS_FILE ".bzdirect"
@@ -152,10 +152,6 @@
#include <time.h>
#include <unistd.h>
-#ifndef __attribute__
-#define __attribute__(x)
-#endif /* __attribute__ */
-
#include "bozohttpd.h"
#ifndef MAX_WAIT_TIME
@@ -565,14 +561,26 @@ bozo_read_request(bozohttpd_t *httpd)
if (addr != NULL)
request->hr_remoteaddr = bozostrdup(request->hr_httpd, addr);
slen = sizeof(ss);
- if (getsockname(0, (struct sockaddr *)(void *)&ss, &slen) < 0)
- port = NULL;
- else {
- if (getnameinfo((struct sockaddr *)(void *)&ss, slen, NULL, 0,
- bufport, sizeof bufport, NI_NUMERICSERV) == 0)
- port = bufport;
+
+ /*
+ * Override the bound port from the request value, so it works even
+ * if passed through a proxy that doesn't rewrite the port.
+ */
+ if (httpd->bindport) {
+ if (strcmp(httpd->bindport, "80") != 0)
+ port = httpd->bindport;
else
port = NULL;
+ } else {
+ if (getsockname(0, (struct sockaddr *)(void *)&ss, &slen) < 0)
+ port = NULL;
+ else {
+ if (getnameinfo((struct sockaddr *)(void *)&ss, slen, NULL, 0,
+ bufport, sizeof bufport, NI_NUMERICSERV) == 0)
+ port = bufport;
+ else
+ port = NULL;
+ }
}
if (port != NULL)
request->hr_serverport = bozostrdup(request->hr_httpd, port);
@@ -1410,9 +1418,10 @@ bozo_process_request(bozo_httpreq_t *request)
request->hr_first_byte_pos = 0;
request->hr_last_byte_pos = sb.st_size - 1;
}
- debug((httpd, DEBUG_FAT, "have_range %d first_pos %qd last_pos %qd",
+ debug((httpd, DEBUG_FAT, "have_range %d first_pos %lld last_pos %lld",
request->hr_have_range,
- request->hr_first_byte_pos, request->hr_last_byte_pos));
+ (long long)request->hr_first_byte_pos,
+ (long long)request->hr_last_byte_pos));
if (request->hr_have_range)
bozo_printf(httpd, "%s 206 Partial Content\r\n",
request->hr_proto);
@@ -1726,7 +1735,8 @@ bozo_http_error(bozohttpd_t *httpd, int code, bozo_httpreq_t *request,
size = 0;
bozo_printf(httpd, "%s %s\r\n", proto, header);
- bozo_auth_check_401(request, code);
+ if (request)
+ bozo_auth_check_401(request, code);
bozo_printf(httpd, "Content-Type: text/html\r\n");
bozo_printf(httpd, "Content-Length: %d\r\n", size);
@@ -1845,7 +1855,7 @@ bozodgetln(bozohttpd_t *httpd, int fd, ssize_t *lenp,
}
httpd->getln_buffer[len] = '\0';
- debug((httpd, DEBUG_OBESE, "bozodgetln returns: ``%s'' with len %d",
+ debug((httpd, DEBUG_OBESE, "bozodgetln returns: ``%s'' with len %zd",
httpd->getln_buffer, len));
*lenp = len;
return httpd->getln_buffer;
@@ -1994,6 +2004,9 @@ bozo_setup(bozohttpd_t *httpd, bozoprefs_t *prefs, const char *vhost,
strcmp(cp, "true") == 0) {
httpd->foreground = 1;
}
+ if ((cp = bozo_get_pref(prefs, "pid file")) != NULL) {
+ httpd->pidfile = strdup(cp);
+ }
if ((cp = bozo_get_pref(prefs, "unknown slash")) != NULL &&
strcmp(cp, "true") == 0) {
httpd->unknown_slash = 1;
View
34 libexec/httpd/bozohttpd.h
@@ -1,7 +1,7 @@
-/* $eterna: bozohttpd.h,v 1.37 2010/09/20 22:26:28 mrg Exp $ */
+/* $eterna: bozohttpd.h,v 1.39 2011/11/18 09:21:15 mrg Exp $ */
/*
- * Copyright (c) 1997-2010 Matthew R. Green
+ * Copyright (c) 1997-2011 Matthew R. Green
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -73,6 +73,7 @@ typedef struct bozohttpd_t {
int logstderr; /* log to stderr (even if not tty) */
int background; /* drop into daemon mode */
int foreground; /* keep daemon mode in foreground */
+ char *pidfile; /* path to the pid file, if any */
size_t page_size; /* page size */
char *slashdir; /* www slash directory */
char *bindport; /* bind port; default "http" */
@@ -168,11 +169,16 @@ void debug__(bozohttpd_t *, int, const char *, ...)
#define debug(x)
#endif /* NO_DEBUG */
+#if defined(__GNUC__) && __GNUC__ >= 3
+#define BOZO_PRINTFLIKE(x,y) __attribute__((__format__(__printf__, x,y)))
+#define BOZO_DEAD __attribute__((__noreturn__))
+#endif
+
void bozo_warn(bozohttpd_t *, const char *, ...)
- __attribute__((__format__(__printf__, 2, 3)));
+ BOZO_PRINTFLIKE(2, 3);
void bozo_err(bozohttpd_t *, int, const char *, ...)
- __attribute__((__format__(__printf__, 3, 4)))
- __attribute__((__noreturn__));
+ BOZO_PRINTFLIKE(3, 4)
+ BOZO_DEAD;
int bozo_http_error(bozohttpd_t *, int, bozo_httpreq_t *, const char *);
int bozo_check_special_files(bozo_httpreq_t *, const char *);
@@ -188,10 +194,10 @@ char *bozostrdup(bozohttpd_t *, const char *);
/* ssl-bozo.c */
#ifdef NO_SSL_SUPPORT
-#define bozo_ssl_set_opts(w, x, y) /* nothing */
-#define bozo_ssl_init(x) /* nothing */
-#define bozo_ssl_accept(x) /* nothing */
-#define bozo_ssl_destroy(x) /* nothing */
+#define bozo_ssl_set_opts(w, x, y) do { /* nothing */ } while (0)
+#define bozo_ssl_init(x) do { /* nothing */ } while (0)
+#define bozo_ssl_accept(x) do { /* nothing */ } while (0)
+#define bozo_ssl_destroy(x) do { /* nothing */ } while (0)
#else
void bozo_ssl_set_opts(bozohttpd_t *, const char *, const char *);
void bozo_ssl_init(bozohttpd_t *);
@@ -211,11 +217,11 @@ void bozo_auth_cgi_setenv(bozo_httpreq_t *, char ***);
int bozo_auth_cgi_count(bozo_httpreq_t *);
#else
#define bozo_auth_check(x, y) 0
-#define bozo_auth_cleanup(x) /* nothing */
+#define bozo_auth_cleanup(x) do { /* nothing */ } while (0)
#define bozo_auth_check_headers(y, z, a, b) 0
#define bozo_auth_check_special_files(x, y) 0
-#define bozo_auth_check_401(x, y) /* nothing */
-#define bozo_auth_cgi_setenv(x, y) /* nothing */
+#define bozo_auth_check_401(x, y) do { /* nothing */ } while (0)
+#define bozo_auth_cgi_setenv(x, y) do { /* nothing */ } while (0)
#define bozo_auth_cgi_count(x) 0
#endif /* DO_HTPASSWD */
@@ -233,9 +239,9 @@ void bozo_add_content_map_cgi(bozohttpd_t *, const char *, const char *);
/* daemon-bozo.c */
#ifdef NO_DAEMON_MODE
-#define bozo_daemon_init(x) /* nothing */
+#define bozo_daemon_init(x) do { /* nothing */ } while (0)
#define bozo_daemon_fork(x) 0
-#define bozo_daemon_closefds(x) /* nothing */
+#define bozo_daemon_closefds(x) do { /* nothing */ } while (0)
#else
void bozo_daemon_init(bozohttpd_t *);
int bozo_daemon_fork(bozohttpd_t *);
View
10 libexec/httpd/cgi-bozo.c
@@ -1,7 +1,7 @@
-/* $eterna: cgi-bozo.c,v 1.38 2010/09/20 22:25:00 mrg Exp $ */
+/* $eterna: cgi-bozo.c,v 1.40 2011/11/18 09:21:15 mrg Exp $ */
/*
- * Copyright (c) 1997-2010 Matthew R. Green
+ * Copyright (c) 1997-2011 Matthew R. Green
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -406,6 +406,12 @@ bozo_process_cgi(bozo_httpreq_t *request)
if (request->hr_remoteaddr && *request->hr_remoteaddr)
bozo_setenv(httpd, "REMOTE_ADDR", request->hr_remoteaddr,
curenvp++);
+ /*
+ * XXX Apache does this when invoking content handlers, and PHP
+ * XXX 5.3 requires it as a "security" measure.
+ */
+ if (cgihandler)
+ bozo_setenv(httpd, "REDIRECT_STATUS", "200", curenvp++);
bozo_auth_cgi_setenv(request, &curenvp);
free(file);
View
5 libexec/httpd/content-bozo.c
@@ -1,7 +1,7 @@
-/* $eterna: content-bozo.c,v 1.15 2010/05/10 02:51:28 mrg Exp $ */
+/* $eterna: content-bozo.c,v 1.17 2011/11/18 09:21:15 mrg Exp $ */
/*
- * Copyright (c) 1997-2010 Matthew R. Green
+ * Copyright (c) 1997-2011 Matthew R. Green
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -161,6 +161,7 @@ static bozo_content_map_t static_content_map[] = {
{ ".mpeg", 5, "video/mpeg", "", "", NULL },
{ ".mpg", 4, "video/mpeg", "", "", NULL },
{ ".mpe", 4, "video/mpeg", "", "", NULL },
+ { ".mp4", 4, "video/mp4", "", "", NULL },
{ ".qt", 3, "video/quicktime", "", "", NULL },
{ ".mov", 4, "video/quicktime", "", "", NULL },
{ ".avi", 4, "video/x-msvideo", "", "", NULL },
View
72 libexec/httpd/daemon-bozo.c
@@ -1,7 +1,7 @@
-/* $eterna: daemon-bozo.c,v 1.22 2010/06/21 06:45:45 mrg Exp $ */
+/* $eterna: daemon-bozo.c,v 1.24 2011/11/18 09:21:15 mrg Exp $ */
/*
- * Copyright (c) 1997-2010 Matthew R. Green
+ * Copyright (c) 1997-2011 Matthew R. Green
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,9 +38,11 @@
#include <netinet/in.h>
+#include <assert.h>
#include <errno.h>
#include <netdb.h>
#include <poll.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -59,6 +61,9 @@ static void sigchild(int); /* SIGCHLD handler */
#define INFTIM -1
#endif
+static const char* pidfile_path = NULL;
+static pid_t pidfile_pid = 0;
+
/* ARGSUSED */
static void
sigchild(int signo)
@@ -67,6 +72,52 @@ sigchild(int signo)
}
}
+/* 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)
+{
+
+ exit(EXIT_SUCCESS);
+}
+
+static void
+remove_pidfile(void)
+{
+
+ if (pidfile_path != NULL && pidfile_pid == getpid()) {
+ (void)unlink(pidfile_path);
+ pidfile_path = NULL;
+ }
+}
+
+static void
+create_pidfile(bozohttpd_t *httpd)
+{
+ FILE *file;
+
+ assert(pidfile_path == NULL);
+
+ if (httpd->pidfile == NULL)
+ return;
+
+ if (atexit(remove_pidfile) == -1)
+ bozo_err(httpd, 1, "Failed to install pidfile handler");
+
+ if ((file = fopen(httpd->pidfile, "w")) == NULL)
+ bozo_err(httpd, 1, "Failed to create pidfile '%s'",
+ httpd->pidfile);
+ (void)fprintf(file, "%d\n", getpid());
+ (void)fclose(file);
+
+ pidfile_path = httpd->pidfile;
+ pidfile_pid = getpid();
+
+ debug((httpd, DEBUG_FAT, "Created pid file '%s' for pid %d",
+ pidfile_path, pidfile_pid));
+}
+
void
bozo_daemon_init(bozohttpd_t *httpd)
{
@@ -77,12 +128,7 @@ bozo_daemon_init(bozohttpd_t *httpd)
if (!httpd->background)
return;
- if (httpd->foreground == 0)
- daemon(1, 0);
-
portnum = (httpd->bindport) ? httpd->bindport : "http";
- bozo_warn(httpd, "started in daemon mode as `%s' port `%s' root `%s'",
- httpd->virthostname, portnum, httpd->slashdir);
memset(&h, 0, sizeof(h));
h.ai_family = PF_UNSPEC;
@@ -119,6 +165,18 @@ bozo_daemon_init(bozohttpd_t *httpd)
httpd->nsock = i;
freeaddrinfo(r0);
+ if (httpd->foreground == 0)
+ daemon(1, 0);
+
+ create_pidfile(httpd);
+
+ bozo_warn(httpd, "started in daemon mode as `%s' port `%s' root `%s'",
+ httpd->virthostname, portnum, httpd->slashdir);
+
+ signal(SIGHUP, controlled_exit);
+ signal(SIGINT, controlled_exit);
+ signal(SIGTERM, controlled_exit);
+
signal(SIGCHLD, sigchild);
}
View
8 libexec/httpd/dir-index-bozo.c
@@ -1,7 +1,7 @@
-/* $eterna: dir-index-bozo.c,v 1.18 2010/09/20 22:26:29 mrg Exp $ */
+/* $eterna: dir-index-bozo.c,v 1.20 2011/11/18 09:21:15 mrg Exp $ */
/*
- * Copyright (c) 1997-2010 Matthew R. Green
+ * Copyright (c) 1997-2011 Matthew R. Green
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -143,6 +143,10 @@ bozo_dir_index(bozo_httpreq_t *request, const char *dirname, int isindex)
} else if (S_ISDIR(sb.st_mode)) {
bozo_printf(httpd, "<a href=\"%s/\">", name);
l += bozo_printf(httpd, "%s/", name);
+ } else if (strchr(name, ':') != NULL) {
+ /* RFC 3986 4.2 */
+ bozo_printf(httpd, "<a href=\"./%s\">", name);
+ l += bozo_printf(httpd, "%s", name);
} else {
bozo_printf(httpd, "<a href=\"%s\">", name);
l += bozo_printf(httpd, "%s", name);
View
27 libexec/httpd/main.c
@@ -1,10 +1,10 @@
-/* $NetBSD: main.c,v 1.1.1.2 2010/09/20 23:07:21 mrg Exp $ */
+/* $NetBSD: main.c,v 1.1.1.3 2011/11/18 09:40:36 mrg Exp $ */
-/* $eterna: main.c,v 1.4 2010/07/11 00:34:28 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 */
/*
- * Copyright (c) 1997-2010 Matthew R. Green
+ * Copyright (c) 1997-2011 Matthew R. Green
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -47,10 +47,6 @@
#include <time.h>
#include <unistd.h>
-#ifndef __attribute__
-#define __attribute__(x)
-#endif /* __attribute__ */
-
#include "bozohttpd.h"
/* variables and functions */
@@ -59,7 +55,7 @@
#endif
/* print a usage message, and then exit */
-static void
+BOZO_DEAD static void
usage(bozohttpd_t *httpd, char *progname)
{
bozo_warn(httpd, "usage: %s [options] slashdir [virtualhostname]",
@@ -83,12 +79,13 @@ usage(bozohttpd_t *httpd, char *progname)
bozo_warn(httpd,
" -c cgibin\t\tenable cgi-bin support in this directory");
#endif
+ bozo_warn(httpd, " -I port\t\tbind or use on this port");
#ifndef NO_DAEMON_MODE
bozo_warn(httpd, " -b\t\t\tbackground and go into daemon mode");
bozo_warn(httpd, " -f\t\t\tkeep daemon mode in the foreground");
bozo_warn(httpd,
" -i address\t\tbind on this address (daemon mode only)");
- bozo_warn(httpd, " -I port\t\tbind on this port (daemon mode only)");
+ bozo_warn(httpd, " -P pidfile\t\tpath to the pid file to create");
#endif
bozo_warn(httpd, " -S version\t\tset server version string");
bozo_warn(httpd, " -t dir\t\tchroot to `dir'");
@@ -141,7 +138,7 @@ main(int argc, char **argv)
bozo_set_defaults(&httpd, &prefs);
while ((c = getopt(argc, argv,
- "C:HI:M:S:U:VXZ:bc:defhi:np:rst:uv:x:z:")) != -1) {
+ "C:HI:M:P:S:U:VXZ:bc:defhi:np:rst:uv:x:z:")) != -1) {
switch(c) {
case 'M':
@@ -201,12 +198,16 @@ main(int argc, char **argv)
bozo_set_pref(&prefs, "index.html", optarg);
break;
+ case 'I':
+ bozo_set_pref(&prefs, "port number", optarg);
+ break;
+
#ifdef NO_DAEMON_MODE
case 'b':
case 'e':
case 'f':
case 'i':
- case 'I':
+ case 'P':
bozo_err(&httpd, 1, "Daemon mode is not enabled");
/* NOTREACHED */
#else
@@ -235,8 +236,8 @@ main(int argc, char **argv)
bozo_set_pref(&prefs, "bind address", optarg);
break;
- case 'I':
- bozo_set_pref(&prefs, "port number", optarg);
+ case 'P':
+ bozo_set_pref(&prefs, "pid file", optarg);
break;
#endif /* NO_DAEMON_MODE */
View
8 libexec/httpd/ssl-bozo.c
@@ -1,7 +1,7 @@
-/* $eterna: ssl-bozo.c,v 1.13 2010/05/12 12:24:58 rtr Exp $ */
+/* $eterna: ssl-bozo.c,v 1.15 2011/11/18 09:21:15 mrg Exp $ */
/*
- * Copyright (c) 1997-2010 Matthew R. Green
+ * Copyright (c) 1997-2011 Matthew R. Green
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -62,7 +62,7 @@ typedef struct sslinfo_t {
* the error provided by the caller at the point of error it pops and
* prints all errors from the SSL error queue.
*/
-static void
+BOZO_DEAD static void
bozo_ssl_err(bozohttpd_t *httpd, int code, const char *fmt, ...)
{
va_list ap;
@@ -77,7 +77,7 @@ bozo_ssl_err(bozohttpd_t *httpd, int code, const char *fmt, ...)
unsigned int sslcode = ERR_get_error();
do {
- const char *sslfmt = "SSL Error: %s:%s:%s";
+ static const char sslfmt[] = "SSL Error: %s:%s:%s";
if (httpd->logstderr || isatty(STDERR_FILENO)) {
fprintf(stderr, sslfmt,
View
10 libexec/httpd/testsuite/html_cmp
@@ -1,6 +1,6 @@
#! /bin/sh
#
-# $eterna: html_cmp,v 1.8 2003/02/06 09:40:39 mrg Exp $
+# $eterna: html_cmp,v 1.9 2011/11/17 22:18:02 mrg Exp $
#
# like cmp(1) but compares to files after making their `Date: ' headers
# the same, to allow `now' and `then' to work properly. it also tries
@@ -17,11 +17,11 @@ sedcmd="s/^Date: .*/Date: nowish/;
s/^Server: .*/^Server: bozotic HTTP server version 5.08/;
s/^Content-Length: .*/Content-Length: 223/;"
-sed -e "$sedcmd" < $1 > f1.tmp.$$
-sed -e "$sedcmd" < $2 > f2.tmp.$$
+sed -e "$sedcmd" < "$1" > "f1.tmp.$$"
+sed -e "$sedcmd" < "$2" > "f2.tmp.$$"
-cmp -s f1.tmp.$$ f2.tmp.$$
+cmp -s "f1.tmp.$$" "f2.tmp.$$"
rv=$?
-rm -f f1.tmp.$$ f2.tmp.$$
+rm -f "f1.tmp.$$" "f2.tmp.$$"
exit $rv
View
4 libexec/httpd/tilde-luzah-bozo.c
@@ -1,7 +1,7 @@
-/* $eterna: tilde-luzah-bozo.c,v 1.15 2010/06/15 21:43:40 mrg Exp $ */
+/* $eterna: tilde-luzah-bozo.c,v 1.16 2011/11/18 09:21:15 mrg Exp $ */
/*
- * Copyright (c) 1997-2010 Matthew R. Green
+ * Copyright (c) 1997-2011 Matthew R. Green
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Please sign in to comment.
Something went wrong with that request. Please try again.