summaryrefslogtreecommitdiff
path: root/sapi
diff options
context:
space:
mode:
authorSean Finney <seanius@debian.org>2009-04-10 14:09:48 +0200
committerSean Finney <seanius@debian.org>2009-04-10 14:09:48 +0200
commitcd0b49c72aee33b3e44a9c589fcd93b9e1c7a64f (patch)
tree1315c623bb7d9dfa8d366fa9cd2c6834ceeb5da5 /sapi
parent9ea47aab740772adf0c69d8c94b208a464e599ea (diff)
downloadphp-cd0b49c72aee33b3e44a9c589fcd93b9e1c7a64f.tar.gz
Imported Upstream version 5.2.9.dfsg.1upstream/5.2.9.dfsg.1
Diffstat (limited to 'sapi')
-rw-r--r--sapi/aolserver/aolserver.c6
-rw-r--r--sapi/apache/libpre.c4
-rw-r--r--sapi/apache/mod_php5.c20
-rw-r--r--sapi/apache/mod_php5.h4
-rw-r--r--sapi/apache/php_apache.c4
-rw-r--r--sapi/apache/php_apache_http.h4
-rw-r--r--sapi/apache/sapi_apache.c4
-rw-r--r--sapi/apache2filter/apache_config.c4
-rw-r--r--sapi/apache2filter/php_apache.h4
-rw-r--r--sapi/apache2filter/php_functions.c4
-rw-r--r--sapi/apache2filter/sapi_apache2.c8
-rw-r--r--sapi/apache2handler/apache_config.c32
-rw-r--r--sapi/apache2handler/mod_php5.c4
-rw-r--r--sapi/apache2handler/php_apache.h4
-rw-r--r--sapi/apache2handler/php_functions.c4
-rw-r--r--sapi/apache2handler/sapi_apache2.c7
-rw-r--r--sapi/apache_hooks/mod_php5.c4
-rw-r--r--sapi/apache_hooks/mod_php5.h4
-rw-r--r--sapi/apache_hooks/php_apache.c4
-rw-r--r--sapi/apache_hooks/sapi_apache.c4
-rw-r--r--sapi/caudium/caudium.c6
-rw-r--r--sapi/cgi/cgi_main.c153
-rw-r--r--sapi/cgi/fastcgi.c181
-rw-r--r--sapi/cgi/fastcgi.h8
-rw-r--r--sapi/cgi/getopt.c4
-rw-r--r--sapi/cgi/php_getopt.h4
-rw-r--r--sapi/cgi/tests/005.phpt3
-rw-r--r--sapi/cgi/tests/007.phpt2
-rw-r--r--sapi/cgi/tests/010.phpt53
-rw-r--r--sapi/cgi/tests/include.inc2
-rw-r--r--sapi/cli/config.m48
-rw-r--r--sapi/cli/getopt.c4
-rw-r--r--sapi/cli/php.1.in2
-rw-r--r--sapi/cli/php_cli.c21
-rw-r--r--sapi/cli/php_cli_readline.c4
-rw-r--r--sapi/cli/php_cli_readline.h4
-rw-r--r--sapi/cli/php_getopt.h4
-rw-r--r--sapi/cli/tests/009.phpt3
-rw-r--r--sapi/cli/tests/015.phpt8
-rw-r--r--sapi/cli/tests/021.phpt39
-rw-r--r--sapi/cli/tests/022.inc14
-rw-r--r--sapi/cli/tests/022.phpt47
-rw-r--r--sapi/continuity/capi.c4
-rw-r--r--sapi/embed/php_embed.c4
-rw-r--r--sapi/embed/php_embed.h4
-rw-r--r--sapi/isapi/php5isapi.c7
-rw-r--r--sapi/isapi/stresstest/stresstest.cpp2
-rw-r--r--sapi/milter/php_milter.c12
-rw-r--r--sapi/nsapi/nsapi.c95
-rw-r--r--sapi/phttpd/php_phttpd.h2
-rw-r--r--sapi/phttpd/phttpd.c2
-rw-r--r--sapi/pi3web/pi3web_sapi.c6
-rw-r--r--sapi/roxen/roxen.c6
-rw-r--r--sapi/thttpd/php_thttpd.h2
-rw-r--r--sapi/thttpd/thttpd.c4
-rw-r--r--sapi/tux/php_tux.c2
-rw-r--r--sapi/webjames/php_webjames.h2
-rw-r--r--sapi/webjames/webjames.c2
58 files changed, 588 insertions, 275 deletions
diff --git a/sapi/aolserver/aolserver.c b/sapi/aolserver/aolserver.c
index de8b45db2..92b4da851 100644
--- a/sapi/aolserver/aolserver.c
+++ b/sapi/aolserver/aolserver.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -22,7 +22,7 @@
* - CGI/1.1 conformance
*/
-/* $Id: aolserver.c,v 1.81.2.2.2.2 2007/12/31 07:20:15 sebastian Exp $ */
+/* $Id: aolserver.c,v 1.81.2.2.2.3 2008/12/31 11:17:48 sebastian Exp $ */
/* conflict between PHP and AOLserver headers */
#define Debug php_Debug
@@ -205,7 +205,7 @@ static void php_info_aolserver(ZEND_MODULE_INFO_FUNC_ARGS)
int i;
php_info_print_table_start();
- php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 1.81.2.2.2.2 2007/12/31 07:20:15 sebastian Exp $");
+ php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 1.81.2.2.2.3 2008/12/31 11:17:48 sebastian Exp $");
php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
diff --git a/sapi/apache/libpre.c b/sapi/apache/libpre.c
index 28915b707..e375424e0 100644
--- a/sapi/apache/libpre.c
+++ b/sapi/apache/libpre.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: libpre.c,v 1.6.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */
+/* $Id: libpre.c,v 1.6.2.1.2.3 2008/12/31 11:17:48 sebastian Exp $ */
#ifdef NETWARE
diff --git a/sapi/apache/mod_php5.c b/sapi/apache/mod_php5.c
index 4167f5dd8..325c295f0 100644
--- a/sapi/apache/mod_php5.c
+++ b/sapi/apache/mod_php5.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,7 +17,7 @@
| PHP 4.0 patches by Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: mod_php5.c,v 1.19.2.7.2.14 2007/12/31 07:20:15 sebastian Exp $ */
+/* $Id: mod_php5.c,v 1.19.2.7.2.17 2008/12/31 11:17:48 sebastian Exp $ */
#include "php_apache_http.h"
#include "http_conf_globals.h"
@@ -597,6 +597,8 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
return OK;
}
+ SG(server_context) = r;
+
zend_first_try {
/* Make sure file exists */
@@ -654,8 +656,6 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
/* Init timeout */
hard_timeout("send", r);
- SG(server_context) = r;
-
php_save_umask();
add_common_vars(r);
add_cgi_vars(r);
@@ -729,11 +729,11 @@ static zend_bool should_overwrite_per_dir_entry(HashTable *target_ht, php_per_di
return 1; /* does not exist in dest, copy from source */
}
- if (new_per_dir_entry->type==PHP_INI_SYSTEM
- && orig_per_dir_entry->type!=PHP_INI_SYSTEM) {
- return 1;
- } else {
+ if (orig_per_dir_entry->type==PHP_INI_SYSTEM
+ && new_per_dir_entry->type!=PHP_INI_SYSTEM) {
return 0;
+ } else {
+ return 1;
}
}
/* }}} */
@@ -770,9 +770,9 @@ static void *php_merge_dir(pool *p, void *basev, void *addv)
/* need a copy of addv to merge */
new = php_create_dir(p, "php_merge_dir");
- zend_hash_copy(new, (HashTable *) addv, (copy_ctor_func_t) copy_per_dir_entry, NULL, sizeof(php_per_dir_entry));
+ zend_hash_copy(new, (HashTable *) basev, (copy_ctor_func_t) copy_per_dir_entry, NULL, sizeof(php_per_dir_entry));
- zend_hash_merge_ex(new, (HashTable *) basev, (copy_ctor_func_t) copy_per_dir_entry, sizeof(php_per_dir_entry), (merge_checker_func_t) should_overwrite_per_dir_entry, NULL);
+ zend_hash_merge_ex(new, (HashTable *) addv, (copy_ctor_func_t) copy_per_dir_entry, sizeof(php_per_dir_entry), (merge_checker_func_t) should_overwrite_per_dir_entry, NULL);
return new;
}
/* }}} */
diff --git a/sapi/apache/mod_php5.h b/sapi/apache/mod_php5.h
index 900283a2f..fecdbf948 100644
--- a/sapi/apache/mod_php5.h
+++ b/sapi/apache/mod_php5.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -15,7 +15,7 @@
| Author: Rasmus Lerdorf <rasmus@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: mod_php5.h,v 1.4.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */
+/* $Id: mod_php5.h,v 1.4.2.1.2.3 2008/12/31 11:17:48 sebastian Exp $ */
#ifndef MOD_PHP5_H
#define MOD_PHP5_H
diff --git a/sapi/apache/php_apache.c b/sapi/apache/php_apache.c
index ddf187f42..5941615e8 100644
--- a/sapi/apache/php_apache.c
+++ b/sapi/apache/php_apache.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,7 +17,7 @@
| David Sklar <sklar@student.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_apache.c,v 1.89.2.4.2.7 2007/12/31 07:20:15 sebastian Exp $ */
+/* $Id: php_apache.c,v 1.89.2.4.2.8 2008/12/31 11:17:48 sebastian Exp $ */
#include "php_apache_http.h"
diff --git a/sapi/apache/php_apache_http.h b/sapi/apache/php_apache_http.h
index ee0e2e3d8..848485d68 100644
--- a/sapi/apache/php_apache_http.h
+++ b/sapi/apache/php_apache_http.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_apache_http.h,v 1.13.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */
+/* $Id: php_apache_http.h,v 1.13.2.1.2.3 2008/12/31 11:17:48 sebastian Exp $ */
#define NO_REGEX_EXTRA_H
diff --git a/sapi/apache/sapi_apache.c b/sapi/apache/sapi_apache.c
index 1ef7b2723..2ead2f83e 100644
--- a/sapi/apache/sapi_apache.c
+++ b/sapi/apache/sapi_apache.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -19,7 +19,7 @@
| Stig Bakken <ssb@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: sapi_apache.c,v 1.47.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */
+/* $Id: sapi_apache.c,v 1.47.2.1.2.3 2008/12/31 11:17:48 sebastian Exp $ */
#include "php_apache_http.h"
diff --git a/sapi/apache2filter/apache_config.c b/sapi/apache2filter/apache_config.c
index d484684be..97d6825b1 100644
--- a/sapi/apache2filter/apache_config.c
+++ b/sapi/apache2filter/apache_config.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: apache_config.c,v 1.34.2.1.2.4 2007/12/31 07:20:15 sebastian Exp $ */
+/* $Id: apache_config.c,v 1.34.2.1.2.5 2008/12/31 11:17:48 sebastian Exp $ */
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
diff --git a/sapi/apache2filter/php_apache.h b/sapi/apache2filter/php_apache.h
index e5b17c374..681f19f3b 100644
--- a/sapi/apache2filter/php_apache.h
+++ b/sapi/apache2filter/php_apache.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_apache.h,v 1.25.2.1.2.3 2007/12/31 07:20:15 sebastian Exp $ */
+/* $Id: php_apache.h,v 1.25.2.1.2.4 2008/12/31 11:17:48 sebastian Exp $ */
#ifndef PHP_APACHE_H
#define PHP_APACHE_H
diff --git a/sapi/apache2filter/php_functions.c b/sapi/apache2filter/php_functions.c
index 80ebd20d0..d01196f26 100644
--- a/sapi/apache2filter/php_functions.c
+++ b/sapi/apache2filter/php_functions.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_functions.c,v 1.44.2.2.2.3 2007/12/31 07:20:15 sebastian Exp $ */
+/* $Id: php_functions.c,v 1.44.2.2.2.4 2008/12/31 11:17:48 sebastian Exp $ */
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c
index 08d3bb69f..6e91647ee 100644
--- a/sapi/apache2filter/sapi_apache2.c
+++ b/sapi/apache2filter/sapi_apache2.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: sapi_apache2.c,v 1.136.2.2.2.9 2007/12/31 07:20:15 sebastian Exp $ */
+/* $Id: sapi_apache2.c,v 1.136.2.2.2.11 2008/12/31 11:17:48 sebastian Exp $ */
#include <fcntl.h>
@@ -411,6 +411,10 @@ static void php_apache_request_ctor(ap_filter_t *f, php_struct *ctx TSRMLS_DC)
if (!PG(safe_mode) || (PG(safe_mode) && !ap_auth_type(f->r))) {
auth = apr_table_get(f->r->headers_in, "Authorization");
php_handle_auth_data(auth TSRMLS_CC);
+ if (SG(request_info).auth_user == NULL && f->r->user) {
+ SG(request_info).auth_user = estrdup(f->r->user);
+ }
+ ctx->r->user = apr_pstrdup(ctx->r->pool, SG(request_info).auth_user);
} else {
SG(request_info).auth_user = NULL;
SG(request_info).auth_password = NULL;
diff --git a/sapi/apache2handler/apache_config.c b/sapi/apache2handler/apache_config.c
index c3e040b7f..1e961083d 100644
--- a/sapi/apache2handler/apache_config.c
+++ b/sapi/apache2handler/apache_config.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: apache_config.c,v 1.7.2.1.2.5 2007/12/31 07:20:15 sebastian Exp $ */
+/* $Id: apache_config.c,v 1.7.2.1.2.7 2008/12/31 11:17:48 sebastian Exp $ */
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
@@ -117,6 +117,23 @@ static const char *php_apache_phpini_set(cmd_parms *cmd, void *mconfig, const ch
return NULL;
}
+static zend_bool should_overwrite_per_dir_entry(HashTable *target_ht, php_dir_entry *new_per_dir_entry, zend_hash_key *hash_key, void *pData)
+{
+ php_dir_entry *orig_per_dir_entry;
+
+ if (zend_hash_find(target_ht, hash_key->arKey, hash_key->nKeyLength, (void **) &orig_per_dir_entry)==FAILURE) {
+ return 1; /* does not exist in dest, copy from source */
+ }
+
+ if (new_per_dir_entry->status >= orig_per_dir_entry->status) {
+ /* use new entry */
+ phpapdebug((stderr, "ADDING/OVERWRITING %s (%d vs. %d)\n", hash_key->arKey, new_per_dir_entry->status, orig_per_dir_entry->status));
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf)
{
@@ -128,9 +145,12 @@ void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf)
ulong num_index;
n = create_php_config(p, "merge_php_config");
- zend_hash_copy(&n->config, &e->config, NULL, NULL, sizeof(php_dir_entry));
-
+ /* copy old config */
+ zend_hash_copy(&n->config, &d->config, NULL, NULL, sizeof(php_dir_entry));
+ /* merge new config */
phpapdebug((stderr, "Merge dir (%p)+(%p)=(%p)\n", base_conf, new_conf, n));
+ zend_hash_merge_ex(&n->config, &e->config, NULL, sizeof(php_dir_entry), (merge_checker_func_t) should_overwrite_per_dir_entry, NULL);
+#if STAS_0
for (zend_hash_internal_pointer_reset(&d->config);
zend_hash_get_current_key_ex(&d->config, &str, &str_len,
&num_index, 0, NULL) == HASH_KEY_IS_STRING;
@@ -140,10 +160,10 @@ void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf)
if (zend_hash_find(&n->config, str, str_len, (void **) &pe) == SUCCESS) {
if (pe->status >= data->status) continue;
}
- zend_hash_update(&n->config, str, str_len, data, sizeof(*data), NULL);
phpapdebug((stderr, "ADDING/OVERWRITING %s (%d vs. %d)\n", str, data->status, pe?pe->status:-1));
+ zend_hash_update(&n->config, str, str_len, data, sizeof(*data), NULL);
}
-
+#endif
return n;
}
diff --git a/sapi/apache2handler/mod_php5.c b/sapi/apache2handler/mod_php5.c
index e9b66da21..0a3ed7a22 100644
--- a/sapi/apache2handler/mod_php5.c
+++ b/sapi/apache2handler/mod_php5.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mod_php5.c,v 1.5.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */
+/* $Id: mod_php5.c,v 1.5.2.1.2.3 2008/12/31 11:17:48 sebastian Exp $ */
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
diff --git a/sapi/apache2handler/php_apache.h b/sapi/apache2handler/php_apache.h
index 8ad66500c..c1c9474a6 100644
--- a/sapi/apache2handler/php_apache.h
+++ b/sapi/apache2handler/php_apache.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_apache.h,v 1.8.2.1.2.3 2007/12/31 07:20:15 sebastian Exp $ */
+/* $Id: php_apache.h,v 1.8.2.1.2.4 2008/12/31 11:17:48 sebastian Exp $ */
#ifndef PHP_APACHE_H
#define PHP_APACHE_H
diff --git a/sapi/apache2handler/php_functions.c b/sapi/apache2handler/php_functions.c
index 034051e40..7db52a5b7 100644
--- a/sapi/apache2handler/php_functions.c
+++ b/sapi/apache2handler/php_functions.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_functions.c,v 1.18.2.6.2.6 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: php_functions.c,v 1.18.2.6.2.7 2008/12/31 11:17:48 sebastian Exp $ */
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c
index 5fa6cdf75..c7733b443 100644
--- a/sapi/apache2handler/sapi_apache2.c
+++ b/sapi/apache2handler/sapi_apache2.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: sapi_apache2.c,v 1.57.2.10.2.17 2008/01/16 15:50:37 iliaa Exp $ */
+/* $Id: sapi_apache2.c,v 1.57.2.10.2.19 2008/12/31 11:17:48 sebastian Exp $ */
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
@@ -456,6 +456,9 @@ static int php_apache_request_ctor(request_rec *r, php_struct *ctx TSRMLS_DC)
if (!PG(safe_mode) || (PG(safe_mode) && !ap_auth_type(r))) {
auth = apr_table_get(r->headers_in, "Authorization");
php_handle_auth_data(auth TSRMLS_CC);
+ if (SG(request_info).auth_user == NULL && r->user) {
+ SG(request_info).auth_user = estrdup(r->user);
+ }
ctx->r->user = apr_pstrdup(ctx->r->pool, SG(request_info).auth_user);
} else {
SG(request_info).auth_user = NULL;
diff --git a/sapi/apache_hooks/mod_php5.c b/sapi/apache_hooks/mod_php5.c
index 7f7d982e3..0f9d8a12f 100644
--- a/sapi/apache_hooks/mod_php5.c
+++ b/sapi/apache_hooks/mod_php5.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,7 +17,7 @@
| PHP 4.0 patches by Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: mod_php5.c,v 1.11.2.1.2.6 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: mod_php5.c,v 1.11.2.1.2.7 2008/12/31 11:17:48 sebastian Exp $ */
#include "php_apache_http.h"
diff --git a/sapi/apache_hooks/mod_php5.h b/sapi/apache_hooks/mod_php5.h
index bd6fb9a52..ffa815fa5 100644
--- a/sapi/apache_hooks/mod_php5.h
+++ b/sapi/apache_hooks/mod_php5.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -15,7 +15,7 @@
| Author: Rasmus Lerdorf <rasmus@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: mod_php5.h,v 1.2.2.1.2.2 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: mod_php5.h,v 1.2.2.1.2.3 2008/12/31 11:17:48 sebastian Exp $ */
#ifndef MOD_PHP5_H
#define MOD_PHP5_H
diff --git a/sapi/apache_hooks/php_apache.c b/sapi/apache_hooks/php_apache.c
index fd0a84f3e..982e72a36 100644
--- a/sapi/apache_hooks/php_apache.c
+++ b/sapi/apache_hooks/php_apache.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,7 +17,7 @@
| David Sklar <sklar@student.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_apache.c,v 1.19.2.3.2.6 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: php_apache.c,v 1.19.2.3.2.7 2008/12/31 11:17:48 sebastian Exp $ */
#include "php_apache_http.h"
diff --git a/sapi/apache_hooks/sapi_apache.c b/sapi/apache_hooks/sapi_apache.c
index 4efa2fcb7..f7ac1d765 100644
--- a/sapi/apache_hooks/sapi_apache.c
+++ b/sapi/apache_hooks/sapi_apache.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -19,7 +19,7 @@
| Stig Bakken <ssb@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: sapi_apache.c,v 1.9.2.1.2.2 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: sapi_apache.c,v 1.9.2.1.2.3 2008/12/31 11:17:48 sebastian Exp $ */
#include "php_apache_http.h"
diff --git a/sapi/caudium/caudium.c b/sapi/caudium/caudium.c
index 9a10d88d6..3b7d85e5e 100644
--- a/sapi/caudium/caudium.c
+++ b/sapi/caudium/caudium.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: caudium.c,v 1.36.2.1.2.2 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: caudium.c,v 1.36.2.1.2.3 2008/12/31 11:17:48 sebastian Exp $ */
#include "php.h"
#ifdef HAVE_CAUDIUM
@@ -444,7 +444,7 @@ static void php_info_caudium(ZEND_MODULE_INFO_FUNC_ARGS)
{
/* char buf[512]; */
php_info_print_table_start();
- php_info_print_table_row(2, "SAPI module version", "$Id: caudium.c,v 1.36.2.1.2.2 2007/12/31 07:20:16 sebastian Exp $");
+ php_info_print_table_row(2, "SAPI module version", "$Id: caudium.c,v 1.36.2.1.2.3 2008/12/31 11:17:48 sebastian Exp $");
/* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index f47ae96c8..6e1139966 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: cgi_main.c,v 1.267.2.15.2.56 2008/04/09 09:16:40 dmitry Exp $ */
+/* $Id: cgi_main.c,v 1.267.2.15.2.69 2009/01/19 18:17:59 dsp Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -103,6 +103,12 @@ static int children = 0;
*/
static int parent = 1;
+/* Did parent received exit signals SIG_TERM/SIG_INT/SIG_QUIT */
+static int exit_signal = 0;
+
+/* Is Parent waiting for children to exit */
+static int parent_waiting = 0;
+
/**
* Process group
*/
@@ -232,6 +238,7 @@ static void print_extensions(TSRMLS_D)
zend_llist sorted_exts;
zend_llist_copy(&sorted_exts, &zend_extensions);
+ sorted_exts.dtor = NULL;
zend_llist_sort(&sorted_exts, extension_name_cmp TSRMLS_CC);
zend_llist_apply_with_argument(&sorted_exts, (llist_apply_with_arg_func_t) print_extension_info, NULL TSRMLS_CC);
zend_llist_destroy(&sorted_exts);
@@ -362,6 +369,8 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
char buf[SAPI_CGI_MAX_HEADER_LENGTH];
sapi_header_struct *h;
zend_llist_position pos;
+ zend_bool ignore_status = 0;
+ int response_status = SG(sapi_headers).http_response_code;
if (SG(request_info).no_headers == 1) {
return SAPI_HEADER_SENT_SUCCESSFULLY;
@@ -373,8 +382,11 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
zend_bool has_status = 0;
if (CGIG(rfc2616_headers) && SG(sapi_headers).http_status_line) {
- len = slprintf(buf, SAPI_CGI_MAX_HEADER_LENGTH,
- "%s\r\n", SG(sapi_headers).http_status_line);
+ char *s;
+ len = slprintf(buf, SAPI_CGI_MAX_HEADER_LENGTH, "%s\r\n", SG(sapi_headers).http_status_line);
+ if ((s = strchr(SG(sapi_headers).http_status_line, ' '))) {
+ response_status = atoi((s + 1));
+ }
if (len > SAPI_CGI_MAX_HEADER_LENGTH) {
len = SAPI_CGI_MAX_HEADER_LENGTH;
@@ -388,6 +400,7 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
(s - SG(sapi_headers).http_status_line) >= 5 &&
strncasecmp(SG(sapi_headers).http_status_line, "HTTP/", 5) == 0) {
len = slprintf(buf, sizeof(buf), "Status:%s\r\n", s);
+ response_status = atoi((s + 1));
} else {
h = (sapi_header_struct*)zend_llist_get_first_ex(&sapi_headers->headers, &pos);
while (h) {
@@ -417,6 +430,7 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
}
if (!has_status) {
PHPWRITE_H(buf, len);
+ ignore_status = 1;
}
}
@@ -424,8 +438,21 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
while (h) {
/* prevent CRLFCRLF */
if (h->header_len) {
- PHPWRITE_H(h->header, h->header_len);
- PHPWRITE_H("\r\n", 2);
+ if (h->header_len > sizeof("Status:")-1 &&
+ strncasecmp(h->header, "Status:", sizeof("Status:")-1) == 0) {
+ if (!ignore_status) {
+ ignore_status = 1;
+ PHPWRITE_H(h->header, h->header_len);
+ PHPWRITE_H("\r\n", 2);
+ }
+ } else if (response_status == 304 && h->header_len > sizeof("Content-Type:")-1 &&
+ strncasecmp(h->header, "Content-Type:", sizeof("Content-Type:")-1) == 0) {
+ h = (sapi_header_struct*)zend_llist_get_next_ex(&sapi_headers->headers, &pos);
+ continue;
+ } else {
+ PHPWRITE_H(h->header, h->header_len);
+ PHPWRITE_H("\r\n", 2);
+ }
}
h = (sapi_header_struct*)zend_llist_get_next_ex(&sapi_headers->headers, &pos);
}
@@ -765,6 +792,39 @@ static void php_cgi_usage(char *argv0)
}
/* }}} */
+/* {{{ is_valid_path
+ *
+ * some server configurations allow '..' to slip through in the
+ * translated path. We'll just refuse to handle such a path.
+ */
+static int is_valid_path(const char *path)
+{
+ const char *p;
+
+ if (!path) {
+ return 0;
+ }
+ p = strstr(path, "..");
+ if (p) {
+ if ((p == path || IS_SLASH(*(p-1))) &&
+ (*(p+2) == 0 || IS_SLASH(*(p+2)))) {
+ return 0;
+ }
+ while (1) {
+ p = strstr(p+1, "..");
+ if (!p) {
+ break;
+ }
+ if (IS_SLASH(*(p-1)) &&
+ (*(p+2) == 0 || IS_SLASH(*(p+2)))) {
+ return 0;
+ }
+ }
+ }
+ return 1;
+}
+/* }}} */
+
/* {{{ init_request_info
initializes request_info structure
@@ -900,7 +960,8 @@ static void init_request_info(TSRMLS_D)
TRANSLATE_SLASHES(env_document_root);
}
- if (env_path_translated != NULL && env_redirect_url != NULL) {
+ if (env_path_translated != NULL && env_redirect_url != NULL &&
+ orig_script_filename != NULL && script_path_translated != NULL) {
/*
pretty much apache specific. If we have a redirect_url
then our script_filename and script_name point to the
@@ -925,6 +986,9 @@ static void init_request_info(TSRMLS_D)
if (script_path_translated &&
(script_path_translated_len = strlen(script_path_translated)) > 0 &&
(script_path_translated[script_path_translated_len-1] == '/' ||
+#ifdef PHP_WIN32
+ script_path_translated[script_path_translated_len-1] == '\\' ||
+#endif
(real_path = tsrm_realpath(script_path_translated, NULL TSRMLS_CC)) == NULL)) {
char *pt = estrndup(script_path_translated, script_path_translated_len);
int len = script_path_translated_len;
@@ -1061,9 +1125,7 @@ static void init_request_info(TSRMLS_D)
if (pt) {
efree(pt);
}
- /* some server configurations allow '..' to slip through in the
- translated path. We'll just refuse to handle such a path. */
- if (script_path_translated && !strstr(script_path_translated, "..")) {
+ if (is_valid_path(script_path_translated)) {
SG(request_info).path_translated = estrdup(script_path_translated);
}
} else {
@@ -1094,9 +1156,7 @@ static void init_request_info(TSRMLS_D)
} else {
SG(request_info).request_uri = env_script_name;
}
- /* some server configurations allow '..' to slip through in the
- translated path. We'll just refuse to handle such a path. */
- if (script_path_translated && !strstr(script_path_translated, "..")) {
+ if (is_valid_path(script_path_translated)) {
SG(request_info).path_translated = estrdup(script_path_translated);
}
free(real_path);
@@ -1114,9 +1174,7 @@ static void init_request_info(TSRMLS_D)
script_path_translated = env_path_translated;
}
#endif
- /* some server configurations allow '..' to slip through in the
- translated path. We'll just refuse to handle such a path. */
- if (script_path_translated && !strstr(script_path_translated, "..")) {
+ if (is_valid_path(script_path_translated)) {
SG(request_info).path_translated = estrdup(script_path_translated);
}
#if ENABLE_PATHINFO_CHECK
@@ -1135,7 +1193,7 @@ static void init_request_info(TSRMLS_D)
}
/* }}} */
-#if PHP_FASTCGI
+#if PHP_FASTCGI && !defined(PHP_WIN32)
/**
* Clean up child processes upon exit
*/
@@ -1145,15 +1203,16 @@ void fastcgi_cleanup(int signal)
fprintf(stderr, "FastCGI shutdown, pid %d\n", getpid());
#endif
-#ifndef PHP_WIN32
sigaction(SIGTERM, &old_term, 0);
/* Kill all the processes in our process group */
kill(-pgroup, SIGTERM);
-#endif
- /* We should exit at this point, but MacOSX doesn't seem to */
- exit(0);
+ if (parent && parent_waiting) {
+ exit_signal = 1;
+ } else {
+ exit(0);
+ }
}
#endif
@@ -1491,11 +1550,18 @@ consult the installation file that came with this distribution, or visit \n\
#ifndef PHP_WIN32
/* Pre-fork, if required */
if (getenv("PHP_FCGI_CHILDREN")) {
- children = atoi(getenv("PHP_FCGI_CHILDREN"));
+ char * children_str = getenv("PHP_FCGI_CHILDREN");
+ children = atoi(children_str);
if (children < 0) {
fprintf(stderr, "PHP_FCGI_CHILDREN is not valid\n");
return FAILURE;
}
+ fcgi_set_mgmt_var("FCGI_MAX_CONNS", sizeof("FCGI_MAX_CONNS")-1, children_str, strlen(children_str));
+ /* This is the number of concurrent requests, equals FCGI_MAX_CONNS */
+ fcgi_set_mgmt_var("FCGI_MAX_REQS", sizeof("FCGI_MAX_REQS")-1, children_str, strlen(children_str));
+ } else {
+ fcgi_set_mgmt_var("FCGI_MAX_CONNS", sizeof("FCGI_MAX_CONNS")-1, "1", sizeof("1")-1);
+ fcgi_set_mgmt_var("FCGI_MAX_REQS", sizeof("FCGI_MAX_REQS")-1, "1", sizeof("1")-1);
}
if (children) {
@@ -1520,7 +1586,7 @@ consult the installation file that came with this distribution, or visit \n\
}
if (fcgi_in_shutdown()) {
- exit(0);
+ goto parent_out;
}
while (parent) {
@@ -1557,9 +1623,25 @@ consult the installation file that came with this distribution, or visit \n\
#ifdef DEBUG_FASTCGI
fprintf(stderr, "Wait for kids, pid %d\n", getpid());
#endif
- while (wait(&status) < 0) {
+ parent_waiting = 1;
+ while (1) {
+ if (wait(&status) >= 0) {
+ running--;
+ break;
+ } else if (exit_signal) {
+ break;
+ }
+ }
+ if (exit_signal) {
+#if 0
+ while (running > 0) {
+ while (wait(&status) < 0) {
+ }
+ running--;
+ }
+#endif
+ goto parent_out;
}
- running--;
}
}
} else {
@@ -1628,17 +1710,6 @@ consult the installation file that came with this distribution, or visit \n\
&& !fastcgi
#endif
) {
- if (cgi_sapi_module.php_ini_path_override && cgi_sapi_module.php_ini_ignore) {
- no_headers = 1;
- php_output_startup();
- php_output_activate(TSRMLS_C);
- SG(headers_sent) = 1;
- php_printf("You cannot use both -n and -c switch. Use -h for help.\n");
- php_end_ob_buffers(1 TSRMLS_CC);
- exit_status = 1;
- goto out;
- }
-
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0)) != -1) {
switch (c) {
@@ -1727,9 +1798,9 @@ consult the installation file that came with this distribution, or visit \n\
SG(request_info).no_headers = 1;
}
#if ZEND_DEBUG
- php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2008 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
+ php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2009 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
#else
- php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2008 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
+ php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2009 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
#endif
php_request_shutdown((void *) 0);
exit_status = 0;
@@ -1898,7 +1969,7 @@ consult the installation file that came with this distribution, or visit \n\
/* #!php support */
c = fgetc(file_handle.handle.fp);
if (c == '#') {
- while (c != '\n' && c != '\r') {
+ while (c != '\n' && c != '\r' && c != EOF) {
c = fgetc(file_handle.handle.fp); /* skip to end of line */
}
/* handle situations where line is terminated by \r\n */
@@ -2061,6 +2132,10 @@ out:
}
#endif
+#ifndef PHP_WIN32
+parent_out:
+#endif
+
SG(server_context) = NULL;
php_module_shutdown(TSRMLS_C);
sapi_shutdown();
diff --git a/sapi/cgi/fastcgi.c b/sapi/cgi/fastcgi.c
index 6503c3d00..f94d82d17 100644
--- a/sapi/cgi/fastcgi.c
+++ b/sapi/cgi/fastcgi.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: fastcgi.c,v 1.4.2.13.2.30 2008/04/03 10:24:44 dmitry Exp $ */
+/* $Id: fastcgi.c,v 1.4.2.13.2.35 2008/12/31 11:17:48 sebastian Exp $ */
#include "php.h"
#include "fastcgi.h"
@@ -133,18 +133,7 @@ typedef union _sa_t {
struct sockaddr_in sa_inet;
} sa_t;
-typedef struct _fcgi_mgmt_rec {
- char* name;
- char name_len;
- char val;
-} fcgi_mgmt_rec;
-
-static const fcgi_mgmt_rec fcgi_mgmt_vars[] = {
- {"FCGI_MAX_CONNS", sizeof("FCGI_MAX_CONNS")-1, 1},
- {"FCGI_MAX_REQS", sizeof("FCGI_MAX_REQS")-1, 1},
- {"FCGI_MPXS_CONNS", sizeof("FCGI_MPXS_CONNS")-1, 0}
-};
-
+static HashTable fcgi_mgmt_vars;
static int is_initialized = 0;
static int is_fastcgi = 0;
@@ -170,6 +159,20 @@ static void fcgi_signal_handler(int signo)
}
}
+static void fcgi_setup_signals(void)
+{
+ struct sigaction new_sa, old_sa;
+
+ sigemptyset(&new_sa.sa_mask);
+ new_sa.sa_flags = 0;
+ new_sa.sa_handler = fcgi_signal_handler;
+ sigaction(SIGUSR1, &new_sa, NULL);
+ sigaction(SIGTERM, &new_sa, NULL);
+ sigaction(SIGPIPE, NULL, &old_sa);
+ if (old_sa.sa_handler == SIG_DFL) {
+ sigaction(SIGPIPE, &new_sa, NULL);
+ }
+}
#endif
int fcgi_in_shutdown(void)
@@ -180,6 +183,14 @@ int fcgi_in_shutdown(void)
int fcgi_init(void)
{
if (!is_initialized) {
+#ifndef _WIN32
+ sa_t sa;
+ socklen_t len = sizeof(sa);
+#endif
+ zend_hash_init(&fcgi_mgmt_vars, 0, NULL, fcgi_free_mgmt_var_cb, 1);
+ fcgi_set_mgmt_var("FCGI_MPXS_CONNS", sizeof("FCGI_MPXS_CONNS")-1, "0", sizeof("0")-1);
+
+ is_initialized = 1;
#ifdef _WIN32
# if 0
/* TODO: Support for TCP sockets */
@@ -190,8 +201,6 @@ int fcgi_init(void)
return 0;
}
# endif
- is_initialized = 1;
-
if ((GetStdHandle(STD_OUTPUT_HANDLE) == INVALID_HANDLE_VALUE) &&
(GetStdHandle(STD_ERROR_HANDLE) == INVALID_HANDLE_VALUE) &&
(GetStdHandle(STD_INPUT_HANDLE) != INVALID_HANDLE_VALUE)) {
@@ -218,24 +227,9 @@ int fcgi_init(void)
return is_fastcgi = 0;
}
#else
- sa_t sa;
- socklen_t len = sizeof(sa);
-
- is_initialized = 1;
errno = 0;
if (getpeername(0, (struct sockaddr *)&sa, &len) != 0 && errno == ENOTCONN) {
- struct sigaction new_sa, old_sa;
-
- sigemptyset(&new_sa.sa_mask);
- new_sa.sa_flags = 0;
- new_sa.sa_handler = fcgi_signal_handler;
- sigaction(SIGUSR1, &new_sa, NULL);
- sigaction(SIGTERM, &new_sa, NULL);
- sigaction(SIGPIPE, NULL, &old_sa);
- if (old_sa.sa_handler == SIG_DFL) {
- sigaction(SIGPIPE, &new_sa, NULL);
- }
-
+ fcgi_setup_signals();
return is_fastcgi = 1;
} else {
return is_fastcgi = 0;
@@ -257,6 +251,9 @@ int fcgi_is_fastcgi(void)
void fcgi_shutdown(void)
{
+ if (is_initialized) {
+ zend_hash_destroy(&fcgi_mgmt_vars);
+ }
is_fastcgi = 0;
}
@@ -459,35 +456,35 @@ int fcgi_listen(const char *path, int backlog)
if (!tcp) {
chmod(path, 0777);
} else {
- char *ip = getenv("FCGI_WEB_SERVER_ADDRS");
- char *cur, *end;
- int n;
-
- if (ip) {
- ip = strdup(ip);
- cur = ip;
- n = 0;
- while (*cur) {
- if (*cur == ',') n++;
- cur++;
- }
- allowed_clients = malloc(sizeof(in_addr_t) * (n+2));
- n = 0;
- cur = ip;
- while (cur) {
- end = strchr(cur, ',');
- if (end) {
- *end = 0;
- end++;
- }
- allowed_clients[n] = inet_addr(cur);
- if (allowed_clients[n] == INADDR_NONE) {
+ char *ip = getenv("FCGI_WEB_SERVER_ADDRS");
+ char *cur, *end;
+ int n;
+
+ if (ip) {
+ ip = strdup(ip);
+ cur = ip;
+ n = 0;
+ while (*cur) {
+ if (*cur == ',') n++;
+ cur++;
+ }
+ allowed_clients = malloc(sizeof(in_addr_t) * (n+2));
+ n = 0;
+ cur = ip;
+ while (cur) {
+ end = strchr(cur, ',');
+ if (end) {
+ *end = 0;
+ end++;
+ }
+ allowed_clients[n] = inet_addr(cur);
+ if (allowed_clients[n] == INADDR_NONE) {
fprintf(stderr, "Wrong IP address '%s' in FCGI_WEB_SERVER_ADDRS\n", cur);
- }
- n++;
- cur = end;
- }
- allowed_clients[n] = INADDR_NONE;
+ }
+ n++;
+ cur = end;
+ }
+ allowed_clients[n] = INADDR_NONE;
free(ip);
}
}
@@ -501,6 +498,8 @@ int fcgi_listen(const char *path, int backlog)
if (tcp) {
listen_socket = _open_osfhandle((long)listen_socket, 0);
}
+#else
+ fcgi_setup_signals();
#endif
return listen_socket;
}
@@ -743,8 +742,13 @@ static int fcgi_read_request(fcgi_request *req)
padding = hdr.paddingLength;
}
} else if (hdr.type == FCGI_GET_VALUES) {
- int j;
unsigned char *p = buf + sizeof(fcgi_header);
+ HashPosition pos;
+ char * str_index;
+ uint str_length;
+ ulong num_index;
+ int key_type;
+ zval ** value;
if (safe_read(req, buf, len+padding) != len+padding) {
req->keep = 0;
@@ -756,11 +760,41 @@ static int fcgi_read_request(fcgi_request *req)
return 0;
}
- for (j = 0; j < sizeof(fcgi_mgmt_vars)/sizeof(fcgi_mgmt_vars[0]); j++) {
- if (zend_hash_exists(&req->env, fcgi_mgmt_vars[j].name, fcgi_mgmt_vars[j].name_len+1) == 0) {
- sprintf((char*)p, "%c%c%s%c", fcgi_mgmt_vars[j].name_len, 1, fcgi_mgmt_vars[j].name, fcgi_mgmt_vars[j].val);
- p += fcgi_mgmt_vars[j].name_len + 3;
+ zend_hash_internal_pointer_reset_ex(&req->env, &pos);
+ while ((key_type = zend_hash_get_current_key_ex(&req->env, &str_index, &str_length, &num_index, 0, &pos)) != HASH_KEY_NON_EXISTANT) {
+ int zlen;
+ zend_hash_move_forward_ex(&req->env, &pos);
+ if (key_type != HASH_KEY_IS_STRING) {
+ continue;
+ }
+ if (zend_hash_find(&fcgi_mgmt_vars, str_index, str_length, (void**) &value) != SUCCESS) {
+ continue;
+ }
+ --str_length;
+ zlen = Z_STRLEN_PP(value);
+ if ((p + 4 + 4 + str_length + zlen) >= (buf + sizeof(buf))) {
+ break;
+ }
+ if (str_length < 0x80) {
+ *p++ = str_length;
+ } else {
+ *p++ = ((str_length >> 24) & 0xff) | 0x80;
+ *p++ = (str_length >> 16) & 0xff;
+ *p++ = (str_length >> 8) & 0xff;
+ *p++ = str_length & 0xff;
+ }
+ if (zlen < 0x80) {
+ *p++ = zlen;
+ } else {
+ *p++ = ((zlen >> 24) & 0xff) | 0x80;
+ *p++ = (zlen >> 16) & 0xff;
+ *p++ = (zlen >> 8) & 0xff;
+ *p++ = zlen & 0xff;
}
+ memcpy(p, str_index, str_length);
+ p += str_length;
+ memcpy(p, Z_STRVAL_PP(value), zlen);
+ p += zlen;
}
len = p - buf - sizeof(fcgi_header);
len += fcgi_make_header((fcgi_header*)buf, FCGI_GET_VALUES_RESULT, 0, len);
@@ -1219,6 +1253,23 @@ void fcgi_impersonate(void)
}
#endif
+void fcgi_set_mgmt_var(char * name, size_t name_len, const char * value, size_t value_len)
+{
+ zval * zvalue;
+ zvalue = pemalloc(sizeof(*zvalue), 1);
+ Z_TYPE_P(zvalue) = IS_STRING;
+ Z_STRVAL_P(zvalue) = pestrndup(value, value_len, 1);
+ Z_STRLEN_P(zvalue) = value_len;
+ zend_hash_add(&fcgi_mgmt_vars, name, name_len + 1, &zvalue, sizeof(zvalue), NULL);
+}
+
+void fcgi_free_mgmt_var_cb(void * ptr)
+{
+ zval ** var = (zval **)ptr;
+ pefree(Z_STRVAL_PP(var), 1);
+ pefree(*var, 1);
+}
+
/*
* Local variables:
* tab-width: 4
diff --git a/sapi/cgi/fastcgi.h b/sapi/cgi/fastcgi.h
index 2b8606472..6df318052 100644
--- a/sapi/cgi/fastcgi.h
+++ b/sapi/cgi/fastcgi.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: fastcgi.h,v 1.2.2.4.2.6 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: fastcgi.h,v 1.2.2.4.2.8 2008/12/31 11:17:48 sebastian Exp $ */
/* FastCGI protocol */
@@ -131,6 +131,10 @@ int fcgi_flush(fcgi_request *req, int close);
#ifdef PHP_WIN32
void fcgi_impersonate(void);
#endif
+
+void fcgi_set_mgmt_var(char * name, size_t name_len, const char * value, size_t value_len);
+void fcgi_free_mgmt_var_cb(void * ptr);
+
/*
* Local variables:
* tab-width: 4
diff --git a/sapi/cgi/getopt.c b/sapi/cgi/getopt.c
index d5bb50618..1e2182f32 100644
--- a/sapi/cgi/getopt.c
+++ b/sapi/cgi/getopt.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: getopt.c,v 1.9.2.1.2.5 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: getopt.c,v 1.9.2.1.2.6 2008/12/31 11:17:48 sebastian Exp $ */
#include <stdio.h>
#include <string.h>
diff --git a/sapi/cgi/php_getopt.h b/sapi/cgi/php_getopt.h
index aa513dded..ac6cf5123 100644
--- a/sapi/cgi/php_getopt.h
+++ b/sapi/cgi/php_getopt.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_getopt.h,v 1.7.2.1.2.3 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: php_getopt.h,v 1.7.2.1.2.4 2008/12/31 11:17:48 sebastian Exp $ */
#include "php.h"
diff --git a/sapi/cgi/tests/005.phpt b/sapi/cgi/tests/005.phpt
index 6d82b0f31..34a28f9c5 100644
--- a/sapi/cgi/tests/005.phpt
+++ b/sapi/cgi/tests/005.phpt
@@ -10,15 +10,12 @@ include "include.inc";
$php = get_cgi_path();
reset_env_vars();
-var_dump(`$php -n -c -f 'wrong'`);
var_dump(`$php -n -a -f 'wrong'`);
var_dump(`$php -n -f 'wrong' -a`);
echo "Done\n";
?>
--EXPECTF--
-string(55) "You cannot use both -n and -c switch. Use -h for help.
-"
string(51) "No input file specified.
Interactive mode enabled
diff --git a/sapi/cgi/tests/007.phpt b/sapi/cgi/tests/007.phpt
index c0f8df1bf..92bf0f6aa 100644
--- a/sapi/cgi/tests/007.phpt
+++ b/sapi/cgi/tests/007.phpt
@@ -10,7 +10,7 @@ $php = get_cgi_path();
reset_env_vars();
var_dump(`"$php" -n -f some.php -f some.php`);
-var_dump(`"$php" -s -w -l`);
+var_dump(`"$php" -n -s -w -l`);
echo "Done\n";
?>
diff --git a/sapi/cgi/tests/010.phpt b/sapi/cgi/tests/010.phpt
new file mode 100644
index 000000000..e633ad28b
--- /dev/null
+++ b/sapi/cgi/tests/010.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Bug #45860 (header() function fails to correctly replace all Status lines)
+--SKIPIF--
+<?php include "skipif.inc"; ?>
+--FILE--
+<?php
+
+include "include.inc";
+
+$php = get_cgi_path();
+reset_env_vars();
+
+$f = tempnam(sys_get_temp_dir(), 'cgitest');
+
+putenv("TRANSLATED_PATH=".$f."/x");
+putenv("SCRIPT_FILENAME=".$f."/x");
+file_put_contents($f, '<?php
+header("HTTP/1.1 403 Forbidden");
+header("Status: 403 Also Forbidden");
+?>');
+
+echo (`$php -n $f`);
+
+file_put_contents($f, '<?php
+header("HTTP/1.1 403 Forbidden");
+?>');
+
+echo (`$php -n $f`);
+
+file_put_contents($f, '<?php
+header("Status: 403 Also Forbidden");
+?>');
+
+echo (`$php -n $f`);
+
+echo "Done\n";
+
+@unlink($f);
+?>
+--EXPECTF--
+Status: 403 Forbidden
+X-Powered-By: PHP/%s
+Content-type: text/html
+
+Status: 403 Forbidden
+X-Powered-By: PHP/%s
+Content-type: text/html
+
+X-Powered-By: PHP/%s
+Status: 403 Also Forbidden
+Content-type: text/html
+
+Done
diff --git a/sapi/cgi/tests/include.inc b/sapi/cgi/tests/include.inc
index 11bf8f3b8..2d8ed8a2e 100644
--- a/sapi/cgi/tests/include.inc
+++ b/sapi/cgi/tests/include.inc
@@ -8,7 +8,7 @@ function get_cgi_path() /* {{{ */
$cgi = false;
if (file_exists($php) && is_executable($php)) {
- $version = `$php -v`;
+ $version = `$php -n -v`;
if (strstr($version, "(cli)")) {
/* that's cli */
$cli = true;
diff --git a/sapi/cli/config.m4 b/sapi/cli/config.m4
index 4ea165c46..104b1a733 100644
--- a/sapi/cli/config.m4
+++ b/sapi/cli/config.m4
@@ -1,5 +1,5 @@
dnl
-dnl $Id: config.m4,v 1.22.2.1.2.1 2007/07/11 23:20:36 jani Exp $
+dnl $Id: config.m4,v 1.22.2.1.2.2 2008/09/01 13:15:15 dmitry Exp $
dnl
PHP_ARG_ENABLE(cli,,
@@ -14,7 +14,11 @@ if test "$PHP_CLI" != "no"; then
case $host_alias in
*aix*)
- BUILD_CLI="echo '\#! .' > php.sym && echo >>php.sym && nm -BCpg \`echo \$(PHP_GLOBAL_OBJS) \$(PHP_CLI_OBJS) | sed 's/\([A-Za-z0-9_]*\)\.lo/\1.o/g'\` | \$(AWK) '{ if (((\$\$2 == \"T\") || (\$\$2 == \"D\") || (\$\$2 == \"B\")) && (substr(\$\$3,1,1) != \".\")) { print \$\$3 } }' | sort -u >> php.sym && \$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) -Wl,-brtl -Wl,-bE:php.sym \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)"
+ if test "$php_build_target" = "shared"; then
+ BUILD_CLI="echo '\#! .' > php.sym && echo >>php.sym && nm -BCpg \`echo \$(PHP_GLOBAL_OBJS) \$(PHP_CLI_OBJS) | sed 's/\([A-Za-z0-9_]*\)\.lo/.libs\/\1.o/g'\` | \$(AWK) '{ if (((\$\$2 == \"T\") || (\$\$2 == \"D\") || (\$\$2 == \"B\")) && (substr(\$\$3,1,1) != \".\")) { print \$\$3 } }' | sort -u >> php.sym && \$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) -Wl,-brtl -Wl,-bE:php.sym \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)"
+ else
+ BUILD_CLI="echo '\#! .' > php.sym && echo >>php.sym && nm -BCpg \`echo \$(PHP_GLOBAL_OBJS) \$(PHP_CLI_OBJS) | sed 's/\([A-Za-z0-9_]*\)\.lo/\1.o/g'\` | \$(AWK) '{ if (((\$\$2 == \"T\") || (\$\$2 == \"D\") || (\$\$2 == \"B\")) && (substr(\$\$3,1,1) != \".\")) { print \$\$3 } }' | sort -u >> php.sym && \$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) -Wl,-brtl -Wl,-bE:php.sym \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)"
+ fi
;;
*darwin*)
BUILD_CLI="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_CLI_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)"
diff --git a/sapi/cli/getopt.c b/sapi/cli/getopt.c
index 5b0bc5448..bf9012b52 100644
--- a/sapi/cli/getopt.c
+++ b/sapi/cli/getopt.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: getopt.c,v 1.8.2.1.2.7 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: getopt.c,v 1.8.2.1.2.8 2008/12/31 11:17:49 sebastian Exp $ */
#include <stdio.h>
#include <string.h>
diff --git a/sapi/cli/php.1.in b/sapi/cli/php.1.in
index 9e78fef11..a21239942 100644
--- a/sapi/cli/php.1.in
+++ b/sapi/cli/php.1.in
@@ -400,7 +400,7 @@ contributors all around the world.
.SH VERSION INFORMATION
This manpage describes \fBphp\fP, version @PHP_VERSION@.
.SH COPYRIGHT
-Copyright \(co 1997\-2008 The PHP Group
+Copyright \(co 1997\-2009 The PHP Group
.LP
This source file is subject to version 3.01 of the PHP license,
that is bundled with this package in the file LICENSE, and is
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index fa3d582bc..813485e43 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_cli.c,v 1.129.2.13.2.24 2008/01/29 20:01:14 dmitry Exp $ */
+/* $Id: php_cli.c,v 1.129.2.13.2.30 2008/12/31 11:17:49 sebastian Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -260,11 +260,10 @@ static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{
{
ret = sapi_cli_single_write(ptr, remaining);
if (!ret) {
-#ifdef PHP_CLI_WIN32_NO_CONSOLE
- break;
-#else
+#ifndef PHP_CLI_WIN32_NO_CONSOLE
php_handle_aborted_connection();
#endif
+ break;
}
ptr += ret;
remaining -= ret;
@@ -504,7 +503,7 @@ static void cli_register_file_handles(TSRMLS_D) /* {{{ */
if (s_err) php_stream_close(s_err);
return;
}
-
+
#if PHP_DEBUG
/* do not close stdout and stderr */
s_out->flags |= PHP_STREAM_FLAG_NO_CLOSE;
@@ -562,7 +561,7 @@ static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file,
/* #!php support */
c = fgetc(file_handle->handle.fp);
if (c == '#') {
- while (c != '\n' && c != '\r') {
+ while (c != '\n' && c != '\r' && c != EOF) {
c = fgetc(file_handle->handle.fp); /* skip to end of line */
}
/* handle situations where line is terminated by \r\n */
@@ -729,12 +728,6 @@ int main(int argc, char *argv[])
CG(in_compilation) = 0; /* not initialized but needed for several options */
EG(uninitialized_zval_ptr) = NULL;
- if (cli_sapi_module.php_ini_path_override && cli_sapi_module.php_ini_ignore) {
- PUTS("You cannot use both -n and -c switch. Use -h for help.\n");
- exit_status=1;
- goto out_err;
- }
-
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0)) != -1) {
switch (c) {
@@ -779,7 +772,7 @@ int main(int argc, char *argv[])
}
request_started = 1;
- php_printf("PHP %s (%s) (built: %s %s) %s\nCopyright (c) 1997-2008 The PHP Group\n%s",
+ php_printf("PHP %s (%s) (built: %s %s) %s\nCopyright (c) 1997-2009 The PHP Group\n%s",
PHP_VERSION, sapi_module.name, __DATE__, __TIME__,
#if ZEND_DEBUG && defined(HAVE_GCOV)
"(DEBUG GCOV)",
diff --git a/sapi/cli/php_cli_readline.c b/sapi/cli/php_cli_readline.c
index 614ee26f3..dd76c3518 100644
--- a/sapi/cli/php_cli_readline.c
+++ b/sapi/cli/php_cli_readline.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_cli_readline.c,v 1.3.2.5.2.4 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: php_cli_readline.c,v 1.3.2.5.2.5 2008/12/31 11:17:49 sebastian Exp $ */
#include "php.h"
diff --git a/sapi/cli/php_cli_readline.h b/sapi/cli/php_cli_readline.h
index b5e489aed..cdf4e5a08 100644
--- a/sapi/cli/php_cli_readline.h
+++ b/sapi/cli/php_cli_readline.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_cli_readline.h,v 1.2.2.1.2.2 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: php_cli_readline.h,v 1.2.2.1.2.3 2008/12/31 11:17:49 sebastian Exp $ */
#include "php.h"
diff --git a/sapi/cli/php_getopt.h b/sapi/cli/php_getopt.h
index 0c8e06829..ef10db00c 100644
--- a/sapi/cli/php_getopt.h
+++ b/sapi/cli/php_getopt.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_getopt.h,v 1.7.2.1.2.2 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: php_getopt.h,v 1.7.2.1.2.3 2008/12/31 11:17:49 sebastian Exp $ */
#include "php.h"
diff --git a/sapi/cli/tests/009.phpt b/sapi/cli/tests/009.phpt
index c0bb319f7..a881a0730 100644
--- a/sapi/cli/tests/009.phpt
+++ b/sapi/cli/tests/009.phpt
@@ -7,15 +7,12 @@ using invalid combinations of cmdline options
$php = getenv('TEST_PHP_EXECUTABLE');
-var_dump(`$php -n -c -r "echo hello;"`);
var_dump(`$php -n -a -r "echo hello;"`);
var_dump(`$php -n -r "echo hello;" -a`);
echo "Done\n";
?>
--EXPECTF--
-You cannot use both -n and -c switch. Use -h for help.
-NULL
Either execute direct code, process stdin or use a file.
NULL
Either execute direct code, process stdin or use a file.
diff --git a/sapi/cli/tests/015.phpt b/sapi/cli/tests/015.phpt
index 4d5226759..ab5918b4d 100644
--- a/sapi/cli/tests/015.phpt
+++ b/sapi/cli/tests/015.phpt
@@ -13,10 +13,10 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
$php = getenv('TEST_PHP_EXECUTABLE');
-echo `"$php" --version | grep built:`;
-echo `echo "<?php print_r(\\\$argv);" | "$php" -- foo bar baz`, "\n";
-echo `"$php" --version foo bar baz | grep built:`;
-echo `"$php" --notexisting foo bar baz | grep Usage:`;
+echo `"$php" -n --version | grep built:`;
+echo `echo "<?php print_r(\\\$argv);" | "$php" -n -- foo bar baz`, "\n";
+echo `"$php" -n --version foo bar baz | grep built:`;
+echo `"$php" -n --notexisting foo bar baz | grep Usage:`;
echo "Done\n";
?>
diff --git a/sapi/cli/tests/021.phpt b/sapi/cli/tests/021.phpt
new file mode 100644
index 000000000..b127b8969
--- /dev/null
+++ b/sapi/cli/tests/021.phpt
@@ -0,0 +1,39 @@
+--TEST--
+CLI shell shebang
+--SKIPIF--
+<?php
+include 'skipif.inc';
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die ("skip not for Windows");
+}
+?>
+--FILE--
+<?php
+
+$php = getenv('TEST_PHP_EXECUTABLE');
+
+$filename = dirname(__FILE__).'/021.tmp.php';
+
+$script = "#!$php -n\n".
+ "ola\n".
+ "<?php echo 1+1,'\n';\n".
+ "?>\n".
+ "adeus\n";
+
+file_put_contents($filename, $script);
+chmod($filename, 0777);
+
+echo `$filename`;
+
+echo "\nDone\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__).'/021.tmp.php');
+?>
+--EXPECTF--
+ola
+2
+adeus
+
+Done
diff --git a/sapi/cli/tests/022.inc b/sapi/cli/tests/022.inc
new file mode 100644
index 000000000..b77512fcf
--- /dev/null
+++ b/sapi/cli/tests/022.inc
@@ -0,0 +1,14 @@
+<?php
+
+ob_start();
+var_dump(STDIN);
+
+$fd = fopen("php://stdin","r");
+var_dump($fd);
+
+$client_socket = stream_socket_accept($fd);
+
+$data = ob_get_clean();
+fwrite($client_socket, $data);
+
+?>
diff --git a/sapi/cli/tests/022.phpt b/sapi/cli/tests/022.phpt
new file mode 100644
index 000000000..eabb8bdf8
--- /dev/null
+++ b/sapi/cli/tests/022.phpt
@@ -0,0 +1,47 @@
+--TEST--
+STDIN/OUT/ERR stream type
+--SKIPIF--
+<?php
+if (!getenv("TEST_PHP_EXECUTABLE")) die("skip TEST_PHP_EXECUTABLE not set");
+if (substr(PHP_OS, 0, 3) == "WIN") die("skip non windows test");
+?>
+--FILE--
+<?php
+$php = getenv("TEST_PHP_EXECUTABLE");
+$socket_file = dirname(__FILE__) . '/' . pathinfo(__FILE__, PATHINFO_FILENAME) . '.sock';
+$test_file = dirname(__FILE__) . '/' . pathinfo(__FILE__, PATHINFO_FILENAME) . '.inc';
+if (file_exists($socket_file)) {
+ unlink($socket_file);
+}
+$socket = stream_socket_server('unix://' . $socket_file);
+var_dump($socket);
+if (!$socket) {
+ exit(1);
+}
+$desc = array(
+ 0 => $socket,
+ 1 => STDOUT,
+ 2 => STDERR,
+);
+$pipes = array();
+$proc = proc_open("$php -n " . escapeshellarg($test_file), $desc, $pipes);
+var_dump($proc);
+if (!$proc) {
+ exit(1);
+}
+
+$client_socket = stream_socket_client('unix://' . $socket_file);
+var_dump($client_socket);
+echo stream_get_contents($client_socket);
+fclose($client_socket);
+
+proc_terminate($proc);
+proc_close($proc);
+unlink($socket_file);
+?>
+--EXPECTF--
+resource(%d) of type (stream)
+resource(%d) of type (process)
+resource(%d) of type (stream)
+resource(%d) of type (stream)
+resource(%d) of type (stream)
diff --git a/sapi/continuity/capi.c b/sapi/continuity/capi.c
index 88e18c824..b57008951 100644
--- a/sapi/continuity/capi.c
+++ b/sapi/continuity/capi.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -110,7 +110,7 @@ PHP_MSHUTDOWN_FUNCTION(continuity)
PHP_MINFO_FUNCTION(continuity)
{
php_info_print_table_start();
- php_info_print_table_row(2, "Continuity Module Revision", "$Revision: 1.11.2.2.2.2 $");
+ php_info_print_table_row(2, "Continuity Module Revision", "$Revision: 1.11.2.2.2.3 $");
php_info_print_table_row(2, "Server Version", conFget_build());
#ifdef CONTINUITY_CDPEXT
php_info_print_table_row(2,"CDP Extensions", "enabled");
diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c
index 93cd41ccd..d5e4363c2 100644
--- a/sapi/embed/php_embed.c
+++ b/sapi/embed/php_embed.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -15,7 +15,7 @@
| Author: Edin Kadribasic <edink@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_embed.c,v 1.11.2.1.2.7 2008/03/26 13:21:57 helly Exp $ */
+/* $Id: php_embed.c,v 1.11.2.1.2.8 2008/12/31 11:17:49 sebastian Exp $ */
#include "php_embed.h"
diff --git a/sapi/embed/php_embed.h b/sapi/embed/php_embed.h
index c40bc7d7d..9f729ba3c 100644
--- a/sapi/embed/php_embed.h
+++ b/sapi/embed/php_embed.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -15,7 +15,7 @@
| Author: Edin Kadribasic <edink@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_embed.h,v 1.6.2.2.2.2 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: php_embed.h,v 1.6.2.2.2.3 2008/12/31 11:17:49 sebastian Exp $ */
#ifndef _PHP_EMBED_H_
#define _PHP_EMBED_H_
diff --git a/sapi/isapi/php5isapi.c b/sapi/isapi/php5isapi.c
index 451d5e85e..36303c583 100644
--- a/sapi/isapi/php5isapi.c
+++ b/sapi/isapi/php5isapi.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
| Ben Mansell <ben@zeus.com> (Zeus Support) |
+----------------------------------------------------------------------+
*/
-/* $Id: php5isapi.c,v 1.8.2.2.2.4 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: php5isapi.c,v 1.8.2.2.2.6 2008/12/31 11:17:49 sebastian Exp $ */
#include "php.h"
#include <httpext.h>
@@ -711,6 +711,7 @@ DWORD WINAPI HttpFilterProc(PHTTP_FILTER_CONTEXT pfc, DWORD notificationType, LP
case SF_NOTIFY_PREPROC_HEADERS:
SG(request_info).auth_user = NULL;
SG(request_info).auth_password = NULL;
+ SG(request_info).auth_digest = NULL;
break;
case SF_NOTIFY_AUTHENTICATION: {
char *auth_user = ((HTTP_FILTER_AUTHENT *) pvNotification)->pszUser;
@@ -745,7 +746,7 @@ static void init_request_info(LPEXTENSION_CONTROL_BLOCK lpECB TSRMLS_DC)
SG(request_info).content_length = lpECB->cbTotalBytes;
SG(sapi_headers).http_response_code = 200; /* I think dwHttpStatusCode is invalid at this stage -RL */
if (!bFilterLoaded) { /* we don't have valid ISAPI Filter information */
- SG(request_info).auth_user = SG(request_info).auth_password = NULL;
+ SG(request_info).auth_user = SG(request_info).auth_password = SG(request_info).auth_digest = NULL;
}
#ifdef WITH_ZEUS
diff --git a/sapi/isapi/stresstest/stresstest.cpp b/sapi/isapi/stresstest/stresstest.cpp
index c7e634c15..97824e6be 100644
--- a/sapi/isapi/stresstest/stresstest.cpp
+++ b/sapi/isapi/stresstest/stresstest.cpp
@@ -271,7 +271,7 @@ void DoThreads() {
for (i=0; i< numThreads; i++) {
CloseHandle(threads[i]);
}
- delete threads;
+ delete [] threads;
}
void DoFileList(const char *filelist, const char *environment)
diff --git a/sapi/milter/php_milter.c b/sapi/milter/php_milter.c
index d551ead12..0ae314f4c 100644
--- a/sapi/milter/php_milter.c
+++ b/sapi/milter/php_milter.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -18,6 +18,7 @@
+----------------------------------------------------------------------+
*/
+/* $Id: php_milter.c,v 1.14.2.2.2.6 2008/12/31 11:17:49 sebastian Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -1006,13 +1007,6 @@ int main(int argc, char *argv[])
zend_uv.html_errors = 0; /* tell the engine we're in non-html mode */
- if (milter_sapi_module.php_ini_path_override && milter_sapi_module.php_ini_ignore) {
- SG(headers_sent) = 1;
- SG(request_info).no_headers = 1;
- PUTS("You cannot use both -n and -c switch. Use -h for help.\n");
- exit(1);
- }
-
while ((c = ap_php_getopt(argc, argv, OPTSTRING)) != -1) {
switch (c) {
@@ -1065,7 +1059,7 @@ int main(int argc, char *argv[])
}
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
- php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2008 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
+ php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2009 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
php_end_ob_buffers(1 TSRMLS_CC);
exit(1);
break;
diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c
index 2a9ff1c1a..18c3aae3e 100644
--- a/sapi/nsapi/nsapi.c
+++ b/sapi/nsapi/nsapi.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: nsapi.c,v 1.69.2.3.2.8 2008/03/09 16:06:33 felipe Exp $ */
+/* $Id: nsapi.c,v 1.69.2.3.2.16 2009/01/06 13:46:49 thetaphi Exp $ */
/*
* PHP includes
@@ -60,12 +60,6 @@
* NSAPI includes
*/
#include "nsapi.h"
-#include "base/pblock.h"
-#include "base/session.h"
-#include "frame/req.h"
-#include "frame/protocol.h" /* protocol_start_response */
-#include "base/util.h" /* is_mozilla, getline */
-#include "frame/log.h" /* log_error */
#define NSLS_D struct nsapi_request_context *request_context
#define NSLS_DC , NSLS_D
@@ -231,13 +225,6 @@ char *nsapi_dll = NULL;
*/
static void php_nsapi_init_dynamic_symbols(void)
{
-#if defined(servact_uri2path) && defined(servact_pathchecks) && defined(servact_fileinfo) && defined(servact_service)
- /* use functions from nsapi.h if available */
- nsapi_servact_uri2path = &servact_uri2path;
- nsapi_servact_pathchecks = &servact_pathchecks;
- nsapi_servact_fileinfo = &servact_fileinfo;
- nsapi_servact_service = &servact_service;
-#else
/* find address of internal NSAPI functions */
#ifdef PHP_WIN32
register int i;
@@ -271,7 +258,6 @@ static void php_nsapi_init_dynamic_symbols(void)
nsapi_servact_fileinfo = NULL;
nsapi_servact_service = NULL;
}
-#endif
}
/* }}} */
@@ -308,7 +294,7 @@ PHP_MSHUTDOWN_FUNCTION(nsapi)
PHP_MINFO_FUNCTION(nsapi)
{
php_info_print_table_start();
- php_info_print_table_row(2, "NSAPI Module Revision", "$Revision: 1.69.2.3.2.8 $");
+ php_info_print_table_row(2, "NSAPI Module Revision", "$Revision: 1.69.2.3.2.16 $");
php_info_print_table_row(2, "Server Software", system_version());
php_info_print_table_row(2, "Sub-requests with nsapi_virtual()",
(nsapi_servact_service)?((zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0))?"not supported with zlib.output_compression":"enabled"):"not supported on this platform" );
@@ -327,22 +313,20 @@ PHP_MINFO_FUNCTION(nsapi)
*/
PHP_FUNCTION(nsapi_virtual)
{
- zval **uri;
- int rv;
- char *value;
+ int uri_len,rv;
+ char *uri,*value;
Request *rq;
nsapi_request_context *rc = (nsapi_request_context *)SG(server_context);
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &uri) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &uri, &uri_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(uri);
if (!nsapi_servact_service) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include uri '%s' - Sub-requests not supported on this platform", (*uri)->value.str.val);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include uri '%s' - Sub-requests not supported on this platform", uri);
RETURN_FALSE;
} else if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include uri '%s' - Sub-requests do not work with zlib.output_compression", (*uri)->value.str.val);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include uri '%s' - Sub-requests do not work with zlib.output_compression", uri);
RETURN_FALSE;
} else {
php_end_ob_buffers(1 TSRMLS_CC);
@@ -350,8 +334,8 @@ PHP_FUNCTION(nsapi_virtual)
/* do the sub-request */
/* thanks to Chris Elving from Sun for this code sniplet */
- if ((rq = request_restart_internal((*uri)->value.str.val, NULL)) == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include uri '%s' - Internal request creation failed", (*uri)->value.str.val);
+ if ((rq = request_restart_internal(uri, NULL)) == NULL) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include uri '%s' - Internal request creation failed", uri);
RETURN_FALSE;
}
@@ -383,7 +367,7 @@ PHP_FUNCTION(nsapi_virtual)
} while (rv == REQ_RESTART);
if (rq->status_num != 200) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include uri '%s' - HTTP status code %d during subrequest", (*uri)->value.str.val, rq->status_num);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include uri '%s' - HTTP status code %d during subrequest", uri, rq->status_num);
request_free(rq);
RETURN_FALSE;
}
@@ -403,6 +387,10 @@ PHP_FUNCTION(nsapi_request_headers)
struct pb_entry *entry;
nsapi_request_context *rc = (nsapi_request_context *)SG(server_context);
+ if (ZEND_NUM_ARGS()) {
+ WRONG_PARAM_COUNT;
+ }
+
array_init(return_value);
for (i=0; i < rc->rq->headers->hsize; i++) {
@@ -425,9 +413,11 @@ PHP_FUNCTION(nsapi_response_headers)
struct pb_entry *entry;
nsapi_request_context *rc = (nsapi_request_context *)SG(server_context);
- array_init(return_value);
+ if (ZEND_NUM_ARGS()) {
+ WRONG_PARAM_COUNT;
+ }
- php_header(TSRMLS_C);
+ array_init(return_value);
for (i=0; i < rc->rq->srvhdrs->hsize; i++) {
entry=rc->rq->srvhdrs->ht[i];
@@ -447,9 +437,12 @@ PHP_FUNCTION(nsapi_response_headers)
static int sapi_nsapi_ub_write(const char *str, unsigned int str_length TSRMLS_DC)
{
int retval;
- nsapi_request_context *rc;
+ nsapi_request_context *rc = (nsapi_request_context *)SG(server_context);
+
+ if (!SG(headers_sent)) {
+ sapi_send_headers(TSRMLS_C);
+ }
- rc = (nsapi_request_context *)SG(server_context);
retval = net_write(rc->sn->csd, (char *)str, str_length);
if (retval == IO_ERROR /* -1 */ || retval == IO_EOF /* 0 */) {
php_handle_aborted_connection();
@@ -457,6 +450,24 @@ static int sapi_nsapi_ub_write(const char *str, unsigned int str_length TSRMLS_D
return retval;
}
+/* modified version of apache2 */
+static void sapi_nsapi_flush(void *server_context)
+{
+ nsapi_request_context *rc = (nsapi_request_context *)server_context;
+ TSRMLS_FETCH();
+
+ if (!SG(headers_sent)) {
+ sapi_send_headers(TSRMLS_C);
+ }
+
+ /* flushing is only supported in iPlanet servers from version 6.1 on, make it conditional */
+#if NSAPI_VERSION >= 302
+ if (net_flush(rc->sn->csd) < 0) {
+ php_handle_aborted_connection();
+ }
+#endif
+}
+
static int sapi_nsapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC)
{
char *header_name, *header_content, *p;
@@ -729,6 +740,13 @@ static int php_nsapi_startup(sapi_module_struct *sapi_module)
return SUCCESS;
}
+static struct stat* sapi_nsapi_get_stat(TSRMLS_D)
+{
+ return request_stat_path(
+ SG(request_info).path_translated,
+ ((nsapi_request_context *)SG(server_context))->rq
+ );
+}
static sapi_module_struct nsapi_sapi_module = {
"nsapi", /* name */
@@ -741,8 +759,8 @@ static sapi_module_struct nsapi_sapi_module = {
NULL, /* deactivate */
sapi_nsapi_ub_write, /* unbuffered write */
- NULL, /* flush */
- NULL, /* get uid */
+ sapi_nsapi_flush, /* flush */
+ sapi_nsapi_get_stat, /* get uid/stat */
NULL, /* getenv */
php_error, /* error handler */
@@ -831,12 +849,10 @@ int NSAPI_PUBLIC php5_init(pblock *pb, Session *sn, Request *rq)
int threads=128; /* default for server */
/* fetch max threads from NSAPI and initialize TSRM with it */
-#if defined(pool_maxthreads)
- threads=pool_maxthreads;
+ threads=conf_getglobals()->Vpool_maxthreads;
if (threads<1) {
threads=128; /* default for server */
}
-#endif
tsrm_startup(threads, 1, 0, NULL);
core_globals = ts_resource(core_globals_id);
@@ -884,7 +900,7 @@ int NSAPI_PUBLIC php5_execute(pblock *pb, Session *sn, Request *rq)
int retval;
nsapi_request_context *request_context;
zend_file_handle file_handle = {0};
- struct stat fst;
+ struct stat *fst;
char *path_info;
char *query_string = pblock_findval("query", rq->reqpb);
@@ -956,7 +972,8 @@ int NSAPI_PUBLIC php5_execute(pblock *pb, Session *sn, Request *rq)
file_handle.free_filename = 0;
file_handle.opened_path = NULL;
- if (stat(SG(request_info).path_translated, &fst)==0 && S_ISREG(fst.st_mode)) {
+ fst = request_stat_path(SG(request_info).path_translated, rq);
+ if (fst && S_ISREG(fst->st_mode)) {
if (php_request_startup(TSRMLS_C) == SUCCESS) {
php_execute_script(&file_handle TSRMLS_CC);
php_request_shutdown(NULL);
diff --git a/sapi/phttpd/php_phttpd.h b/sapi/phttpd/php_phttpd.h
index 04eb9bc20..a827d8cb7 100644
--- a/sapi/phttpd/php_phttpd.h
+++ b/sapi/phttpd/php_phttpd.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/sapi/phttpd/phttpd.c b/sapi/phttpd/phttpd.c
index ed4b3fd57..c9a0fad04 100644
--- a/sapi/phttpd/phttpd.c
+++ b/sapi/phttpd/phttpd.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/sapi/pi3web/pi3web_sapi.c b/sapi/pi3web/pi3web_sapi.c
index 10fea09e2..746b8bbbc 100644
--- a/sapi/pi3web/pi3web_sapi.c
+++ b/sapi/pi3web/pi3web_sapi.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pi3web_sapi.c,v 1.60.2.1.2.2 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: pi3web_sapi.c,v 1.60.2.1.2.3 2008/12/31 11:17:49 sebastian Exp $ */
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
@@ -57,7 +57,7 @@ static void php_info_pi3web(ZEND_MODULE_INFO_FUNC_ARGS)
PUTS("<table border=0 cellpadding=3 cellspacing=1 width=600 align=center>\n");
PUTS("<tr><th colspan=2 bgcolor=\"" PHP_HEADER_COLOR "\">Pi3Web Server Information</th></tr>\n");
php_info_print_table_header(2, "Information Field", "Value");
- php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c,v 1.60.2.1.2.2 2007/12/31 07:20:16 sebastian Exp $");
+ php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c,v 1.60.2.1.2.3 2008/12/31 11:17:49 sebastian Exp $");
php_info_print_table_row(2, "Server Name Stamp", HTTPCore_getServerStamp());
snprintf(variable_buf, 511, "%d", HTTPCore_debugEnabled());
php_info_print_table_row(2, "Debug Enabled", variable_buf);
diff --git a/sapi/roxen/roxen.c b/sapi/roxen/roxen.c
index 47585a0c4..558268a67 100644
--- a/sapi/roxen/roxen.c
+++ b/sapi/roxen/roxen.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: roxen.c,v 1.61.2.2.2.2 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: roxen.c,v 1.61.2.2.2.3 2008/12/31 11:17:49 sebastian Exp $ */
#include "php.h"
#ifdef HAVE_ROXEN
@@ -438,7 +438,7 @@ static void php_info_roxen(ZEND_MODULE_INFO_FUNC_ARGS)
{
/* char buf[512]; */
php_info_print_table_start();
- php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.61.2.2.2.2 2007/12/31 07:20:16 sebastian Exp $");
+ php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.61.2.2.2.3 2008/12/31 11:17:49 sebastian Exp $");
/* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
diff --git a/sapi/thttpd/php_thttpd.h b/sapi/thttpd/php_thttpd.h
index ea7cc3686..cc6f4f7bd 100644
--- a/sapi/thttpd/php_thttpd.h
+++ b/sapi/thttpd/php_thttpd.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c
index 1619c5161..ec26ac619 100644
--- a/sapi/thttpd/thttpd.c
+++ b/sapi/thttpd/thttpd.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: thttpd.c,v 1.95.2.1.2.2 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: thttpd.c,v 1.95.2.1.2.3 2008/12/31 11:17:49 sebastian Exp $ */
#include "php.h"
#include "SAPI.h"
diff --git a/sapi/tux/php_tux.c b/sapi/tux/php_tux.c
index 65a7cde05..806dcad14 100644
--- a/sapi/tux/php_tux.c
+++ b/sapi/tux/php_tux.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/sapi/webjames/php_webjames.h b/sapi/webjames/php_webjames.h
index e54caea70..eac8b11b8 100644
--- a/sapi/webjames/php_webjames.h
+++ b/sapi/webjames/php_webjames.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/sapi/webjames/webjames.c b/sapi/webjames/webjames.c
index f166eddfb..e5bce4e7b 100644
--- a/sapi/webjames/webjames.c
+++ b/sapi/webjames/webjames.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |