Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/httpd merge bozohttpd 20100510.
details: https://anonhg.NetBSD.org/src/rev/8d2ec1d10d87
branches: trunk
changeset: 754727:8d2ec1d10d87
user: mrg <mrg%NetBSD.org@localhost>
date: Mon May 10 14:44:19 2010 +0000
description:
merge bozohttpd 20100510.
diffstat:
libexec/httpd/Makefile.boot | 6 ++--
libexec/httpd/auth-bozo.c | 25 ++++++++++++-----
libexec/httpd/bozohttpd.c | 30 ++++++++++++--------
libexec/httpd/bozohttpd.h | 16 +++++-----
libexec/httpd/cgi-bozo.c | 8 ++--
libexec/httpd/daemon-bozo.c | 56 +++++++++++++++++++++------------------
libexec/httpd/tilde-luzah-bozo.c | 6 ++--
7 files changed, 83 insertions(+), 64 deletions(-)
diffs (truncated from 382 to 300 lines):
diff -r 1d1d9f87f637 -r 8d2ec1d10d87 libexec/httpd/Makefile.boot
--- a/libexec/httpd/Makefile.boot Mon May 10 14:33:21 2010 +0000
+++ b/libexec/httpd/Makefile.boot Mon May 10 14:44:19 2010 +0000
@@ -1,10 +1,10 @@
-# $eterna: Makefile.boot,v 1.8 2010/05/10 02:24:30 mrg Exp $
+# $eterna: Makefile.boot,v 1.9 2010/05/10 04:57:50 mrg Exp $
#
# very simple makefile to compile bozohttpd, should work with every make.
# see Makefile for a list of compile options that may be placed in CFLAGS.
CC= cc
-CFLAGS= -O
+CFLAGS= -O -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
GROFF= groff -Tascii
CRYPTOLIBDIR= # -L/usr/local/lib
@@ -14,7 +14,7 @@
dir-index-bozo.c ssl-bozo.c tilde-luzah-bozo.c main.c
all:
- $(CC) $(CFLAGS) -o bozohttpd $(FILES) $(CRYPTOLIBS)
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o bozohttpd $(FILES) $(CRYPTOLIBS)
man:
$(GROFF) -mandoc bozohttpd.8 > bozohttpd.cat8
diff -r 1d1d9f87f637 -r 8d2ec1d10d87 libexec/httpd/auth-bozo.c
--- a/libexec/httpd/auth-bozo.c Mon May 10 14:33:21 2010 +0000
+++ b/libexec/httpd/auth-bozo.c Mon May 10 14:44:19 2010 +0000
@@ -1,6 +1,6 @@
-/* $NetBSD: auth-bozo.c,v 1.8 2010/05/10 03:37:45 mrg Exp $ */
+/* $NetBSD: auth-bozo.c,v 1.9 2010/05/10 14:44:19 mrg Exp $ */
-/* $eterna: auth-bozo.c,v 1.15 2010/05/10 02:51:28 mrg Exp $ */
+/* $eterna: auth-bozo.c,v 1.16 2010/05/10 14:36:37 mrg Exp $ */
/*
* Copyright (c) 1997-2010 Matthew R. Green
@@ -53,8 +53,9 @@
* Check if HTTP authentication is required
*/
int
-bozo_auth_check(bozohttpd_t *httpd, bozo_httpreq_t *request, const char *file)
+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;
@@ -68,7 +69,7 @@
else {
*basename++ = '\0';
/* ensure basename(file) != AUTH_FILE */
- if (bozo_check_special_files(httpd, request, basename))
+ if (bozo_check_special_files(request, basename))
return 1;
}
request->hr_authrealm = bozostrdup(httpd, dir);
@@ -127,8 +128,10 @@
}
int
-bozo_auth_check_headers(bozohttpd_t *httpd, bozo_httpreq_t *request, char *val, char *str, ssize_t len)
+bozo_auth_check_headers(bozo_httpreq_t *request, char *val, char *str, ssize_t len)
{
+ bozohttpd_t *httpd = request->hr_httpd;
+
if (strcasecmp(val, "authorization") == 0 &&
strncasecmp(str, "Basic ", 6) == 0) {
char authbuf[BUFSIZ];
@@ -158,9 +161,11 @@
}
int
-bozo_auth_check_special_files(bozohttpd_t *httpd, bozo_httpreq_t *request,
+bozo_auth_check_special_files(bozo_httpreq_t *request,
const char *name)
{
+ bozohttpd_t *httpd = request->hr_httpd;
+
if (strcmp(name, AUTH_FILE) == 0)
return bozo_http_error(httpd, 403, request,
"no permission to open authfile");
@@ -168,8 +173,10 @@
}
void
-bozo_auth_check_401(bozohttpd_t *httpd, bozo_httpreq_t *request, int code)
+bozo_auth_check_401(bozo_httpreq_t *request, int code)
{
+ bozohttpd_t *httpd = request->hr_httpd;
+
if (code == 401)
bozo_printf(httpd,
"WWW-Authenticate: Basic realm=\"%s\"\r\n",
@@ -179,9 +186,11 @@
#ifndef NO_CGIBIN_SUPPORT
void
-bozo_auth_cgi_setenv(bozohttpd_t *httpd, bozo_httpreq_t *request,
+bozo_auth_cgi_setenv(bozo_httpreq_t *request,
char ***curenvpp)
{
+ bozohttpd_t *httpd = request->hr_httpd;
+
if (request->hr_authuser && *request->hr_authuser) {
bozo_setenv(httpd, "AUTH_TYPE", "Basic", (*curenvpp)++);
bozo_setenv(httpd, "REMOTE_USER", request->hr_authuser,
diff -r 1d1d9f87f637 -r 8d2ec1d10d87 libexec/httpd/bozohttpd.c
--- a/libexec/httpd/bozohttpd.c Mon May 10 14:33:21 2010 +0000
+++ b/libexec/httpd/bozohttpd.c Mon May 10 14:44:19 2010 +0000
@@ -1,6 +1,6 @@
-/* $NetBSD: bozohttpd.c,v 1.16 2010/05/10 03:37:45 mrg Exp $ */
+/* $NetBSD: bozohttpd.c,v 1.17 2010/05/10 14:44:19 mrg Exp $ */
-/* $eterna: bozohttpd.c,v 1.165 2010/05/10 02:52:34 mrg Exp $ */
+/* $eterna: bozohttpd.c,v 1.167 2010/05/10 14:36:37 mrg Exp $ */
/*
* Copyright (c) 1997-2010 Matthew R. Green
@@ -658,7 +658,7 @@
while (*val == ' ' || *val == '\t')
val++;
- if (bozo_auth_check_headers(httpd, request, val, str, len))
+ if (bozo_auth_check_headers(request, val, str, len))
goto next_header;
hdr = addmerge_header(request, val, str, len);
@@ -845,7 +845,7 @@
char dir[MAXPATHLEN], dirfile[MAXPATHLEN], *basename;
snprintf(dir, sizeof(dir), "%s", request->hr_file + 1);
- debug((httpd, DEBUG_FAT, "check_bzredirect: dir %s", dir));
+ debug((request->hr_httpd, DEBUG_FAT, "check_bzredirect: dir %s", dir));
basename = strrchr(dir, '/');
if ((!basename || basename[1] != '\0') &&
@@ -1034,7 +1034,7 @@
* use it as the directory to look for the redir file.
*/
snprintf(dir, sizeof(dir), "%s", request->hr_file + 1);
- debug((httpd, DEBUG_FAT, "check_bzredirect: dir %s", dir));
+ debug((request->hr_httpd, DEBUG_FAT, "check_bzredirect: dir %s", dir));
basename = strrchr(dir, '/');
if ((!basename || basename[1] != '\0') &&
@@ -1058,14 +1058,16 @@
return;
absolute = 1;
}
- debug((httpd, DEBUG_FAT, "check_bzredirect: calling readlink"));
+ debug((request->hr_httpd, DEBUG_FAT,
+ "check_bzredirect: calling readlink"));
rv = readlink(redir, redirpath, sizeof redirpath - 1);
if (rv == -1 || rv == 0) {
- debug((httpd, DEBUG_FAT, "readlink failed"));
+ debug((request->hr_httpd, DEBUG_FAT, "readlink failed"));
return;
}
redirpath[rv] = '\0';
- debug((httpd, DEBUG_FAT, "readlink returned \"%s\"", redirpath));
+ debug((request->hr_httpd, DEBUG_FAT,
+ "readlink returned \"%s\"", redirpath));
/* now we have the link pointer, redirect to the real place */
if (absolute)
@@ -1074,7 +1076,8 @@
snprintf(finalredir = redir, sizeof(redir), "/%s/%s", dir,
redirpath);
- debug((httpd, DEBUG_FAT, "check_bzredirect: new redir %s", finalredir));
+ debug((request->hr_httpd, DEBUG_FAT,
+ "check_bzredirect: new redir %s", finalredir));
handle_redirect(request, finalredir, absolute);
}
@@ -1303,7 +1306,7 @@
goto bad_done;
}
- if (bozo_auth_check(httpd, request, newfile))
+ if (bozo_auth_check(request, newfile))
goto bad_done;
if (strlen(newfile)) {
@@ -1466,7 +1469,7 @@
if (strcmp(name, ABSREDIRECT_FILE) == 0)
return bozo_http_error(httpd, 403, request,
"no permission to open redirect file");
- return bozo_auth_check_special_files(httpd, request, name);
+ return bozo_auth_check_special_files(request, name);
}
/* generic header printing routine */
@@ -1710,7 +1713,7 @@
size = 0;
bozo_printf(httpd, "%s %s\r\n", proto, header);
- bozo_auth_check_401(httpd, request, code);
+ bozo_auth_check_401(request, code);
bozo_printf(httpd, "Content-Type: text/html\r\n");
bozo_printf(httpd, "Content-Length: %d\r\n", size);
@@ -1791,6 +1794,9 @@
* programs (for we pass stdin off to them). could fix this
* by becoming a fd-passing program instead of just exec'ing
* the program
+ *
+ * the above is no longer true, we are the fd-passing
+ * program already.
*/
for (; readfn(httpd, fd, &c, 1) == 1; ) {
debug((httpd, DEBUG_EXPLODING, "bozodgetln read %c", c));
diff -r 1d1d9f87f637 -r 8d2ec1d10d87 libexec/httpd/bozohttpd.h
--- a/libexec/httpd/bozohttpd.h Mon May 10 14:33:21 2010 +0000
+++ b/libexec/httpd/bozohttpd.h Mon May 10 14:44:19 2010 +0000
@@ -1,6 +1,6 @@
-/* $NetBSD: bozohttpd.h,v 1.12 2010/05/10 03:37:45 mrg Exp $ */
+/* $NetBSD: bozohttpd.h,v 1.13 2010/05/10 14:44:19 mrg Exp $ */
-/* $eterna: bozohttpd.h,v 1.30 2010/05/10 02:51:28 mrg Exp $ */
+/* $eterna: bozohttpd.h,v 1.31 2010/05/10 14:36:37 mrg Exp $ */
/*
* Copyright (c) 1997-2010 Matthew R. Green
@@ -213,13 +213,13 @@
extern void bozo_auth_cgi_setenv(bozo_httpreq_t *, char ***);
extern int bozo_auth_cgi_count(bozo_httpreq_t *);
#else
-#define bozo_auth_check(w, x, y) 0
+#define bozo_auth_check(x, y) 0
#define bozo_auth_cleanup(x) /* nothing */
-#define bozo_auth_check_headers(x, y, z, a, b) 0
-#define bozo_auth_check_special_files(w, x, y) 0
-#define bozo_auth_check_401(w, x, y) /* nothing */
-#define bozo_auth_cgi_setenv(w, x, y) /* nothing */
-#define bozo_auth_cgi_count(x) 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_cgi_count(x) 0
#endif /* DO_HTPASSWD */
diff -r 1d1d9f87f637 -r 8d2ec1d10d87 libexec/httpd/cgi-bozo.c
--- a/libexec/httpd/cgi-bozo.c Mon May 10 14:33:21 2010 +0000
+++ b/libexec/httpd/cgi-bozo.c Mon May 10 14:44:19 2010 +0000
@@ -1,6 +1,6 @@
-/* $NetBSD: cgi-bozo.c,v 1.15 2010/05/10 03:37:45 mrg Exp $ */
+/* $NetBSD: cgi-bozo.c,v 1.16 2010/05/10 14:44:19 mrg Exp $ */
-/* $eterna: cgi-bozo.c,v 1.35 2010/05/10 02:51:28 mrg Exp $ */
+/* $eterna: cgi-bozo.c,v 1.36 2010/05/10 14:36:37 mrg Exp $ */
/*
* Copyright (c) 1997-2010 Matthew R. Green
@@ -279,7 +279,7 @@
len = strlen(url);
- if (bozo_auth_check(httpd, request, url + 1))
+ if (bozo_auth_check(request, url + 1))
goto out;
if (!httpd->cgibin ||
@@ -402,7 +402,7 @@
if (request->hr_remoteaddr && *request->hr_remoteaddr)
bozo_setenv(httpd, "REMOTE_ADDR", request->hr_remoteaddr,
curenvp++);
- bozo_auth_cgi_setenv(httpd, request, &curenvp);
+ bozo_auth_cgi_setenv(request, &curenvp);
free(file);
free(url);
diff -r 1d1d9f87f637 -r 8d2ec1d10d87 libexec/httpd/daemon-bozo.c
--- a/libexec/httpd/daemon-bozo.c Mon May 10 14:33:21 2010 +0000
+++ b/libexec/httpd/daemon-bozo.c Mon May 10 14:44:19 2010 +0000
@@ -1,6 +1,6 @@
-/* $NetBSD: daemon-bozo.c,v 1.8 2010/05/10 03:37:45 mrg Exp $ */
+/* $NetBSD: daemon-bozo.c,v 1.9 2010/05/10 14:44:19 mrg Exp $ */
-/* $eterna: daemon-bozo.c,v 1.19 2010/05/10 02:51:28 mrg Exp $ */
+/* $eterna: daemon-bozo.c,v 1.20 2010/05/10 04:39:00 mrg Exp $ */
/*
* Copyright (c) 1997-2010 Matthew R. Green
@@ -136,7 +136,6 @@
static void
daemon_runchild(bozohttpd_t *httpd, int fd)
{
-
httpd->request_times++;
/* setup stdin/stdout/stderr */
@@ -146,6 +145,33 @@
close(fd);
}
+static int
Home |
Main Index |
Thread Index |
Old Index