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 20100509.



details:   https://anonhg.NetBSD.org/src/rev/f35578aa81ec
branches:  trunk
changeset: 754717:f35578aa81ec
user:      mrg <mrg%NetBSD.org@localhost>
date:      Mon May 10 03:37:45 2010 +0000

description:
merge bozohttpd 20100509.

diffstat:

 libexec/httpd/CHANGES            |     8 +-
 libexec/httpd/Makefile           |     7 +-
 libexec/httpd/Makefile.boot      |     4 +-
 libexec/httpd/auth-bozo.c        |    79 +-
 libexec/httpd/bozohttpd.8        |    11 +-
 libexec/httpd/bozohttpd.c        |  2499 ++++++++++++++++++-------------------
 libexec/httpd/bozohttpd.h        |   276 ++-
 libexec/httpd/cgi-bozo.c         |   468 +++---
 libexec/httpd/content-bozo.c     |   363 ++--
 libexec/httpd/daemon-bozo.c      |   147 +-
 libexec/httpd/dir-index-bozo.c   |   114 +-
 libexec/httpd/ssl-bozo.c         |   265 ++-
 libexec/httpd/tilde-luzah-bozo.c |    57 +-
 13 files changed, 2236 insertions(+), 2062 deletions(-)

diffs (truncated from 5602 to 300 lines):

diff -r 5195ef674734 -r f35578aa81ec libexec/httpd/CHANGES
--- a/libexec/httpd/CHANGES     Mon May 10 03:30:04 2010 +0000
+++ b/libexec/httpd/CHANGES     Mon May 10 03:37:45 2010 +0000
@@ -1,4 +1,10 @@
-$eterna: CHANGES,v 1.68 2009/05/22 21:51:38 mrg Exp $
+$eterna: CHANGES,v 1.70 2010/05/10 02:24:30 mrg Exp $
+
+changes since bozohttpd 20090522:
+       o  major rework and clean up of internal interfaces.  move the main
+          program into main.c, the remaining parts are useable as library.
+          add bindings for lua.  by Alistair G. Crooks <agc%netbsd.org@localhost>
+       o  fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=566325
 
 changes since bozohttpd 20090417:
        o  avoid dying in daemon mode for some uncommon, but recoverable, errors
diff -r 5195ef674734 -r f35578aa81ec libexec/httpd/Makefile
--- a/libexec/httpd/Makefile    Mon May 10 03:30:04 2010 +0000
+++ b/libexec/httpd/Makefile    Mon May 10 03:37:45 2010 +0000
@@ -1,6 +1,8 @@
-#      $NetBSD: Makefile,v 1.10 2009/05/23 06:45:28 mrg Exp $
+#      $NetBSD: Makefile,v 1.11 2010/05/10 03:37:45 mrg Exp $
 #
 #      $eterna: Makefile,v 1.27 2009/05/22 21:51:38 mrg Exp $
+#
+# berkeley (netbsd) makefile.  see Makefile.boot for other systems.
 
 # compile-time options are:
 #      DEBUG                   /* include debugging support */
@@ -17,10 +19,13 @@
 BUILDSYMLINKS+=bozohttpd.8 httpd.8
 SRCS=  bozohttpd.c ssl-bozo.c auth-bozo.c cgi-bozo.c daemon-bozo.c \
        tilde-luzah-bozo.c dir-index-bozo.c content-bozo.c
+SRCS+= main.c
 
 LDADD= -lcrypt
 DPADD= ${LIBCRYPT}
 
+WARNS?=        4
+
 .include <bsd.own.mk>
 
 .if ${MKCRYPTO} != "no"
diff -r 5195ef674734 -r f35578aa81ec libexec/httpd/Makefile.boot
--- a/libexec/httpd/Makefile.boot       Mon May 10 03:30:04 2010 +0000
+++ b/libexec/httpd/Makefile.boot       Mon May 10 03:37:45 2010 +0000
@@ -1,4 +1,4 @@
-# $eterna: Makefile.boot,v 1.7 2005/09/27 20:09:20 mrg Exp $
+# $eterna: Makefile.boot,v 1.8 2010/05/10 02:24:30 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.
@@ -11,7 +11,7 @@
 CRYPTOLIBS=    $(CRYPTOLIBDIR) -lcrypto -lssl
 
 FILES= bozohttpd.c auth-bozo.c cgi-bozo.c content-bozo.c daemon-bozo.c \
-       dir-index-bozo.c ssl-bozo.c tilde-luzah-bozo.c
+       dir-index-bozo.c ssl-bozo.c tilde-luzah-bozo.c main.c
 
 all:
        $(CC) $(CFLAGS) -o bozohttpd $(FILES) $(CRYPTOLIBS)
diff -r 5195ef674734 -r f35578aa81ec libexec/httpd/auth-bozo.c
--- a/libexec/httpd/auth-bozo.c Mon May 10 03:30:04 2010 +0000
+++ b/libexec/httpd/auth-bozo.c Mon May 10 03:37:45 2010 +0000
@@ -1,9 +1,9 @@
-/*     $NetBSD: auth-bozo.c,v 1.7 2009/04/18 21:22:03 mrg Exp $        */
+/*     $NetBSD: auth-bozo.c,v 1.8 2010/05/10 03:37:45 mrg Exp $        */
 
-/*     $eterna: auth-bozo.c,v 1.13 2009/04/18 07:38:56 mrg Exp $       */
+/*     $eterna: auth-bozo.c,v 1.15 2010/05/10 02:51:28 mrg Exp $       */
 
 /*
- * Copyright (c) 1997-2009 Matthew R. Green
+ * Copyright (c) 1997-2010 Matthew R. Green
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -53,7 +53,7 @@
  * Check if HTTP authentication is required
  */
 int
-auth_check(http_req *request, const char *file)
+bozo_auth_check(bozohttpd_t *httpd, bozo_httpreq_t *request, const char *file)
 {
        struct stat sb;
        char dir[MAXPATHLEN], authfile[MAXPATHLEN], *basename;
@@ -68,23 +68,23 @@
        else {
                *basename++ = '\0';
                        /* ensure basename(file) != AUTH_FILE */
-               if (check_special_files(request, basename))
+               if (bozo_check_special_files(httpd, request, basename))
                        return 1;
        }
-       request->hr_authrealm = bozostrdup(dir);
+       request->hr_authrealm = bozostrdup(httpd, dir);
 
        snprintf(authfile, sizeof(authfile), "%s/%s", dir, AUTH_FILE);
        if (stat(authfile, &sb) < 0) {
-               debug((DEBUG_NORMAL,
-                   "auth_check realm `%s' dir `%s' authfile `%s' missing",
+               debug((httpd, DEBUG_NORMAL,
+                   "bozo_auth_check realm `%s' dir `%s' authfile `%s' missing",
                    dir, file, authfile));
                return 0;
        }
        if ((fp = fopen(authfile, "r")) == NULL)
-               return http_error(403, request, "no permission to open "
-                                               "authfile");
-       debug((DEBUG_NORMAL,
-           "auth_check realm `%s' dir `%s' authfile `%s' open",
+               return bozo_http_error(httpd, 403, request,
+                       "no permission to open authfile");
+       debug((httpd, DEBUG_NORMAL,
+           "bozo_auth_check realm `%s' dir `%s' authfile `%s' open",
            dir, file, authfile));
        if (request->hr_authuser && request->hr_authpass) {
                while (fgets(user, sizeof(user), fp) != NULL) {
@@ -94,24 +94,26 @@
                        if ((pass = strchr(user, ':')) == NULL)
                                continue;
                        *pass++ = '\0';
-                       debug((DEBUG_NORMAL,
-                           "auth_check authfile `%s':`%s' client `%s':`%s'",
+                       debug((httpd, DEBUG_NORMAL,
+                           "bozo_auth_check authfile `%s':`%s' "
+                               "client `%s':`%s'",
                            user, pass, request->hr_authuser,
                            request->hr_authpass));
                        if (strcmp(request->hr_authuser, user) != 0)
                                continue;
-                       if (strcmp(crypt(request->hr_authpass, pass), pass))
+                       if (strcmp(crypt(request->hr_authpass, pass),
+                                       pass) != 0)
                                break;
                        fclose(fp);
                        return 0;
                }
        }
        fclose(fp);
-       return http_error(401, request, "bad auth");
+       return bozo_http_error(httpd, 401, request, "bad auth");
 }
 
 void
-auth_cleanup(http_req *request)
+bozo_auth_cleanup(bozo_httpreq_t *request)
 {
 
        if (request == NULL)
@@ -125,7 +127,7 @@
 }
 
 int
-auth_check_headers(http_req *request, char *val, char *str, ssize_t len)
+bozo_auth_check_headers(bozohttpd_t *httpd, bozo_httpreq_t *request, char *val, char *str, ssize_t len)
 {
        if (strcasecmp(val, "authorization") == 0 &&
            strncasecmp(str, "Basic ", 6) == 0) {
@@ -133,18 +135,20 @@
                char    *pass = NULL;
                ssize_t alen;
 
-               alen = base64_decode((unsigned char *)str + 6, len - 6,
-                   (unsigned char *)authbuf, sizeof(authbuf) - 1);
+               alen = base64_decode((unsigned char *)str + 6,
+                                       (size_t)(len - 6),
+                                       (unsigned char *)authbuf,
+                                       sizeof(authbuf) - 1);
                if (alen != -1)
                        authbuf[alen] = '\0';
                if (alen == -1 ||
                    (pass = strchr(authbuf, ':')) == NULL)
-                       return http_error(400, request,
+                       return bozo_http_error(httpd, 400, request,
                            "bad authorization field");
                *pass++ = '\0';
-               request->hr_authuser = bozostrdup(authbuf);
-               request->hr_authpass = bozostrdup(pass);
-               debug((DEBUG_FAT,
+               request->hr_authuser = bozostrdup(httpd, authbuf);
+               request->hr_authpass = bozostrdup(httpd, pass);
+               debug((httpd, DEBUG_FAT,
                    "decoded authorization `%s' as `%s':`%s'",
                    str, request->hr_authuser, request->hr_authpass));
                        /* don't store in request->headers */
@@ -154,34 +158,39 @@
 }
 
 int
-auth_check_special_files(http_req *request, const char *name)
+bozo_auth_check_special_files(bozohttpd_t *httpd, bozo_httpreq_t *request,
+                               const char *name)
 {
        if (strcmp(name, AUTH_FILE) == 0)
-               return http_error(403, request, "no permission to open authfile");
+               return bozo_http_error(httpd, 403, request,
+                               "no permission to open authfile");
        return 0;
 }
 
 void
-auth_check_401(http_req *request, int code)
+bozo_auth_check_401(bozohttpd_t *httpd, bozo_httpreq_t *request, int code)
 {
        if (code == 401)
-               bozoprintf("WWW-Authenticate: Basic realm=\"%s\"\r\n",
-                   request && request->hr_authrealm ? request->hr_authrealm :
-                   "default realm");
+               bozo_printf(httpd,
+                       "WWW-Authenticate: Basic realm=\"%s\"\r\n",
+                       (request && request->hr_authrealm) ?
+                               request->hr_authrealm : "default realm");
 }
 
 #ifndef NO_CGIBIN_SUPPORT
 void
-auth_cgi_setenv(http_req *request, char ***curenvpp)
+bozo_auth_cgi_setenv(bozohttpd_t *httpd, bozo_httpreq_t *request,
+                       char ***curenvpp)
 {
        if (request->hr_authuser && *request->hr_authuser) {
-               spsetenv("AUTH_TYPE", "Basic", (*curenvpp)++);
-               spsetenv("REMOTE_USER", request->hr_authuser, (*curenvpp)++);
+               bozo_setenv(httpd, "AUTH_TYPE", "Basic", (*curenvpp)++);
+               bozo_setenv(httpd, "REMOTE_USER", request->hr_authuser,
+                               (*curenvpp)++);
        }
 }
 
 int
-auth_cgi_count(http_req *request)
+bozo_auth_cgi_count(bozo_httpreq_t *request)
 {
        return (request->hr_authuser && *request->hr_authuser) ? 2 : 0;
 }
@@ -219,9 +228,11 @@
                            return(-1)
 
                IN_CHECK(in[i + 0]);
+               /*LINTED*/
                *(cp++) = decodetable[in[i + 0]] << 2
                        | decodetable[in[i + 1]] >> 4;
                IN_CHECK(in[i + 1]);
+               /*LINTED*/
                *(cp++) = decodetable[in[i + 1]] << 4
                        | decodetable[in[i + 2]] >> 2;
                IN_CHECK(in[i + 2]);
diff -r 5195ef674734 -r f35578aa81ec libexec/httpd/bozohttpd.8
--- a/libexec/httpd/bozohttpd.8 Mon May 10 03:30:04 2010 +0000
+++ b/libexec/httpd/bozohttpd.8 Mon May 10 03:37:45 2010 +0000
@@ -1,8 +1,8 @@
-.\"    $NetBSD: bozohttpd.8,v 1.16 2009/11/22 18:40:26 mbalmer Exp $
+.\"    $NetBSD: bozohttpd.8,v 1.17 2010/05/10 03:37:45 mrg Exp $
 .\"
-.\"    $eterna: bozohttpd.8,v 1.91 2009/05/23 00:55:22 mrg Exp $
+.\"    $eterna: bozohttpd.8,v 1.93 2010/05/10 02:51:28 mrg Exp $
 .\"
-.\" Copyright (c) 1997-2009 Matthew R. Green
+.\" Copyright (c) 1997-2010 Matthew R. Green
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -495,6 +495,11 @@
 .Aq pek%pdc.kth.se@localhost
 provided a fix for a minor (non-security) buffer overflow condition
 .It
+Alistair G. Crooks
+.Aq agc%netbsd.org@localhost
+cleaned up many internal interfaces, made bozohttpd linkable as a
+library and provided the lua binding.
+.It
 Jun-ichiro itojun Hagino, KAME
 .Aq itojun%iijlab.net@localhost
 provided initial IPv6 support
diff -r 5195ef674734 -r f35578aa81ec libexec/httpd/bozohttpd.c
--- a/libexec/httpd/bozohttpd.c Mon May 10 03:30:04 2010 +0000
+++ b/libexec/httpd/bozohttpd.c Mon May 10 03:37:45 2010 +0000
@@ -1,9 +1,9 @@
-/*     $NetBSD: bozohttpd.c,v 1.15 2009/05/23 08:26:26 mrg Exp $       */
+/*     $NetBSD: bozohttpd.c,v 1.16 2010/05/10 03:37:45 mrg Exp $       */
 
-/*     $eterna: bozohttpd.c,v 1.159 2009/05/23 02:14:30 mrg Exp $      */
+/*     $eterna: bozohttpd.c,v 1.165 2010/05/10 02:52:34 mrg Exp $      */
 
 /*
- * Copyright (c) 1997-2009 Matthew R. Green
+ * Copyright (c) 1997-2010 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/20090522"
+#define SERVER_SOFTWARE                "bozohttpd/20100509"
 #endif
 #ifndef DIRECT_ACCESS_FILE
 #define DIRECT_ACCESS_FILE     ".bzdirect"
@@ -120,6 +120,13 @@



Home | Main Index | Thread Index | Old Index