NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/38466: cvsweb does not work with httpd



Well, supporting configurations such as "-C .sh /bin/sh -x index.sh"
might be useful for some sites.  I use the attached patch which appends
the `index.html' name to the URL <http://example.com/cgi-bin/>, but not
to <http://example.com/cgi-bin/script/info/>.  The patch doesn't change
the current behaviour for CGI scripts outside the `cgibin' directory,
since bozohttpd doesn't provide PATH_INFO to those anyway.
Index: cgi-bozo.c
===================================================================
RCS file: /cvsroot/src/libexec/httpd/cgi-bozo.c,v
retrieving revision 1.7
diff -u -r1.7 cgi-bozo.c
--- cgi-bozo.c  3 Mar 2008 22:15:09 -0000       1.7
+++ cgi-bozo.c  3 May 2008 13:45:08 -0000
@@ -60,6 +60,7 @@
 static const char *    content_cgihandler(http_req *, const char *);
 static void            finish_cgi_output(http_req *request, int, int);
 static int             parse_header(const char *, ssize_t, char **, char **);
+static void            append_index_html(char **);
 
 void
 set_cgibin(char *path)
@@ -118,16 +119,12 @@
        info = NULL;
 
        len = strlen(url);
-       if (len == 0 || url[len - 1] == '/') {  /* append index.html */
-               debug((DEBUG_FAT, "appending index.html"));
-               url = bozorealloc(url, len + strlen(index_html) + 1);
-               strcat(url, index_html);
-               debug((DEBUG_NORMAL, "process_cgi: url adjusted to `%s'", url));
-       }
 
        auth_check(request, url + 1);
 
        if (!cgibin || strncmp(url + 1, CGIBIN_PREFIX, CGIBIN_PREFIX_LEN) != 0) 
{
+               if (len == 0 || url[len - 1] == '/')
+                       append_index_html(&url);
                cgihandler = content_cgihandler(request, url + 1);
                if (cgihandler == NULL) {
                        free(url);
@@ -135,7 +132,8 @@
                }
                debug((DEBUG_NORMAL, "process_cgi: cgihandler `%s'",
                    cgihandler));
-       }
+       } else if (len - 1 == CGIBIN_PREFIX_LEN)        /* url is "/cgi-bin/" */
+               append_index_html(&url);
 
        ix = 0;
        if (cgihandler) {
@@ -430,6 +428,15 @@
        return (NULL);
 }
 
+static void
+append_index_html(char **url)
+{
+       debug((DEBUG_FAT, "appending index.html"));
+       *url = bozorealloc(*url, strlen(*url) + strlen(index_html) + 1);
+       strcat(*url, index_html);
+       debug((DEBUG_NORMAL, "append_index_html: url adjusted to `%s'", *url));
+}
+
 #ifndef NO_DYNAMIC_CONTENT
 /* cgi maps are simple ".postfix /path/to/prog" */
 void


Home | Main Index | Thread Index | Old Index