
cherokee at cherokee-project
Nov 16, 2009, 6:33 AM
Post #1 of 1
(83 views)
Permalink
|
|
[3829] cherokee/trunk: Removes the previously deprecated phpcgi handler.
|
|
Revision: 3829 http://svn.cherokee-project.com/changeset/3829 Author: alo Date: 2009-11-16 15:33:28 +0100 (Mon, 16 Nov 2009) Log Message: ----------- Removes the previously deprecated phpcgi handler. Modified Paths: -------------- cherokee/trunk/cherokee/Makefile.am cherokee/trunk/cherokee/handler_cgi.c cherokee/trunk/cherokee/handler_cgi_base.c cherokee/trunk/cherokee/handler_cgi_base.h cherokee/trunk/configure.in Removed Paths: ------------- cherokee/trunk/cherokee/handler_phpcgi.c cherokee/trunk/cherokee/handler_phpcgi.h cherokee/trunk/cherokee/phpcgi.deps Modified: cherokee/trunk/cherokee/Makefile.am =================================================================== --- cherokee/trunk/cherokee/Makefile.am 2009-11-16 14:00:47 UTC (rev 3828) +++ cherokee/trunk/cherokee/Makefile.am 2009-11-16 14:33:28 UTC (rev 3829) @@ -17,7 +17,6 @@ common.deps \ combined.deps \ error_redir.deps \ -phpcgi.deps \ scgi.deps \ fcgi.deps \ uwsgi.deps \ @@ -627,28 +626,6 @@ # -# Handler phpcgi -# -handler_phpcgi = \ -handler_phpcgi.c \ -handler_phpcgi.h - -if PLATFORM_WIN32 -phpcgi_ldflags_win32 = -lplugin_cgi -endif - -libplugin_phpcgi_la_LDFLAGS = $(module_ldflags) $(phpcgi_ldflags_win32) -libplugin_phpcgi_la_SOURCES = $(handler_phpcgi) -libplugin_phpcgi_la_LIBADD = $(dynamic_handler_file_lib) - -if STATIC_HANDLER_PHPCGI -static_handler_phpcgi_src = $(handler_phpcgi) -else -dynamic_handler_phpcgi_lib = libplugin_phpcgi.la -endif - - -# # Handler redir # handler_redir = \ @@ -1471,7 +1448,6 @@ $(static_handler_error_redir_src) \ $(static_handler_error_nn_src) \ $(static_handler_cgi_src) \ -$(static_handler_phpcgi_src) \ $(static_handler_common_src) \ $(static_handler_proxy_src) \ $(static_handler_ssi_src) \ @@ -1645,7 +1621,6 @@ $(dynamic_gen_evhost_lib) \ $(dynamic_handler_file_lib) \ $(dynamic_handler_cgi_lib) \ -$(dynamic_handler_phpcgi_lib) \ $(dynamic_handler_server_info_lib) \ $(dynamic_handler_render_rrd_lib) \ $(dynamic_handler_admin_lib) \ Modified: cherokee/trunk/cherokee/handler_cgi.c =================================================================== --- cherokee/trunk/cherokee/handler_cgi.c 2009-11-16 14:00:47 UTC (rev 3828) +++ cherokee/trunk/cherokee/handler_cgi.c 2009-11-16 14:33:28 UTC (rev 3829) @@ -511,7 +511,7 @@ cherokee_connection_t *conn = HANDLER_CONN(cgi); cherokee_handler_cgi_base_t *cgi_base = HDL_CGI_BASE(cgi); char *absolute_path = cgi_base->executable.buf; - char *argv[4] = { NULL, NULL, NULL, NULL }; + char *argv[2] = { NULL, NULL }; #ifdef TRACE_ENABLED TRACE(ENTRIES, "About to execute: '%s'\n", absolute_path); @@ -596,16 +596,8 @@ /* Build de argv array */ + script = absolute_path; argv[0] = absolute_path; - - if (cgi_base->param.len > 0) { - argv[1] = cgi_base->param.buf; - argv[2] = cgi_base->param_extra.buf; - script = cgi_base->param.buf; - } else { - argv[1] = cgi_base->param_extra.buf; - script = absolute_path; - } /* Change the execution user? */ @@ -765,7 +757,7 @@ */ cmd = HDL_CGI_BASE(cgi)->executable.buf; cherokee_buffer_add (&cmd_line, cmd, strlen(cmd)); - cherokee_buffer_add_va (&cmd_line, " \"%s\"", HDL_CGI_BASE(cgi)->param.buf); +// cherokee_buffer_add_va (&cmd_line, " \"%s\"", HDL_CGI_BASE(cgi)->param.buf); /* Execution directory */ Modified: cherokee/trunk/cherokee/handler_cgi_base.c =================================================================== --- cherokee/trunk/cherokee/handler_cgi_base.c 2009-11-16 14:00:47 UTC (rev 3828) +++ cherokee/trunk/cherokee/handler_cgi_base.c 2009-11-16 14:33:28 UTC (rev 3829) @@ -61,8 +61,6 @@ cherokee_buffer_init (&cgi->xsendfile); cherokee_buffer_init (&cgi->executable); - cherokee_buffer_init (&cgi->param); - cherokee_buffer_init (&cgi->param_extra); cherokee_buffer_init (&cgi->data); cherokee_buffer_ensure_size (&cgi->data, 2*1024); @@ -214,21 +212,10 @@ cherokee_buffer_mrproper (&cgi->executable); cherokee_buffer_mrproper (&cgi->xsendfile); - cherokee_buffer_mrproper (&cgi->param); - cherokee_buffer_mrproper (&cgi->param_extra); - return ret_ok; } -void -cherokee_handler_cgi_base_add_parameter (cherokee_handler_cgi_base_t *cgi, char *param, cuint_t param_len) -{ - cherokee_buffer_clean (&cgi->param_extra); - cherokee_buffer_add (&cgi->param_extra, param, param_len); -} - - #ifdef _WIN32 static void add_win32_systemroot_env (cherokee_handler_cgi_base_t *cgi, @@ -651,11 +638,9 @@ */ cherokee_buffer_clean (&tmp); if (cherokee_buffer_is_empty (&cgi_props->script_alias)) { - if (cgi->param.len > 0) { - name = &cgi->param; /* phpcgi */ - } else { - name = &cgi->executable; /* cgi */ - } + /* cgi */ + name = &cgi->executable; + if (conn->local_directory.len > 0){ p = name->buf + conn->local_directory.len; len = (name->buf + name->len) - p; Modified: cherokee/trunk/cherokee/handler_cgi_base.h =================================================================== --- cherokee/trunk/cherokee/handler_cgi_base.h 2009-11-16 14:00:47 UTC (rev 3828) +++ cherokee/trunk/cherokee/handler_cgi_base.h 2009-11-16 14:33:28 UTC (rev 3829) @@ -75,15 +75,12 @@ */ cherokee_handler_cgi_base_phase_t init_phase; cuint_t got_eof; - char *extra_param; size_t content_length; cherokee_buffer_t xsendfile; void *file_handler; - cherokee_buffer_t param; - cherokee_buffer_t param_extra; cherokee_buffer_t executable; cherokee_buffer_t data; @@ -127,7 +124,6 @@ ret_t cherokee_handler_cgi_base_add_headers (cherokee_handler_cgi_base_t *cgi, cherokee_buffer_t *buffer); ret_t cherokee_handler_cgi_base_step (cherokee_handler_cgi_base_t *cgi, cherokee_buffer_t *buffer); -void cherokee_handler_cgi_base_add_parameter (cherokee_handler_cgi_base_t *cgi, char *name, cuint_t len); ret_t cherokee_handler_cgi_base_extract_path (cherokee_handler_cgi_base_t *cgi, cherokee_boolean_t check_filename); ret_t cherokee_handler_cgi_base_split_pathinfo (cherokee_handler_cgi_base_t *cgi, cherokee_buffer_t *buf, Deleted: cherokee/trunk/cherokee/handler_phpcgi.c =================================================================== --- cherokee/trunk/cherokee/handler_phpcgi.c 2009-11-16 14:00:47 UTC (rev 3828) +++ cherokee/trunk/cherokee/handler_phpcgi.c 2009-11-16 14:33:28 UTC (rev 3829) @@ -1,276 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* Cherokee - * - * Authors: - * Alvaro Lopez Ortega <alvaro [at] alobbs> - * - * Copyright (C) 2001-2009 Alvaro Lopez Ortega - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -/* Mini-Howto compile PHP5: - * - * $ ./configure ./configure --with-mysql=/usr/include/mysql/ --with-mysql-sock=/var/run/mysqld/mysqld.sock && make - * $ sudo cp sapi/cgi/php /usr/lib/cgi-bin/php5 - */ - -#include "common-internal.h" -#include "handler_phpcgi.h" - -#ifdef HAVE_SYS_TYPES_H -# include <sys/types.h> -#endif - -#ifdef HAVE_SYS_STAT_H -# include <sys/stat.h> -#endif - -#ifdef HAVE_UNISTD_H -# include <unistd.h> -#endif - -#ifdef HAVE_STDLIB_H -# include <stdlib.h> -#endif - -#include "module.h" -#include "plugin_loader.h" -#include "handler_cgi.h" -#include "connection.h" -#include "connection-protected.h" - - -static char *php_paths[] = { -#ifndef _WIN32 - "/usr/lib/cgi-bin/", - "/usr/local/bin/", - "/usr/bin/", -#else - "C:/PHP/", -#endif - NULL -}; - -static char *php_names[] = { -#ifndef _WIN32 - "php-cgi", - "php", - "php5", - "php4", - "php-cgi", -#else - "PHP.EXE", -#endif - NULL -}; - - -/* Plugin initialization - */ -PLUGIN_INFO_HANDLER_EASY_INIT (phpcgi, http_get | http_post | http_head); - - -static ret_t -check_interpreter (char *path) -{ - int re; - - /* Sanity check - */ - if (path == NULL) - return ret_not_found; - - /* Check for the PHP executable - */ - re = access (path, R_OK | X_OK); - if (re != 0) { - return ret_not_found; - } - - return ret_ok; -} - - -static ret_t -search_php_executable (char **ret_path) -{ - cuint_t npath; - cuint_t nname; - cherokee_buffer_t tmppath = CHEROKEE_BUF_INIT; - - for (npath = 0; php_paths[npath]; npath++) { - for (nname = 0; php_names[nname]; nname++) { - int re; - - cherokee_buffer_add_va (&tmppath, "%s%s", php_paths[npath], php_names[nname]); - re = access (tmppath.buf, R_OK | X_OK); - - if (re == 0) { - *ret_path = strdup (tmppath.buf); - goto out; - } - - cherokee_buffer_clean (&tmppath); - } - } - -out: - cherokee_buffer_mrproper (&tmppath); - return ret_ok; -} - - -ret_t -cherokee_handler_phpcgi_new (cherokee_handler_t **hdl, void *cnt, cherokee_module_props_t *props) -{ - ret_t ret; - cherokee_handler_cgi_base_t *cgi; - char *interpreter = NULL; - - /* Create the new handler CGI object - */ - ret = cherokee_handler_cgi_new (hdl, cnt, props); - if (unlikely(ret != ret_ok)) - return ret; - - cgi = HDL_CGI_BASE(*hdl); - - /* Redefine the init method - */ - MODULE(*hdl)->init = (handler_func_init_t) cherokee_handler_phpcgi_init; - - /* Look for the interpreter in the properties - */ - if (props) { - interpreter = PROP_PHPCGI(props)->interpreter.buf; - } - - if (interpreter == NULL) - search_php_executable (&interpreter); - - /* Check the interpreter - */ - if (check_interpreter(interpreter) != ret_ok) { - PRINT_ERROR ("ERROR: PHP interpreter not found (%s). Please install it.\n", - interpreter ? interpreter : ""); - return ret_error; - } - - /* Set it up in the CGI handler - */ - if (cgi->executable.len <= 0) { - cherokee_buffer_add (&cgi->executable, interpreter, strlen(interpreter)); - } - - /* If it has to fake the effective directory, set the -C paramter: - * Do not chdir to the script's directory - */ - if (!cherokee_buffer_is_empty (&CONN(cnt)->effective_directory)) { - cherokee_handler_cgi_base_add_parameter (cgi, "-C", 2); - } - - return ret_ok; -} - - -ret_t -cherokee_handler_phpcgi_init (cherokee_handler_t *hdl) -{ - cherokee_handler_cgi_base_t *cgi = HDL_CGI_BASE(hdl); - cherokee_connection_t *conn = HANDLER_CONN(hdl); - cherokee_buffer_t *ld = &conn->local_directory; - - /* Special case: - * The CGI handler could return a ret_eagain value, so the connection - * will keep trying call this funcion. The right action on this case - * is to call again the CGI handler - */ - if (cgi->init_phase != hcgi_phase_build_headers) { - return cherokee_handler_cgi_init (HDL_CGI(hdl)); - } - - /* Add parameter to CGI handler - */ - if (cgi->param.len <= 0) { - cherokee_buffer_add_buffer (&cgi->param, ld); - cherokee_buffer_add_buffer (&cgi->param, &conn->request); - cherokee_handler_cgi_base_split_pathinfo (cgi, &cgi->param, ld->len, false); - } - - cherokee_handler_cgi_add_env_pair (cgi, "REDIRECT_STATUS", 15, "200", 3); - cherokee_handler_cgi_add_env_pair (cgi, "SCRIPT_FILENAME", 15, cgi->param.buf, cgi->param.len); - - return cherokee_handler_cgi_init (HDL_CGI(hdl)); -} - - -static ret_t -props_free (cherokee_handler_phpcgi_props_t *props) -{ - cherokee_buffer_mrproper (&props->interpreter); - return cherokee_module_props_free_base (MODULE_PROPS(props)); -} - - -ret_t -cherokee_handler_phpcgi_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_module_props_t **_props) -{ - cherokee_list_t *i; - cherokee_handler_phpcgi_props_t *props; - - if (*_props == NULL) { - CHEROKEE_NEW_STRUCT(n, handler_phpcgi_props); - - cherokee_module_props_init_base (MODULE_PROPS(n), - MODULE_PROPS_FREE(props_free)); - - cherokee_buffer_init (&n->interpreter); - *_props = MODULE_PROPS(n); - } - - props = PROP_PHPCGI(*_props); - - cherokee_config_node_foreach (i, conf) { - cherokee_config_node_t *subconf = CONFIG_NODE(i); - - if (equal_buf_str (&subconf->key, "interpreter")) { - cherokee_buffer_add_buffer (&props->interpreter, &subconf->val); - } - } - - return cherokee_handler_cgi_configure (conf, srv, _props); -} - - -/* Library init function - */ -static cherokee_boolean_t _phpcgi_is_init = false; - -void -PLUGIN_INIT_NAME(phpcgi) (cherokee_plugin_loader_t *loader) -{ - /* Is init? - */ - if (_phpcgi_is_init) - return; - _phpcgi_is_init = true; - - /* Load the dependences - */ - cherokee_plugin_loader_load (loader, "cgi"); -} - Deleted: cherokee/trunk/cherokee/handler_phpcgi.h =================================================================== --- cherokee/trunk/cherokee/handler_phpcgi.h 2009-11-16 14:00:47 UTC (rev 3828) +++ cherokee/trunk/cherokee/handler_phpcgi.h 2009-11-16 14:33:28 UTC (rev 3829) @@ -1,46 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* Cherokee - * - * Authors: - * Alvaro Lopez Ortega <alvaro [at] alobbs> - * - * Copyright (C) 2001-2009 Alvaro Lopez Ortega - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef CHEROKEE_CONNECTION_HANDLER_PHPCGI_H -#define CHEROKEE_CONNECTION_HANDLER_PHPCGI_H - -#include "common-internal.h" -#include "handler_cgi.h" - -typedef struct { - cherokee_handler_cgi_props_t base; - cherokee_buffer_t interpreter; -} cherokee_handler_phpcgi_props_t; - -#define PROP_PHPCGI(x) ((cherokee_handler_phpcgi_props_t *)(x)) - - -/* Library init function - */ -void PLUGIN_INIT_NAME(phpcgi) (cherokee_plugin_loader_t *loader); - -ret_t cherokee_handler_phpcgi_new (cherokee_handler_t **hdl, void *cnt, cherokee_module_props_t *props); -ret_t cherokee_handler_phpcgi_init (cherokee_handler_t *hdl); - -#endif /* CHEROKEE_CONNECTION_HANDLER_PHPCGI_H */ Deleted: cherokee/trunk/cherokee/phpcgi.deps =================================================================== --- cherokee/trunk/cherokee/phpcgi.deps 2009-11-16 14:00:47 UTC (rev 3828) +++ cherokee/trunk/cherokee/phpcgi.deps 2009-11-16 14:33:28 UTC (rev 3829) @@ -1 +0,0 @@ -cgi Modified: cherokee/trunk/configure.in =================================================================== --- cherokee/trunk/configure.in 2009-11-16 14:00:47 UTC (rev 3828) +++ cherokee/trunk/configure.in 2009-11-16 14:33:28 UTC (rev 3829) @@ -1344,7 +1344,7 @@ AC_HELP_STRING([--enable-static-module=MODULE][]), [use_static_module="$use_static_module $enableval "],[]) -modules="error_redir error_nn server_info file admin dirlist fcgi fastcgi scgi uwsgi redir common cgi phpcgi proxy ssi secdownload empty_gif custom_error dbslayer streaming gzip deflate ncsa combined custom pam ldap mysql htpasswd plain htdigest authlist round_robin ip_hash directory extensions request header exists fullpath method from bind geoip wildcard rehost target_ip evhost libssl render_rrd rrd not and or" +modules="error_redir error_nn server_info file admin dirlist fcgi fastcgi scgi uwsgi redir common cgi proxy ssi secdownload empty_gif custom_error dbslayer streaming gzip deflate ncsa combined custom pam ldap mysql htpasswd plain htdigest authlist round_robin ip_hash directory extensions request header exists fullpath method from bind geoip wildcard rehost target_ip evhost libssl render_rrd rrd not and or" # Remove modules that will not be compiles # @@ -1412,7 +1412,6 @@ AM_CONDITIONAL(STATIC_HANDLER_ERROR_NN, grep error_nn $conf_h >/dev/null) AM_CONDITIONAL(STATIC_HANDLER_COMMON, grep common $conf_h >/dev/null) AM_CONDITIONAL(STATIC_HANDLER_CGI, grep cgi $conf_h >/dev/null) -AM_CONDITIONAL(STATIC_HANDLER_PHPCGI, grep phpcgi $conf_h >/dev/null) AM_CONDITIONAL(STATIC_HANDLER_PROXY, grep proxy $conf_h >/dev/null) AM_CONDITIONAL(STATIC_HANDLER_SSI, grep ssi $conf_h >/dev/null) AM_CONDITIONAL(STATIC_HANDLER_SECDOWNLOAD, grep secdownload $conf_h >/dev/null)
|