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



details:   https://anonhg.NetBSD.org/src/rev/0efab6185585
branches:  trunk
changeset: 755724:0efab6185585
user:      mrg <mrg%NetBSD.org@localhost>
date:      Thu Jun 17 19:43:30 2010 +0000

description:
merge bozohttpd 20100617.

diffstat:

 libexec/httpd/CHANGES            |   9 +++-
 libexec/httpd/bozohttpd.8        |   9 ++--
 libexec/httpd/bozohttpd.c        |  23 ++++++++---
 libexec/httpd/bozohttpd.h        |  74 ++++++++++++++++++++--------------------
 libexec/httpd/cgi-bozo.c         |  14 +++++--
 libexec/httpd/daemon-bozo.c      |  17 ++++++--
 libexec/httpd/tilde-luzah-bozo.c |  13 +++---
 7 files changed, 93 insertions(+), 66 deletions(-)

diffs (truncated from 397 to 300 lines):

diff -r 3807518ee84c -r 0efab6185585 libexec/httpd/CHANGES
--- a/libexec/httpd/CHANGES     Thu Jun 17 18:35:45 2010 +0000
+++ b/libexec/httpd/CHANGES     Thu Jun 17 19:43:30 2010 +0000
@@ -1,8 +1,13 @@
-$eterna: CHANGES,v 1.71 2010/05/13 04:19:04 mrg Exp $
+$eterna: CHANGES,v 1.75 2010/06/17 19:26:54 mrg Exp $
 
 changes since bozohttpd 20100509:
        o  fix some compile issues
-       o  fix SSL mode.  from rtr.
+       o  fix SSL mode.  from rtr
+       o  fix some cgi-bin issues, as seen with cvsweb
+       o  disable multi-file daemon mode for now, it breaks
+       o  return 404's instead of 403's when chdir of ~user dirs fail
+       o  remove "noreturn" attribute from bozo_http_error() that was
+          causing incorrect runtime behaviour
 
 changes since bozohttpd 20090522:
        o  major rework and clean up of internal interfaces.  move the main
diff -r 3807518ee84c -r 0efab6185585 libexec/httpd/bozohttpd.8
--- a/libexec/httpd/bozohttpd.8 Thu Jun 17 18:35:45 2010 +0000
+++ b/libexec/httpd/bozohttpd.8 Thu Jun 17 19:43:30 2010 +0000
@@ -1,6 +1,6 @@
-.\"    $NetBSD: bozohttpd.8,v 1.19 2010/05/15 06:48:27 mrg Exp $
+.\"    $NetBSD: bozohttpd.8,v 1.20 2010/06/17 19:43:30 mrg Exp $
 .\"
-.\"    $eterna: bozohttpd.8,v 1.95 2010/05/13 04:17:58 mrg Exp $
+.\"    $eterna: bozohttpd.8,v 1.96 2010/06/17 19:27:32 mrg Exp $
 .\"
 .\" Copyright (c) 1997-2010 Matthew R. Green
 .\" All rights reserved.
@@ -26,8 +26,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd May 22, 2009
-.Dd May 10, 2010
+.Dd June 17, 2010
 .Dt HTTPD 8
 .Os
 .Sh NAME
@@ -459,7 +458,7 @@
 and regular code audits.
 This manual documents
 .Nm
-version 20100512.
+version 20100617.
 .Sh AUTHORS
 .Nm
 was written by Matthew R. Green
diff -r 3807518ee84c -r 0efab6185585 libexec/httpd/bozohttpd.c
--- a/libexec/httpd/bozohttpd.c Thu Jun 17 18:35:45 2010 +0000
+++ b/libexec/httpd/bozohttpd.c Thu Jun 17 19:43:30 2010 +0000
@@ -1,6 +1,6 @@
-/*     $NetBSD: bozohttpd.c,v 1.19 2010/05/15 06:48:27 mrg Exp $       */
+/*     $NetBSD: bozohttpd.c,v 1.20 2010/06/17 19:43:30 mrg Exp $       */
 
-/*     $eterna: bozohttpd.c,v 1.169 2010/05/13 04:17:58 mrg Exp $      */
+/*     $eterna: bozohttpd.c,v 1.172 2010/06/17 19:27:32 mrg Exp $      */
 
 /*
  * Copyright (c) 1997-2010 Matthew R. Green
@@ -109,7 +109,7 @@
 #define INDEX_HTML             "index.html"
 #endif
 #ifndef SERVER_SOFTWARE
-#define SERVER_SOFTWARE                "bozohttpd/20100512"
+#define SERVER_SOFTWARE                "bozohttpd/20100617"
 #endif
 #ifndef DIRECT_ACCESS_FILE
 #define DIRECT_ACCESS_FILE     ".bzdirect"
@@ -339,6 +339,7 @@
        MF(hr_remoteaddr);
        MF(hr_serverport);
        MF(hr_file);
+       MF(hr_oldfile);
        MF(hr_query);
 #undef MF
        bozo_auth_cleanup(request);
@@ -521,10 +522,14 @@
        bozo_httpreq_t *request;
 
        /*
-        * if we're in daemon mode, bozo_daemon_fork() will return here once
-        * for each child, then we can setup SSL.
+        * if we're in daemon mode, bozo_daemon_fork() will return here twice
+        * for each call.  once in the child, returning 0, and once in the
+        * parent, returning 1.  for each child, then we can setup SSL, and
+        * the parent can signal the caller there was no request to process
+        * and it will wait for another.
         */
-       bozo_daemon_fork(httpd);
+       if (bozo_daemon_fork(httpd))
+               return NULL;
        bozo_ssl_accept(httpd);
 
        request = bozomalloc(httpd, sizeof(*request));
@@ -536,6 +541,7 @@
        request->hr_last_byte_pos = -1;
        request->hr_if_modified_since = NULL;
        request->hr_file = NULL;
+       request->hr_oldfile = NULL;
 
        slen = sizeof(ss);
        if (getpeername(0, (struct sockaddr *)(void *)&ss, &slen) < 0)
@@ -1310,7 +1316,7 @@
                goto bad_done;
 
        if (strlen(newfile)) {
-               free(request->hr_file);
+               request->hr_oldfile = request->hr_file;
                request->hr_file = newfile;
        }
 
@@ -2004,6 +2010,9 @@
            strcmp(cp, "true") == 0) {
                httpd->dir_indexing = 1;
        }
+       if ((cp = bozo_get_pref(prefs, "public_html")) != NULL) {
+               httpd->public_html = strdup(cp);
+       }
        httpd->server_software =
                        strdup(bozo_get_pref(prefs, "server software"));
        httpd->index_html = strdup(bozo_get_pref(prefs, "index.html"));
diff -r 3807518ee84c -r 0efab6185585 libexec/httpd/bozohttpd.h
--- a/libexec/httpd/bozohttpd.h Thu Jun 17 18:35:45 2010 +0000
+++ b/libexec/httpd/bozohttpd.h Thu Jun 17 19:43:30 2010 +0000
@@ -1,6 +1,6 @@
-/*     $NetBSD: bozohttpd.h,v 1.13 2010/05/10 14:44:19 mrg Exp $       */
+/*     $NetBSD: bozohttpd.h,v 1.14 2010/06/17 19:43:30 mrg Exp $       */
 
-/*     $eterna: bozohttpd.h,v 1.31 2010/05/10 14:36:37 mrg Exp $       */
+/*     $eterna: bozohttpd.h,v 1.35 2010/06/17 00:49:30 mrg Exp $       */
 
 /*
  * Copyright (c) 1997-2010 Matthew R. Green
@@ -118,6 +118,7 @@
 #define HTTP_CONNECT   0x08    /* not supported */
        const char *hr_methodstr;
        char    *hr_file;
+       char    *hr_oldfile;    /* if we added an index_html */
        char    *hr_query;  
        const char *hr_proto;
        const char *hr_content_type;
@@ -175,8 +176,7 @@
 void   bozo_err(bozohttpd_t *, int, const char *, ...)
                __attribute__((__format__(__printf__, 3, 4)))
                __attribute__((__noreturn__));
-int    bozo_http_error(bozohttpd_t *, int, bozo_httpreq_t *, const char *)
-               __attribute__((__noreturn__));
+int    bozo_http_error(bozohttpd_t *, int, bozo_httpreq_t *, const char *);
 
 int    bozo_check_special_files(bozo_httpreq_t *, const char *);
 char   *bozo_http_date(char *, size_t);
@@ -196,59 +196,59 @@
 #define bozo_ssl_accept(x)             /* nothing */
 #define bozo_ssl_destroy(x)            /* nothing */
 #else
-extern void    bozo_ssl_set_opts(bozohttpd_t *, const char *, const char *);
-extern void    bozo_ssl_init(bozohttpd_t *);
-extern void    bozo_ssl_accept(bozohttpd_t *);
-extern void    bozo_ssl_destroy(bozohttpd_t *);
+void   bozo_ssl_set_opts(bozohttpd_t *, const char *, const char *);
+void   bozo_ssl_init(bozohttpd_t *);
+void   bozo_ssl_accept(bozohttpd_t *);
+void   bozo_ssl_destroy(bozohttpd_t *);
 #endif
 
 
 /* auth-bozo.c */
 #ifdef DO_HTPASSWD
-extern int     bozo_auth_check(bozo_httpreq_t *, const char *);
-extern void    bozo_auth_cleanup(bozo_httpreq_t *);
-extern int     bozo_auth_check_headers(bozo_httpreq_t *, char *, char *, ssize_t);
-extern int     bozo_auth_check_special_files(bozo_httpreq_t *, const char *);
-extern void    bozo_auth_check_401(bozo_httpreq_t *, int);
-extern void    bozo_auth_cgi_setenv(bozo_httpreq_t *, char ***);
-extern int     bozo_auth_cgi_count(bozo_httpreq_t *);
+int    bozo_auth_check(bozo_httpreq_t *, const char *);
+void   bozo_auth_cleanup(bozo_httpreq_t *);
+int    bozo_auth_check_headers(bozo_httpreq_t *, char *, char *, ssize_t);
+int    bozo_auth_check_special_files(bozo_httpreq_t *, const char *);
+void   bozo_auth_check_401(bozo_httpreq_t *, int);
+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_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
+#define        bozo_auth_check(x, y)                   0
+#define        bozo_auth_cleanup(x)                    /* nothing */
+#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 */
 
 
 /* cgi-bozo.c */
 #ifdef NO_CGIBIN_SUPPORT
-#define        bozo_process_cgi(h, r)                  0
+#define        bozo_process_cgi(h)                             0
 #else
-extern void    bozo_cgi_setbin(bozohttpd_t *, const char *);
-extern void    bozo_setenv(bozohttpd_t *, const char *, const char *, char **);
-extern int     bozo_process_cgi(bozo_httpreq_t *);
-extern void    bozo_add_content_map_cgi(bozohttpd_t *, const char *, const char *);
+void   bozo_cgi_setbin(bozohttpd_t *, const char *);
+void   bozo_setenv(bozohttpd_t *, const char *, const char *, char **);
+int    bozo_process_cgi(bozo_httpreq_t *);
+void   bozo_add_content_map_cgi(bozohttpd_t *, const char *, const char *);
 #endif /* NO_CGIBIN_SUPPORT */
 
 
 /* daemon-bozo.c */
 #ifdef NO_DAEMON_MODE
 #define bozo_daemon_init(x)                            /* nothing */
-#define bozo_daemon_fork(x)                            /* nothing */
-#define bozo_daemon_closefds()                 /* nothing */
+#define bozo_daemon_fork(x)                            0
+#define bozo_daemon_closefds()                         /* nothing */
 #else
-extern void    bozo_daemon_init(bozohttpd_t *);
-extern void    bozo_daemon_fork(bozohttpd_t *);
-extern void    bozo_daemon_closefds(bozohttpd_t *);
+void   bozo_daemon_init(bozohttpd_t *);
+int    bozo_daemon_fork(bozohttpd_t *);
+void   bozo_daemon_closefds(bozohttpd_t *);
 #endif /* NO_DAEMON_MODE */
 
 
 /* tilde-luzah-bozo.c */
 #ifdef NO_USER_SUPPORT
-#define bozo_user_transform(a, b, c)                   0
+#define bozo_user_transform(a, c)                      0
 #else
 int    bozo_user_transform(bozo_httpreq_t *, int *);
 #endif /* NO_USER_SUPPORT */
@@ -263,10 +263,10 @@
 
 
 /* content-bozo.c */
-extern const char *bozo_content_type(bozo_httpreq_t *, const char *);
-extern const char *bozo_content_encoding(bozo_httpreq_t *, const char *);
-extern bozo_content_map_t *bozo_match_content_map(bozohttpd_t *, const char *, int);
-extern bozo_content_map_t *bozo_get_content_map(bozohttpd_t *, const char *);
+const char *bozo_content_type(bozo_httpreq_t *, const char *);
+const char *bozo_content_encoding(bozo_httpreq_t *, const char *);
+bozo_content_map_t *bozo_match_content_map(bozohttpd_t *, const char *, int);
+bozo_content_map_t *bozo_get_content_map(bozohttpd_t *, const char *);
 #ifndef NO_DYNAMIC_CONTENT
 void   bozo_add_content_map_mime(bozohttpd_t *, const char *, const char *, const char *, const char *);
 #endif
diff -r 3807518ee84c -r 0efab6185585 libexec/httpd/cgi-bozo.c
--- a/libexec/httpd/cgi-bozo.c  Thu Jun 17 18:35:45 2010 +0000
+++ b/libexec/httpd/cgi-bozo.c  Thu Jun 17 19:43:30 2010 +0000
@@ -1,6 +1,6 @@
-/*     $NetBSD: cgi-bozo.c,v 1.16 2010/05/10 14:44:19 mrg Exp $        */
+/*     $NetBSD: cgi-bozo.c,v 1.17 2010/06/17 19:43:30 mrg Exp $        */
 
-/*     $eterna: cgi-bozo.c,v 1.36 2010/05/10 14:36:37 mrg Exp $        */
+/*     $eterna: cgi-bozo.c,v 1.37 2010/06/09 07:54:16 mrg Exp $        */
 
 /*
  * Copyright (c) 1997-2010 Matthew R. Green
@@ -249,6 +249,7 @@
        const char *type, *clen, *info, *cgihandler;
        char    *query, *s, *t, *path, *env, *command, *file, *url;
        char    **envp, **curenvp, *argv[4];
+       char    *uri;
        size_t  len;
        ssize_t rbytes;
        pid_t   pid;
@@ -258,9 +259,14 @@
        if (!httpd->cgibin && !httpd->process_cgi)
                return 0;
 
-       asprintf(&file, "/%s", request->hr_file);
+       uri = request->hr_oldfile ? request->hr_oldfile : request->hr_file;
+       if (uri[0] == '/')
+               file = bozostrdup(httpd, uri);
+       else
+               asprintf(&file, "/%s", uri);
        if (file == NULL)
                return 0;
+
        if (request->hr_query && strlen(request->hr_query))
                query = bozostrdup(httpd, request->hr_query);
        else
@@ -382,7 +388,7 @@
        bozo_setenv(httpd, "SCRIPT_FILENAME", file + 1, curenvp++);
        bozo_setenv(httpd, "SERVER_SOFTWARE", httpd->server_software,
                        curenvp++);
-       bozo_setenv(httpd, "REQUEST_URI", request->hr_file, curenvp++);
+       bozo_setenv(httpd, "REQUEST_URI", uri, curenvp++);



Home | Main Index | Thread Index | Old Index