diff options
author | Steven Barth <steven@midlink.org> | 2008-06-12 08:25:36 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-06-12 08:25:36 +0000 |
commit | b8430dcff704319f01279f1c399af4faf9cb9cb2 (patch) | |
tree | 64f669c5fd398490367c099e3dcafd06b6ab353f /libs/sgi-webuci/boa-patches/200-plugin_api.patch | |
parent | e6cf26b8eeb622ddb8fac942c823630341608128 (diff) |
Readded unfindes Boa 0.94.14rc21
Diffstat (limited to 'libs/sgi-webuci/boa-patches/200-plugin_api.patch')
-rw-r--r-- | libs/sgi-webuci/boa-patches/200-plugin_api.patch | 253 |
1 files changed, 137 insertions, 116 deletions
diff --git a/libs/sgi-webuci/boa-patches/200-plugin_api.patch b/libs/sgi-webuci/boa-patches/200-plugin_api.patch index de79991592..78933da68f 100644 --- a/libs/sgi-webuci/boa-patches/200-plugin_api.patch +++ b/libs/sgi-webuci/boa-patches/200-plugin_api.patch @@ -1,7 +1,7 @@ -Index: boa-0.94.13/src/list.h +Index: boa-0.94.14rc21/src/list.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ boa-0.94.13/src/list.h 2008-05-27 19:28:21.000000000 +0200 ++++ boa-0.94.14rc21/src/list.h 2008-06-11 10:25:04.000000000 +0200 @@ -0,0 +1,601 @@ +#ifndef _LINUX_LIST_H +#define _LINUX_LIST_H @@ -604,11 +604,11 @@ Index: boa-0.94.13/src/list.h + pos = n) + +#endif -Index: boa-0.94.13/src/plugin.c +Index: boa-0.94.14rc21/src/plugin.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ boa-0.94.13/src/plugin.c 2008-05-27 19:28:21.000000000 +0200 -@@ -0,0 +1,189 @@ ++++ boa-0.94.14rc21/src/plugin.c 2008-06-11 10:25:04.000000000 +0200 +@@ -0,0 +1,198 @@ +/* + * Simple plugin API for boa + * Copyright (C) 2008 John Crispin <blogic@openwrt.org> @@ -670,7 +670,17 @@ Index: boa-0.94.13/src/plugin.c + break; + } + ctx.server_addr = req->local_ip_addr; -+ ctx.server_proto = req->http_version; ++ switch (req->http_version) { ++ case HTTP09: ++ ctx.server_proto = "HTTP/0.9"; ++ break; ++ case HTTP10: ++ ctx.server_proto = "HTTP/1.0"; ++ break; ++ case HTTP11: ++ ctx.server_proto = "HTTP/1.1"; ++ break; ++ } + ctx.query_string = req->query_string; + ctx.remote_addr = req->remote_ip_addr; + ctx.remote_port = req->remote_port; @@ -691,19 +701,19 @@ Index: boa-0.94.13/src/plugin.c + + switch(child_pid) { + case -1: -+ log_error_time(); ++ log_error_doc(req); + perror("fork"); + send_r_error(req); + return 0; + + case 0: + if (dup2(req->fd, STDOUT_FILENO) == -1) { -+ log_error_time(); ++ log_error_doc(req); + perror("dup2 - fd"); + _exit(1); + } + if (set_block_fd(req->fd) == -1) { -+ log_error_time(); ++ log_error_doc(req); + perror("cgi-fcntl"); + _exit(1); + } @@ -713,7 +723,6 @@ Index: boa-0.94.13/src/plugin.c + close(req->post_data_fd); + set_block_fd(STDIN_FILENO); + } -+ close_access_log(); + + if (cgi_log_fd) + dup2(cgi_log_fd, STDERR_FILENO); @@ -798,11 +807,11 @@ Index: boa-0.94.13/src/plugin.c +} + + -Index: boa-0.94.13/src/request.c +Index: boa-0.94.14rc21/src/request.c =================================================================== ---- boa-0.94.13.orig/src/request.c 2002-07-24 05:03:59.000000000 +0200 -+++ boa-0.94.13/src/request.c 2008-05-27 19:28:21.000000000 +0200 -@@ -50,6 +50,7 @@ +--- boa-0.94.14rc21.orig/src/request.c 2005-02-22 15:11:29.000000000 +0100 ++++ boa-0.94.14rc21/src/request.c 2008-06-11 10:25:04.000000000 +0200 +@@ -59,6 +59,7 @@ dequeue(&request_free, request_free); /* dequeue the head */ } else { req = (request *) malloc(sizeof (request)); @@ -810,105 +819,116 @@ Index: boa-0.94.13/src/request.c if (!req) { log_error_time(); perror("malloc for new request"); -@@ -603,6 +604,8 @@ +@@ -793,6 +794,8 @@ int process_header_end(request * req) { + int ret; + if (!req->logline) { - send_r_error(req); - return 0; -@@ -630,11 +633,26 @@ + log_error_doc(req); + fputs("No logline in process_header_end\n", stderr); +@@ -855,19 +858,35 @@ } if (req->method == M_POST) { - req->post_data_fd = create_temporary_file(1, NULL, 0); -- if (req->post_data_fd == 0) -- return(0); -- return(1); /* success */ -- } -+ if (!req->plugin) { -+ req->post_data_fd = create_temporary_file(1, NULL, 0); -+ } else { -+ int fd[2]; -+ if (pipe(&fd[0]) != -1) { -+ req->post_data_fd = fd[1]; -+ req->read_data_fd = fd[0]; -+ set_nonblock_fd(req->post_data_fd); -+ } -+ } -+ if (req->post_data_fd == 0) { -+ return(0); -+ } -+ if (!req->plugin) -+ return(1); /* success */ ++ if (!req->plugin) { ++ req->post_data_fd = create_temporary_file(1, NULL, 0); ++ } else { ++ int fd[2]; ++ if (pipe(&fd[0]) != -1) { ++ req->post_data_fd = fd[1]; ++ req->read_data_fd = fd[0]; ++ set_nonblock_fd(req->post_data_fd); ++ } ++ } + if (req->post_data_fd == 0) { + /* errors already logged */ + send_r_error(req); + return 0; + } +- if (fcntl(req->post_data_fd, F_SETFD, 1) == -1) { +- boa_perror(req, "unable to set close-on-exec for req->post_data_fd!"); +- close(req->post_data_fd); +- req->post_data_fd = 0; +- return 0; ++ if (!req->plugin) { ++ if (fcntl(req->post_data_fd, F_SETFD, 1) == -1) { ++ boa_perror(req, "unable to set close-on-exec for req->post_data_fd!"); ++ close(req->post_data_fd); ++ req->post_data_fd = 0; ++ return 0; ++ } ++ return(1); /* success */ + } +- return 1; /* success */ + } + -+ ret = plugin_handle(req); -+ if (ret) -+ return ret; ++ ret = plugin_handle(req); ++ if (ret) { ++ return ret; + } - if (req->is_cgi) { - return init_cgi(req); -Index: boa-0.94.13/src/Makefile.in + if (req->cgi_type) { +Index: boa-0.94.14rc21/src/Makefile.in =================================================================== ---- boa-0.94.13.orig/src/Makefile.in 2002-03-24 23:20:19.000000000 +0100 -+++ boa-0.94.13/src/Makefile.in 2008-05-27 19:28:21.000000000 +0200 -@@ -20,7 +20,7 @@ +--- boa-0.94.14rc21.orig/src/Makefile.in 2005-02-22 04:02:40.000000000 +0100 ++++ boa-0.94.14rc21/src/Makefile.in 2008-06-11 10:25:04.000000000 +0200 +@@ -15,7 +15,7 @@ srcdir = @srcdir@ VPATH = @srcdir@:@srcdir@/../extras LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ +LIBS = @LIBS@ -ldl - CFLAGS = @CFLAGS@ -I. - - # Change these if necessary -@@ -32,7 +32,8 @@ - + CFLAGS = @CFLAGS@ + CPPFLAGS = @CPPFLAGS@ -I@srcdir@ -I. + @ifGNUmake@DEPEND = .depend +@@ -26,6 +26,7 @@ SOURCES = alias.c boa.c buffer.c cgi.c cgi_header.c config.c escape.c \ - get.c hash.c ip.c log.c mmap_cache.c pipe.c queue.c read.c \ -- request.c response.c select.c signals.c util.c sublog.c -+ request.c response.c select.c signals.c util.c sublog.c \ -+ plugin.c - - OBJS = y.tab.o lex.yy.o $(SOURCES:.c=.o) timestamp.o @STRUTIL@ + get.c hash.c ip.c log.c mmap_cache.c pipe.c queue.c range.c \ + read.c request.c response.c signals.c util.c sublog.c \ ++ plugin.c \ + @ASYNCIO_SOURCE@ @ACCESSCONTROL_SOURCE@ -Index: boa-0.94.13/src/boa.h + OBJS = $(SOURCES:.c=.o) timestamp.o @STRUTIL@ +Index: boa-0.94.14rc21/src/boa.h =================================================================== ---- boa-0.94.13.orig/src/boa.h 2002-07-26 05:03:44.000000000 +0200 -+++ boa-0.94.13/src/boa.h 2008-05-27 19:28:21.000000000 +0200 -@@ -37,6 +37,7 @@ +--- boa-0.94.14rc21.orig/src/boa.h 2005-02-22 15:11:29.000000000 +0100 ++++ boa-0.94.14rc21/src/boa.h 2008-06-11 10:25:04.000000000 +0200 +@@ -38,6 +38,7 @@ #include <fcntl.h> #include <limits.h> /* OPEN_MAX */ #include <setjmp.h> +#include <stdbool.h> - #include <netdb.h> #include <netinet/in.h> -@@ -50,6 +51,7 @@ + +@@ -49,6 +50,7 @@ #include "compat.h" /* oh what fun is porting */ #include "defines.h" #include "globals.h" +#include "boa-plugin.h" /* alias */ - void add_alias(char *fakename, char *realname, int script); -@@ -192,4 +194,9 @@ - /* select */ - void select_loop(int server_s); - + void add_alias(const char *fakename, const char *realname, enum ALIAS type); +@@ -225,5 +227,10 @@ + void range_pool_push(Range * r); + int ranges_fixup(request * req); + int range_parse(request * req, const char *str); +- ++ +/* plugins */ +int plugin_init(char *path); +int plugin_handle(request * req); +struct httpd_plugin *plugin_lookup(request *req); + #endif -Index: boa-0.94.13/src/config.c +Index: boa-0.94.14rc21/src/config.c =================================================================== ---- boa-0.94.13.orig/src/config.c 2002-07-26 05:04:29.000000000 +0200 -+++ boa-0.94.13/src/config.c 2008-05-27 19:28:21.000000000 +0200 -@@ -61,6 +61,7 @@ +--- boa-0.94.14rc21.orig/src/config.c 2005-02-22 15:11:29.000000000 +0100 ++++ boa-0.94.14rc21/src/config.c 2008-06-11 10:25:04.000000000 +0200 +@@ -64,6 +64,7 @@ char *error_log_name; char *access_log_name; char *cgi_log_name; @@ -916,17 +936,17 @@ Index: boa-0.94.13/src/config.c int use_localtime; -@@ -116,6 +117,7 @@ - {"SinglePostLimit", S1A, c_set_int, &single_post_limit}, - {"CGIPath", S1A, c_set_string, &cgi_path}, - {"MaxConnections", S1A, c_set_int, &max_connections}, +@@ -165,6 +166,7 @@ + {"CGINice", S2A, c_set_int, &cgi_nice}, + #endif + {"CGIEnv", S2A, c_add_cgi_env, NULL}, + {"PluginRoot", S1A, c_set_string, &plugin_root}, }; - static void c_set_user(char *v1, char *v2, void *t) -@@ -323,6 +325,22 @@ - free(dirmaker); - dirmaker = temp; + static void c_add_cgi_env(char *v1, char *v2, void *t) +@@ -544,6 +546,22 @@ + single_post_limit); + exit(EXIT_FAILURE); } + if (plugin_root) { + char *plugin_path = plugin_root; @@ -939,69 +959,70 @@ Index: boa-0.94.13/src/config.c + next++; + } + -+ plugin_init(normalize_path(plugin_path)); ++ plugin_init(plugin_path); + plugin_path = next; + } while (plugin_path); + free(plugin_root); + } - #if 0 - if (mime_types) { -Index: boa-0.94.13/src/alias.c + if (vhost_root && virtualhost) { + fprintf(stderr, "Both VHostRoot and VirtualHost were enabled, and " +Index: boa-0.94.14rc21/src/alias.c =================================================================== ---- boa-0.94.13.orig/src/alias.c 2002-07-28 04:46:52.000000000 +0200 -+++ boa-0.94.13/src/alias.c 2008-05-27 19:28:21.000000000 +0200 -@@ -213,6 +213,7 @@ - uri_len = strlen(req->request_uri); +--- boa-0.94.14rc21.orig/src/alias.c 2005-02-22 15:11:29.000000000 +0100 ++++ boa-0.94.14rc21/src/alias.c 2008-06-11 10:25:04.000000000 +0200 +@@ -246,6 +246,7 @@ + uri_len = strlen(req->request_uri); current = find_alias(req->request_uri, uri_len); + req->plugin = !!plugin_lookup(req); if (current) { - if (current->type == SCRIPTALIAS) /* Script */ -@@ -237,7 +238,7 @@ - } + return init_script_alias(req, current, uri_len); +@@ -263,7 +264,7 @@ + uri_len - current->fake_len + 1); if (current->type == REDIRECT) { /* Redirect */ - if (req->method == M_POST) { /* POST to non-script */ + if ((req->method == M_POST) && !req->plugin) { /* POST to non-script */ /* it's not a cgi, but we try to POST??? */ - send_r_bad_request(req); - return 0; /* not a script alias, therefore begin filling in data */ -@@ -361,7 +362,7 @@ + log_error_doc(req); + fputs("POST to non-script is disallowed.\n", stderr); +@@ -432,7 +433,7 @@ else - req->is_cgi = CGI; + req->cgi_type = CGI; return 1; - } else if (req->method == M_POST) { /* POST to non-script */ + } else if ((req->method == M_POST) && !req->plugin) { /* POST to non-script */ /* it's not a cgi, but we try to POST??? */ - send_r_bad_request(req); - return 0; -Index: boa-0.94.13/src/globals.h + log_error_doc(req); + fputs("POST to non-script disallowed.\n", stderr); +Index: boa-0.94.14rc21/src/globals.h =================================================================== ---- boa-0.94.13.orig/src/globals.h 2002-07-24 05:03:59.000000000 +0200 -+++ boa-0.94.13/src/globals.h 2008-05-27 19:28:21.000000000 +0200 -@@ -47,6 +47,7 @@ - struct request { /* pending requests */ - int fd; /* client's socket fd */ - int status; /* see #defines.h */ -+ bool plugin; - time_t time_last; /* time of last succ. op. */ - char *pathname; /* pathname of requested file */ - int simple; /* simple request? */ -@@ -92,6 +93,7 @@ - char *header_referer; +--- boa-0.94.14rc21.orig/src/globals.h 2005-02-22 15:11:29.000000000 +0100 ++++ boa-0.94.14rc21/src/globals.h 2008-06-11 10:25:04.000000000 +0200 +@@ -158,6 +158,7 @@ + char *host; /* what we end up using for 'host', no matter the contents of header_host */ int post_data_fd; /* fd for post data tmpfile */ + int read_data_fd; /* fd for post data input (plugin) */ char *path_info; /* env variable */ char *path_translated; /* env variable */ -Index: boa-0.94.13/src/read.c +@@ -193,6 +194,8 @@ + char accept[MAX_ACCEPT_LENGTH]; /* Accept: fields */ + #endif + ++ bool plugin; ++ + struct request *next; /* next */ + struct request *prev; /* previous */ + }; +Index: boa-0.94.14rc21/src/read.c =================================================================== ---- boa-0.94.13.orig/src/read.c 2002-03-18 02:53:48.000000000 +0100 -+++ boa-0.94.13/src/read.c 2008-05-27 19:28:21.000000000 +0200 -@@ -338,8 +338,11 @@ +--- boa-0.94.14rc21.orig/src/read.c 2005-02-23 16:41:55.000000000 +0100 ++++ boa-0.94.14rc21/src/read.c 2008-06-11 10:25:04.000000000 +0200 +@@ -375,8 +375,11 @@ if (bytes_to_write == 0) { /* nothing left in buffer to write */ req->header_line = req->header_end = req->buffer; @@ -1015,10 +1036,10 @@ Index: boa-0.94.13/src/read.c /* if here, we can safely assume that there is more to read */ req->status = BODY_READ; return 1; -Index: boa-0.94.13/src/boa-plugin.h +Index: boa-0.94.14rc21/src/boa-plugin.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ boa-0.94.13/src/boa-plugin.h 2008-05-27 19:28:21.000000000 +0200 ++++ boa-0.94.14rc21/src/boa-plugin.h 2008-06-11 10:25:04.000000000 +0200 @@ -0,0 +1,67 @@ +#ifndef _HTTPD_PLUGIN_H__ +#define _HTTPD_PLUGIN_H__ |