X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=libs%2Fsgi-webuci%2Fboa-patches%2F200-plugin_api.patch;h=de79991592aed6a676ed1eb77f87e7984daa2cf6;hp=78933da68f9066459cb594ff4c4a13504861d0f1;hb=d8e5e32ad8af6f49a10dc0fe18c9c2327f924dcd;hpb=0ce532556c304c370a0e2511567e499ea8d5342f diff --git a/libs/sgi-webuci/boa-patches/200-plugin_api.patch b/libs/sgi-webuci/boa-patches/200-plugin_api.patch index 78933da68..de7999159 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.14rc21/src/list.h +Index: boa-0.94.13/src/list.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ boa-0.94.14rc21/src/list.h 2008-06-11 10:25:04.000000000 +0200 ++++ boa-0.94.13/src/list.h 2008-05-27 19:28:21.000000000 +0200 @@ -0,0 +1,601 @@ +#ifndef _LINUX_LIST_H +#define _LINUX_LIST_H @@ -604,11 +604,11 @@ Index: boa-0.94.14rc21/src/list.h + pos = n) + +#endif -Index: boa-0.94.14rc21/src/plugin.c +Index: boa-0.94.13/src/plugin.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ boa-0.94.14rc21/src/plugin.c 2008-06-11 10:25:04.000000000 +0200 -@@ -0,0 +1,198 @@ ++++ boa-0.94.13/src/plugin.c 2008-05-27 19:28:21.000000000 +0200 +@@ -0,0 +1,189 @@ +/* + * Simple plugin API for boa + * Copyright (C) 2008 John Crispin @@ -670,17 +670,7 @@ Index: boa-0.94.14rc21/src/plugin.c + break; + } + ctx.server_addr = req->local_ip_addr; -+ 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.server_proto = req->http_version; + ctx.query_string = req->query_string; + ctx.remote_addr = req->remote_ip_addr; + ctx.remote_port = req->remote_port; @@ -701,19 +691,19 @@ Index: boa-0.94.14rc21/src/plugin.c + + switch(child_pid) { + case -1: -+ log_error_doc(req); ++ log_error_time(); + perror("fork"); + send_r_error(req); + return 0; + + case 0: + if (dup2(req->fd, STDOUT_FILENO) == -1) { -+ log_error_doc(req); ++ log_error_time(); + perror("dup2 - fd"); + _exit(1); + } + if (set_block_fd(req->fd) == -1) { -+ log_error_doc(req); ++ log_error_time(); + perror("cgi-fcntl"); + _exit(1); + } @@ -723,6 +713,7 @@ Index: boa-0.94.14rc21/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); @@ -807,11 +798,11 @@ Index: boa-0.94.14rc21/src/plugin.c +} + + -Index: boa-0.94.14rc21/src/request.c +Index: boa-0.94.13/src/request.c =================================================================== ---- 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 @@ +--- 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 @@ dequeue(&request_free, request_free); /* dequeue the head */ } else { req = (request *) malloc(sizeof (request)); @@ -819,116 +810,105 @@ Index: boa-0.94.14rc21/src/request.c if (!req) { log_error_time(); perror("malloc for new request"); -@@ -793,6 +794,8 @@ +@@ -603,6 +604,8 @@ int process_header_end(request * req) { + int ret; + if (!req->logline) { - log_error_doc(req); - fputs("No logline in process_header_end\n", stderr); -@@ -855,19 +858,35 @@ + send_r_error(req); + return 0; +@@ -630,11 +633,26 @@ } if (req->method == M_POST) { - req->post_data_fd = create_temporary_file(1, NULL, 0); -+ 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 */ +- 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 */ + } + -+ ret = plugin_handle(req); -+ if (ret) { -+ return ret; - } ++ ret = plugin_handle(req); ++ if (ret) ++ return ret; - if (req->cgi_type) { -Index: boa-0.94.14rc21/src/Makefile.in + if (req->is_cgi) { + return init_cgi(req); +Index: boa-0.94.13/src/Makefile.in =================================================================== ---- 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 @@ +--- 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 @@ srcdir = @srcdir@ VPATH = @srcdir@:@srcdir@/../extras LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ +LIBS = @LIBS@ -ldl - CFLAGS = @CFLAGS@ - CPPFLAGS = @CPPFLAGS@ -I@srcdir@ -I. - @ifGNUmake@DEPEND = .depend -@@ -26,6 +26,7 @@ + CFLAGS = @CFLAGS@ -I. + + # Change these if necessary +@@ -32,7 +32,8 @@ + 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 range.c \ - read.c request.c response.c signals.c util.c sublog.c \ -+ plugin.c \ - @ASYNCIO_SOURCE@ @ACCESSCONTROL_SOURCE@ + 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@ - OBJS = $(SOURCES:.c=.o) timestamp.o @STRUTIL@ -Index: boa-0.94.14rc21/src/boa.h +Index: boa-0.94.13/src/boa.h =================================================================== ---- 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 @@ +--- 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 @@ #include #include /* OPEN_MAX */ #include +#include + #include #include - -@@ -49,6 +50,7 @@ +@@ -50,6 +51,7 @@ #include "compat.h" /* oh what fun is porting */ #include "defines.h" #include "globals.h" +#include "boa-plugin.h" /* alias */ - 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); -- -+ + void add_alias(char *fakename, char *realname, int script); +@@ -192,4 +194,9 @@ + /* select */ + void select_loop(int server_s); + +/* plugins */ +int plugin_init(char *path); +int plugin_handle(request * req); +struct httpd_plugin *plugin_lookup(request *req); + #endif -Index: boa-0.94.14rc21/src/config.c +Index: boa-0.94.13/src/config.c =================================================================== ---- 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 @@ +--- 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 @@ char *error_log_name; char *access_log_name; char *cgi_log_name; @@ -936,17 +916,17 @@ Index: boa-0.94.14rc21/src/config.c int use_localtime; -@@ -165,6 +166,7 @@ - {"CGINice", S2A, c_set_int, &cgi_nice}, - #endif - {"CGIEnv", S2A, c_add_cgi_env, NULL}, +@@ -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}, + {"PluginRoot", S1A, c_set_string, &plugin_root}, }; - static void c_add_cgi_env(char *v1, char *v2, void *t) -@@ -544,6 +546,22 @@ - single_post_limit); - exit(EXIT_FAILURE); + static void c_set_user(char *v1, char *v2, void *t) +@@ -323,6 +325,22 @@ + free(dirmaker); + dirmaker = temp; } + if (plugin_root) { + char *plugin_path = plugin_root; @@ -959,70 +939,69 @@ Index: boa-0.94.14rc21/src/config.c + next++; + } + -+ plugin_init(plugin_path); ++ plugin_init(normalize_path(plugin_path)); + plugin_path = next; + } while (plugin_path); + free(plugin_root); + } - if (vhost_root && virtualhost) { - fprintf(stderr, "Both VHostRoot and VirtualHost were enabled, and " -Index: boa-0.94.14rc21/src/alias.c + #if 0 + if (mime_types) { +Index: boa-0.94.13/src/alias.c =================================================================== ---- 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 @@ - +--- 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); + current = find_alias(req->request_uri, uri_len); + req->plugin = !!plugin_lookup(req); if (current) { + if (current->type == SCRIPTALIAS) /* Script */ - return init_script_alias(req, current, uri_len); -@@ -263,7 +264,7 @@ - uri_len - current->fake_len + 1); +@@ -237,7 +238,7 @@ + } 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??? */ - log_error_doc(req); - fputs("POST to non-script is disallowed.\n", stderr); -@@ -432,7 +433,7 @@ + send_r_bad_request(req); + return 0; /* not a script alias, therefore begin filling in data */ +@@ -361,7 +362,7 @@ else - req->cgi_type = CGI; + req->is_cgi = 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??? */ - log_error_doc(req); - fputs("POST to non-script disallowed.\n", stderr); -Index: boa-0.94.14rc21/src/globals.h + send_r_bad_request(req); + return 0; +Index: boa-0.94.13/src/globals.h =================================================================== ---- 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 */ +--- 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; 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 */ -@@ -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 +Index: boa-0.94.13/src/read.c =================================================================== ---- 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 @@ +--- 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 @@ if (bytes_to_write == 0) { /* nothing left in buffer to write */ req->header_line = req->header_end = req->buffer; @@ -1036,10 +1015,10 @@ Index: boa-0.94.14rc21/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.14rc21/src/boa-plugin.h +Index: boa-0.94.13/src/boa-plugin.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ boa-0.94.14rc21/src/boa-plugin.h 2008-06-11 10:25:04.000000000 +0200 ++++ boa-0.94.13/src/boa-plugin.h 2008-05-27 19:28:21.000000000 +0200 @@ -0,0 +1,67 @@ +#ifndef _HTTPD_PLUGIN_H__ +#define _HTTPD_PLUGIN_H__