[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
pajoye Mon Jun 22 20:15:27 2009 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: - MF53: [PHP-CVS] cvs: php-src(PHP_5_3) /sapi/cgi cgi_main.c http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.385r2=1.386diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.385 php-src/sapi/cgi/cgi_main.c:1.386 --- php-src/sapi/cgi/cgi_main.c:1.385 Wed Jun 17 19:31:54 2009 +++ php-src/sapi/cgi/cgi_main.c Mon Jun 22 20:15:27 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.385 2009/06/17 19:31:54 pajoye Exp $ */ +/* $Id: cgi_main.c,v 1.386 2009/06/22 20:15:27 pajoye Exp $ */ #include php.h #include php_globals.h @@ -751,7 +751,7 @@ to find more user.ini, if not we only scan the current path. */ if (strncmp(s1, s2, s_len) == 0) { - ptr = s1 + start; /* start is the point where doc_root ends! */ + ptr = s2 + start; /* start is the point where doc_root ends! */ while ((ptr = strchr(ptr, DEFAULT_SLASH)) != NULL) { *ptr = 0; php_parse_user_ini_file(path, PG(user_ini_filename), entry-user_config TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
pajoye Wed Jun 17 19:31:54 2009 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: - MF53: #47318, UMR when trying to activate user config http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.384r2=1.385diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.384 php-src/sapi/cgi/cgi_main.c:1.385 --- php-src/sapi/cgi/cgi_main.c:1.384 Tue Jun 9 13:32:12 2009 +++ php-src/sapi/cgi/cgi_main.c Wed Jun 17 19:31:54 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.384 2009/06/09 13:32:12 dsp Exp $ */ +/* $Id: cgi_main.c,v 1.385 2009/06/17 19:31:54 pajoye Exp $ */ #include php.h #include php_globals.h @@ -703,7 +703,7 @@ /* {{{ php_cgi_ini_activate_user_config */ -static void php_cgi_ini_activate_user_config(char *path, int path_len, int start TSRMLS_DC) +static void php_cgi_ini_activate_user_config(char *path, int path_len, const char *doc_root, int doc_root_len, int start TSRMLS_DC) { char *ptr; user_config_cache_entry *new_entry, *entry; @@ -721,18 +721,47 @@ /* Check whether cache entry has expired and rescan if it is */ if (request_time entry-expires) { + char * real_path; + int real_path_len; + char *s1, *s2; + int s_len; /* Clear the expired config */ zend_hash_clean(entry-user_config); - /* Walk through each directory and apply entries to user_config hash */ - ptr = path + start; /* start is the point where doc_root ends! */ - while ((ptr = strchr(ptr, DEFAULT_SLASH)) != NULL) { - *ptr = 0; + if (!IS_ABSOLUTE_PATH(path, path_len)) { + real_path = tsrm_realpath(path, NULL TSRMLS_CC); + real_path_len = strlen(real_path); + path = real_path; + path_len = real_path_len; + } + + if (path_len doc_root_len) { + s1 = (char *) doc_root; + s2 = path; + s_len = doc_root_len; + } else { + s1 = path; + s2 = (char *) doc_root; + s_len = path_len; + } + + /* we have to test if path is part of DOCUMENT_ROOT. + if it is inside the docroot, we scan the tree up to the docroot + to find more user.ini, if not we only scan the current path. + */ + if (strncmp(s1, s2, s_len) == 0) { + ptr = s1 + start; /* start is the point where doc_root ends! */ + while ((ptr = strchr(ptr, DEFAULT_SLASH)) != NULL) { + *ptr = 0; + php_parse_user_ini_file(path, PG(user_ini_filename), entry-user_config TSRMLS_CC); + *ptr = '/'; + ptr++; + } + } else { php_parse_user_ini_file(path, PG(user_ini_filename), entry-user_config TSRMLS_CC); - *ptr = '/'; - ptr++; } + entry-expires = request_time + PG(user_ini_cache_ttl); } @@ -787,10 +816,10 @@ /* DOCUMENT_ROOT should also be defined at this stage..but better check it anyway */ if (doc_root) { doc_root_len = strlen(doc_root); - if (doc_root[doc_root_len - 1] == '/') { + if (IS_SLASH(doc_root[doc_root_len - 1])) { --doc_root_len; } - php_cgi_ini_activate_user_config(path, path_len, doc_root_len - 1 TSRMLS_CC); + php_cgi_ini_activate_user_config(path, path_len, doc_root, doc_root_len, doc_root_len - 1 TSRMLS_CC); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dsp Tue Jun 9 13:32:12 2009 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fix bug #47042 (cgi sapi is incorrectly removing the SCRIPT_FILENAME for non apache). The fix was provided by Sriram Natarajan. http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.383r2=1.384diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.383 php-src/sapi/cgi/cgi_main.c:1.384 --- php-src/sapi/cgi/cgi_main.c:1.383 Thu Jun 4 11:51:10 2009 +++ php-src/sapi/cgi/cgi_main.c Tue Jun 9 13:32:12 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.383 2009/06/04 11:51:10 jani Exp $ */ +/* $Id: cgi_main.c,v 1.384 2009/06/09 13:32:12 dsp Exp $ */ #include php.h #include php_globals.h @@ -1082,8 +1082,8 @@ } if (env_path_translated != NULL env_redirect_url != NULL - orig_script_filename != NULL script_path_translated != NULL - ) { + env_path_translated != script_path_translated + strcmp(env_path_translated, script_path_translated) != 0) { /* * pretty much apache specific. If we have a redirect_url * then our script_filename and script_name point to the -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
janiThu Jun 4 11:47:51 2009 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: MFB: snprintf - slprintf (Ilia) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.381r2=1.382diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.381 php-src/sapi/cgi/cgi_main.c:1.382 --- php-src/sapi/cgi/cgi_main.c:1.381 Thu May 28 20:47:01 2009 +++ php-src/sapi/cgi/cgi_main.c Thu Jun 4 11:47:51 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.381 2009/05/28 20:47:01 kalle Exp $ */ +/* $Id: cgi_main.c,v 1.382 2009/06/04 11:47:51 jani Exp $ */ #include php.h #include php_globals.h @@ -398,7 +398,7 @@ if (CGIG(rfc2616_headers) SG(sapi_headers).http_status_line) { char *s; - len = snprintf(buf, SAPI_CGI_MAX_HEADER_LENGTH, %s\r\n, SG(sapi_headers).http_status_line); + 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)); } @@ -456,7 +456,7 @@ while (h) { /* prevent CRLFCRLF */ if (h-header_len) { - if (h-header_len sizeof(Status:)-1 + if (h-header_len sizeof(Status:)-1 strncasecmp(h-header, Status:, sizeof(Status:)-1) == 0 ) { if (!ignore_status) { @@ -565,13 +565,13 @@ #endif #if !HAVE_SETENV if (value) { - len = snprintf(buf, len - 1, %s=%s, name, value); + len = slprintf(buf, len - 1, %s=%s, name, value); putenv(buf); } #endif #if !HAVE_UNSETENV if (!value) { - len = snprintf(buf, len - 1, %s=, name); + len = slprintf(buf, len - 1, %s=, name); putenv(buf); } #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
kalle Thu May 28 20:47:01 2009 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fix compiler warnings introduced by the JIT commit http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.380r2=1.381diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.380 php-src/sapi/cgi/cgi_main.c:1.381 --- php-src/sapi/cgi/cgi_main.c:1.380 Sat May 23 18:59:17 2009 +++ php-src/sapi/cgi/cgi_main.c Thu May 28 20:47:01 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.380 2009/05/23 18:59:17 jani Exp $ */ +/* $Id: cgi_main.c,v 1.381 2009/05/28 20:47:01 kalle Exp $ */ #include php.h #include php_globals.h @@ -625,9 +625,7 @@ zend_hash_get_current_data_ex(request-env, (void **) val, pos) == SUCCESS; zend_hash_move_forward_ex(request-env, pos) ) { - unsigned int new_val_len; - - if (php_register_variable_with_conv(conv, var.s, strlen(var.s), val, strlen(*val), array_ptr, filter_arg TSRMLS_CC) == FAILURE) { + if (php_register_variable_with_conv(conv, var.s, strlen(var.s), *val, strlen(*val), array_ptr, filter_arg TSRMLS_CC) == FAILURE) { php_error(E_WARNING, Failed to decode %s array entry, (filter_arg == PARSE_ENV?_ENV:_SERVER)); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
janiSat May 23 18:59:17 2009 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: ws + cs http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.379r2=1.380diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.379 php-src/sapi/cgi/cgi_main.c:1.380 --- php-src/sapi/cgi/cgi_main.c:1.379 Sat May 23 18:03:27 2009 +++ php-src/sapi/cgi/cgi_main.c Sat May 23 18:59:17 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.379 2009/05/23 18:03:27 andrei Exp $ */ +/* $Id: cgi_main.c,v 1.380 2009/05/23 18:59:17 jani Exp $ */ #include php.h #include php_globals.h @@ -32,29 +32,37 @@ #include stdio.h #include php.h + #ifdef PHP_WIN32 -#include win32/time.h -#include win32/signal.h -#include process.h +# include win32/time.h +# include win32/signal.h +# include process.h #endif + #if HAVE_SYS_TIME_H -#include sys/time.h +# include sys/time.h #endif + #if HAVE_UNISTD_H -#include unistd.h +# include unistd.h #endif + #if HAVE_SIGNAL_H -#include signal.h +# include signal.h #endif + #if HAVE_SETLOCALE -#include locale.h +# include locale.h #endif + #if HAVE_SYS_TYPES_H -#include sys/types.h +# include sys/types.h #endif + #if HAVE_SYS_WAIT_H -#include sys/wait.h +# include sys/wait.h #endif + #include zend.h #include zend_extensions.h #include php_ini.h @@ -62,14 +70,15 @@ #include php_main.h #include fopen_wrappers.h #include ext/standard/php_standard.h + #ifdef PHP_WIN32 -#include io.h -#include fcntl.h -#include win32/php_registry.h +# include io.h +# include fcntl.h +# include win32/php_registry.h #endif #ifdef __riscos__ -#include unixlib/local.h +# include unixlib/local.h int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS; #endif @@ -164,7 +173,7 @@ /* {{{ user_config_cache * * Key for each cache entry is dirname(PATH_TRANSLATED). - * + * * NOTE: Each cache entry config_hash contains the combination from all user ini files found in * the path starting from doc_root throught to dirname(PATH_TRANSLATED). There is no point * storing per-file entries as it would not be possible to detect added / deleted entries @@ -412,7 +421,8 @@ h = (sapi_header_struct*)zend_llist_get_first_ex(sapi_headers-headers, pos); while (h) { if (h-header_len sizeof(Status:)-1 - strncasecmp(h-header, Status:, sizeof(Status:)-1) == 0) { + strncasecmp(h-header, Status:, sizeof(Status:)-1) == 0 + ) { has_status = 1; break; } @@ -422,7 +432,7 @@ http_error *err = (http_error*)http_error_codes; while (err-code != 0) { - if (err-code == SG(sapi_headers).http_response_code) { + if (err-code == SG(sapi_headers).http_response_code) { break; } err++; @@ -447,14 +457,16 @@ /* prevent CRLFCRLF */ if (h-header_len) { if (h-header_len sizeof(Status:)-1 - strncasecmp(h-header, Status:, sizeof(Status:)-1) == 0) { - if (!ignore_status) { - ignore_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) { + } 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 { @@ -494,9 +506,9 @@ static char *sapi_cgibin_getenv(char *name, size_t name_len TSRMLS_DC) { /* when php is started by mod_fastcgi, no
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c fastcgi.c
kalle Tue May 19 16:02:38 2009 UTC Modified files: /php-src/sapi/cgi cgi_main.c fastcgi.c Log: Fix compiler warnings, and some unicode stuff http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.377r2=1.378diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.377 php-src/sapi/cgi/cgi_main.c:1.378 --- php-src/sapi/cgi/cgi_main.c:1.377 Tue Mar 10 23:40:02 2009 +++ php-src/sapi/cgi/cgi_main.c Tue May 19 16:02:38 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.377 2009/03/10 23:40:02 helly Exp $ */ +/* $Id: cgi_main.c,v 1.378 2009/05/19 16:02:38 kalle Exp $ */ #include php.h #include php_globals.h @@ -472,7 +472,8 @@ static int sapi_cgi_read_post(char *buffer, uint count_bytes TSRMLS_DC) { - int read_bytes=0, tmp_read_bytes; + uint read_bytes = 0; + int tmp_read_bytes; count_bytes = MIN(count_bytes, (uint) SG(request_info).content_length - SG(read_post_bytes)); while (read_bytes count_bytes) { http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.54r2=1.55diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.54 php-src/sapi/cgi/fastcgi.c:1.55 --- php-src/sapi/cgi/fastcgi.c:1.54 Tue Mar 10 23:40:02 2009 +++ php-src/sapi/cgi/fastcgi.c Tue May 19 16:02:38 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.54 2009/03/10 23:40:02 helly Exp $ */ +/* $Id: fastcgi.c,v 1.55 2009/05/19 16:02:38 kalle Exp $ */ #include php.h #include fastcgi.h @@ -746,7 +746,7 @@ } else if (hdr.type == FCGI_GET_VALUES) { unsigned char *p = buf + sizeof(fcgi_header); HashPosition pos; - char * str_index; + zstr key; uint str_length; ulong num_index; int key_type; @@ -763,13 +763,13 @@ } 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) { + while ((key_type = zend_hash_get_current_key_ex(req-env, key, 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) { + if (zend_hash_find(fcgi_mgmt_vars, key.s, str_length, (void**) value) != SUCCESS) { continue; } --str_length; @@ -793,7 +793,7 @@ *p++ = (zlen 8) 0xff; *p++ = zlen 0xff; } - memcpy(p, str_index, str_length); + memcpy(p, key.s, str_length); p += str_length; memcpy(p, Z_STRVAL_PP(value), zlen); p += zlen; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dsp Mon Jan 19 18:16:53 2009 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fix #47149. Remove check for script_filename = path_translated, as this the actual value that we get from apache. http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.375r2=1.376diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.375 php-src/sapi/cgi/cgi_main.c:1.376 --- php-src/sapi/cgi/cgi_main.c:1.375 Sun Jan 11 08:35:53 2009 +++ php-src/sapi/cgi/cgi_main.c Mon Jan 19 18:16:52 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.375 2009/01/11 08:35:53 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.376 2009/01/19 18:16:52 dsp Exp $ */ #include php.h #include php_globals.h @@ -1063,8 +1063,7 @@ } if (env_path_translated != NULL env_redirect_url != NULL - orig_script_filename != NULL script_path_translated != NULL - strcmp(orig_script_filename, script_path_translated) != 0) { + 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 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Sun Jan 11 08:35:53 2009 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Disable dl() in CGI and FastCGI modes http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.374r2=1.375diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.374 php-src/sapi/cgi/cgi_main.c:1.375 --- php-src/sapi/cgi/cgi_main.c:1.374 Fri Jan 9 22:13:40 2009 +++ php-src/sapi/cgi/cgi_main.c Sun Jan 11 08:35:53 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.374 2009/01/09 22:13:40 dsp Exp $ */ +/* $Id: cgi_main.c,v 1.375 2009/01/11 08:35:53 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1545,7 +1545,9 @@ #endif cgi_sapi_module.executable_location = argv[0]; - cgi_sapi_module.additional_functions = additional_functions; + if (!cgi !fastcgi !bindpath) { + cgi_sapi_module.additional_functions = additional_functions; + } /* startup after we get the above ini override se we get things right */ if (cgi_sapi_module.startup(cgi_sapi_module) == FAILURE) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dsp Fri Jan 9 22:13:40 2009 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed bug #47042 (PHP cgi sapi is removing SCRIPT_FILENAME for non apache). http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.373r2=1.374diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.373 php-src/sapi/cgi/cgi_main.c:1.374 --- php-src/sapi/cgi/cgi_main.c:1.373 Wed Dec 31 11:12:39 2008 +++ php-src/sapi/cgi/cgi_main.c Fri Jan 9 22:13:40 2009 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.373 2008/12/31 11:12:39 sebastian Exp $ */ +/* $Id: cgi_main.c,v 1.374 2009/01/09 22:13:40 dsp Exp $ */ #include php.h #include php_globals.h @@ -1062,7 +1062,9 @@ 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 + strcmp(orig_script_filename, script_path_translated) != 0) { /* pretty much apache specific. If we have a redirect_url then our script_filename and script_name point to the -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Fri Nov 28 11:57:11 2008 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed bug #46366 (bad cwd with / as pathinfo) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.371r2=1.372diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.371 php-src/sapi/cgi/cgi_main.c:1.372 --- php-src/sapi/cgi/cgi_main.c:1.371 Mon Nov 17 11:26:25 2008 +++ php-src/sapi/cgi/cgi_main.c Fri Nov 28 11:57:11 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.371 2008/11/17 11:26:25 felipe Exp $ */ +/* $Id: cgi_main.c,v 1.372 2008/11/28 11:57:11 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1087,6 +1087,9 @@ 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); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
rasmus Sun Nov 9 15:50:13 2008 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fix for bug #46525 which fixes Ilia's fix for bug #46319 http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.369r2=1.370diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.369 php-src/sapi/cgi/cgi_main.c:1.370 --- php-src/sapi/cgi/cgi_main.c:1.369 Sun Nov 2 21:10:12 2008 +++ php-src/sapi/cgi/cgi_main.c Sun Nov 9 15:50:13 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.369 2008/11/02 21:10:12 felipe Exp $ */ +/* $Id: cgi_main.c,v 1.370 2008/11/09 15:50:13 rasmus Exp $ */ #include php.h #include php_globals.h @@ -455,6 +455,7 @@ } } 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); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
Thanks. On 9-Nov-08, at 10:50 AM, Rasmus Lerdorf wrote: rasmus Sun Nov 9 15:50:13 2008 UTC Modified files: /php-src/sapi/cgicgi_main.c Log: Fix for bug #46525 which fixes Ilia's fix for bug #46319 http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.369r2=1.370diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.369 php-src/sapi/cgi/ cgi_main.c:1.370 --- php-src/sapi/cgi/cgi_main.c:1.369 Sun Nov 2 21:10:12 2008 +++ php-src/sapi/cgi/cgi_main.c Sun Nov 9 15:50:13 2008 @@ -21,7 +21,7 @@ + --+ */ -/* $Id: cgi_main.c,v 1.369 2008/11/02 21:10:12 felipe Exp $ */ +/* $Id: cgi_main.c,v 1.370 2008/11/09 15:50:13 rasmus Exp $ */ #include php.h #include php_globals.h @@ -455,6 +455,7 @@ } } 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); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Ilia Alshanetsky -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c fastcgi.c fastcgi.h
lbarnaudTue Oct 21 03:19:08 2008 UTC Modified files: /php-src/sapi/cgi cgi_main.c fastcgi.c fastcgi.h Log: Fixed FCGI_GET_VALUES requests (fixes #45522) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.366r2=1.367diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.366 php-src/sapi/cgi/cgi_main.c:1.367 --- php-src/sapi/cgi/cgi_main.c:1.366 Fri Oct 17 01:34:26 2008 +++ php-src/sapi/cgi/cgi_main.c Tue Oct 21 03:19:07 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.366 2008/10/17 01:34:26 iliaa Exp $ */ +/* $Id: cgi_main.c,v 1.367 2008/10/21 03:19:07 lbarnaud Exp $ */ #include php.h #include php_globals.h @@ -1619,11 +1619,18 @@ #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) { http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.48r2=1.49diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.48 php-src/sapi/cgi/fastcgi.c:1.49 --- php-src/sapi/cgi/fastcgi.c:1.48 Tue Aug 26 09:56:22 2008 +++ php-src/sapi/cgi/fastcgi.c Tue Oct 21 03:19:07 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.48 2008/08/26 09:56:22 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.49 2008/10/21 03:19:07 lbarnaud Exp $ */ #include php.h #include fastcgi.h @@ -133,18 +133,7 @@ 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; @@ -193,12 +182,17 @@ void fcgi_shutdown(void) { + if (is_initialized) { + zend_hash_destroy(fcgi_mgmt_vars); + } is_fastcgi = 0; } int fcgi_init(void) { if (!is_initialized) { + 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); #ifdef _WIN32 # if 0 /* TODO: Support for TCP sockets */ @@ -750,8 +744,13 @@ 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; @@ -763,11 +762,41 @@ 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; + }
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
iliaa Fri Oct 17 01:34:27 2008 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: MFB: Fixed bug #46319 (PHP sets default Content-Type header for HTTP 304 response code, in cgi sapi) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.365r2=1.366diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.365 php-src/sapi/cgi/cgi_main.c:1.366 --- php-src/sapi/cgi/cgi_main.c:1.365 Tue Sep 2 13:22:27 2008 +++ php-src/sapi/cgi/cgi_main.c Fri Oct 17 01:34:26 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.365 2008/09/02 13:22:27 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.366 2008/10/17 01:34:26 iliaa Exp $ */ #include php.h #include php_globals.h @@ -376,6 +376,7 @@ 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; @@ -387,7 +388,11 @@ zend_bool has_status = 0; if (CGIG(rfc2616_headers) SG(sapi_headers).http_status_line) { + char *s; len = snprintf(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; @@ -402,6 +407,7 @@ 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) { @@ -447,6 +453,9 @@ 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) { + continue; } else { PHPWRITE_H(h-header, h-header_len); PHPWRITE_H(\r\n, 2); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c fastcgi.c fastcgi.h
dmitry Tue Aug 26 09:56:23 2008 UTC Modified files: /php-src/sapi/cgi cgi_main.c fastcgi.c fastcgi.h Log: Fixed bug #45786 (FastCGI process exited unexpectedly) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.362r2=1.363diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.362 php-src/sapi/cgi/cgi_main.c:1.363 --- php-src/sapi/cgi/cgi_main.c:1.362 Mon Aug 18 10:48:49 2008 +++ php-src/sapi/cgi/cgi_main.c Tue Aug 26 09:56:22 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.362 2008/08/18 10:48:49 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.363 2008/08/26 09:56:22 dmitry Exp $ */ #include php.h #include php_globals.h @@ -774,7 +774,7 @@ #ifndef PHP_WIN32 !parent #endif - !fcgi_finish_request((fcgi_request*)SG(server_context))) { + !fcgi_finish_request((fcgi_request*)SG(server_context), 0)) { php_handle_aborted_connection(); } } else { @@ -1921,7 +1921,7 @@ get path_translated */ if (php_request_startup(TSRMLS_C) == FAILURE) { if (fastcgi) { - fcgi_finish_request(request); + fcgi_finish_request(request, 1); } SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); @@ -2064,7 +2064,7 @@ /* only fastcgi will get here */ requests++; if (max_requests (requests == max_requests)) { - fcgi_finish_request(request); + fcgi_finish_request(request, 1); if (bindpath) { free(bindpath); } http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.47r2=1.48diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.47 php-src/sapi/cgi/fastcgi.c:1.48 --- php-src/sapi/cgi/fastcgi.c:1.47 Mon Aug 18 10:48:49 2008 +++ php-src/sapi/cgi/fastcgi.c Tue Aug 26 09:56:22 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.47 2008/08/18 10:48:49 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.48 2008/08/26 09:56:22 dmitry Exp $ */ #include php.h #include fastcgi.h @@ -662,6 +662,7 @@ unsigned char buf[FCGI_MAX_LENGTH+8]; req-keep = 0; + req-closed = 0; req-in_len = 0; req-out_hdr = NULL; req-out_pos = req-out_buf; @@ -886,7 +887,6 @@ HANDLE pipe; OVERLAPPED ov; #endif - fcgi_finish_request(req); while (1) { if (req-fd 0) { @@ -1177,13 +1177,16 @@ return len; } -int fcgi_finish_request(fcgi_request *req) +int fcgi_finish_request(fcgi_request *req, int force_close) { int ret = 1; if (req-fd = 0) { - ret = fcgi_flush(req, 1); - fcgi_close(req, 0, 1); + if (!req-closed) { + ret = fcgi_flush(req, 1); + req-closed = 1; + } + fcgi_close(req, force_close, 1); } return ret; } http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.h?r1=1.11r2=1.12diff_format=u Index: php-src/sapi/cgi/fastcgi.h diff -u php-src/sapi/cgi/fastcgi.h:1.11 php-src/sapi/cgi/fastcgi.h:1.12 --- php-src/sapi/cgi/fastcgi.h:1.11 Mon Aug 18 10:48:49 2008 +++ php-src/sapi/cgi/fastcgi.h Tue Aug 26 09:56:22 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.h,v 1.11 2008/08/18 10:48:49 dmitry Exp $ */ +/* $Id: fastcgi.h,v 1.12 2008/08/26 09:56:22 dmitry Exp $ */ /* FastCGI protocol */ @@ -99,6 +99,7 @@ intfd; intid; intkeep; + intclosed; intin_len; intin_pad; @@ -118,7 +119,7 @@ int fcgi_listen(const char *path, int backlog); void fcgi_init_request(fcgi_request *req, int listen_socket); int fcgi_accept_request(fcgi_request *req); -int fcgi_finish_request(fcgi_request *req); +int fcgi_finish_request(fcgi_request *req, int force_close); char* fcgi_getenv(fcgi_request *req, const char* var, int var_len); char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
rasmus Tue Aug 26 15:37:38 2008 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Remove stray folding tag here http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.363r2=1.364diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.363 php-src/sapi/cgi/cgi_main.c:1.364 --- php-src/sapi/cgi/cgi_main.c:1.363 Tue Aug 26 09:56:22 2008 +++ php-src/sapi/cgi/cgi_main.c Tue Aug 26 15:37:38 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.363 2008/08/26 09:56:22 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.364 2008/08/26 15:37:38 rasmus Exp $ */ #include php.h #include php_globals.h @@ -175,7 +175,7 @@ HashTable *user_config; } user_config_cache_entry; -static void user_config_cache_entry_dtor(user_config_cache_entry *entry) /* {{{ */ +static void user_config_cache_entry_dtor(user_config_cache_entry *entry) { zend_hash_destroy(entry-user_config); free(entry-user_config); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c fastcgi.c fastcgi.h
dmitry Mon Aug 18 10:48:49 2008 UTC Modified files: /php-src/sapi/cgi cgi_main.c fastcgi.c fastcgi.h Log: Fix for bug #45786 (FastCGI process exited unexpectedly) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.361r2=1.362diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.361 php-src/sapi/cgi/cgi_main.c:1.362 --- php-src/sapi/cgi/cgi_main.c:1.361 Fri Aug 15 07:31:07 2008 +++ php-src/sapi/cgi/cgi_main.c Mon Aug 18 10:48:49 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.361 2008/08/15 07:31:07 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.362 2008/08/18 10:48:49 dmitry Exp $ */ #include php.h #include php_globals.h @@ -585,10 +585,10 @@ ulong idx; int filter_arg = (array_ptr == PG(http_globals)[TRACK_VARS_ENV])?PARSE_ENV:PARSE_SERVER; - for (zend_hash_internal_pointer_reset_ex(request-env, pos); -zend_hash_get_current_key_ex(request-env, var, var_len, idx, 0, pos) == HASH_KEY_IS_STRING -zend_hash_get_current_data_ex(request-env, (void **) val, pos) == SUCCESS; -zend_hash_move_forward_ex(request-env, pos) + for (zend_hash_internal_pointer_reset_ex(request-env, pos); +zend_hash_get_current_key_ex(request-env, var, var_len, idx, 0, pos) == HASH_KEY_IS_STRING +zend_hash_get_current_data_ex(request-env, (void **) val, pos) == SUCCESS; +zend_hash_move_forward_ex(request-env, pos) ) { unsigned int new_val_len; http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.46r2=1.47diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.46 php-src/sapi/cgi/fastcgi.c:1.47 --- php-src/sapi/cgi/fastcgi.c:1.46 Tue Jul 15 13:10:42 2008 +++ php-src/sapi/cgi/fastcgi.c Mon Aug 18 10:48:49 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.46 2008/07/15 13:10:42 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.47 2008/08/18 10:48:49 dmitry Exp $ */ #include php.h #include fastcgi.h @@ -641,7 +641,7 @@ memcpy(tmp, p, name_len); tmp[name_len] = 0; s = estrndup((char*)p + name_len, val_len); - zend_hash_update(req-env, tmp, name_len+1, s, sizeof(char*), NULL); + zend_hash_update(req-env, tmp, name_len+1, s, sizeof(char*), NULL); p += name_len + val_len; } if (tmp != buf tmp != NULL) { @@ -665,7 +665,8 @@ req-in_len = 0; req-out_hdr = NULL; req-out_pos = req-out_buf; - zend_hash_init(req-env, 0, NULL, (void (*)(void *)) fcgi_free_var, 0); + ALLOC_HASHTABLE(req-env); + zend_hash_init(req-env, 0, NULL, (void (*)(void *)) fcgi_free_var, 0); if (safe_read(req, hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) || hdr.version FCGI_VERSION_1) { @@ -702,15 +703,15 @@ switch fcgi_begin_request*)buf)-roleB1 8) + ((fcgi_begin_request*)buf)-roleB0) { case FCGI_RESPONDER: val = estrdup(RESPONDER); - zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); + zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); break; case FCGI_AUTHORIZER: val = estrdup(AUTHORIZER); - zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); + zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); break; case FCGI_FILTER: val = estrdup(FILTER); - zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); + zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); break; default: return 0; @@ -762,7 +763,7 @@ } 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) { + 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 +=
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Fri Aug 15 07:31:08 2008 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed double call to MSHUTDOWN in case of `php-cgi -m` http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.360r2=1.361diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.360 php-src/sapi/cgi/cgi_main.c:1.361 --- php-src/sapi/cgi/cgi_main.c:1.360 Wed Aug 13 00:49:59 2008 +++ php-src/sapi/cgi/cgi_main.c Fri Aug 15 07:31:07 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.360 2008/08/13 00:49:59 jani Exp $ */ +/* $Id: cgi_main.c,v 1.361 2008/08/15 07:31:07 dmitry Exp $ */ #include php.h #include php_globals.h @@ -247,6 +247,7 @@ 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); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c fastcgi.c
dmitry Tue Jul 15 13:10:42 2008 UTC Modified files: /php-src/sapi/cgi cgi_main.c fastcgi.c Log: Fixed bug #45423 (fastcgi parent process doesn't invoke php_module_shutdown before shutdown) (basant dot kukreja at sun dot com) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.356r2=1.357diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.356 php-src/sapi/cgi/cgi_main.c:1.357 --- php-src/sapi/cgi/cgi_main.c:1.356 Mon Jun 23 11:38:10 2008 +++ php-src/sapi/cgi/cgi_main.c Tue Jul 15 13:10:42 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.356 2008/06/23 11:38:10 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.357 2008/07/15 13:10:42 dmitry Exp $ */ #include php.h #include php_globals.h @@ -101,6 +101,12 @@ */ 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 */ @@ -1235,6 +1241,7 @@ } /* }}} */ +#ifndef PHP_WIN32 /** * Clean up child processes upon exit */ @@ -1244,16 +1251,18 @@ 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 PHP_INI_BEGIN() STD_PHP_INI_ENTRY(cgi.rfc2616_headers, 0, PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals) @@ -1596,7 +1605,7 @@ } if (fcgi_in_shutdown()) { - exit(0); + goto parent_out; } while (parent) { @@ -1633,9 +1642,25 @@ #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 { @@ -2098,6 +2123,10 @@ #endif } +#ifndef PHP_WIN32 +parent_out: +#endif + SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); sapi_shutdown(); http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.45r2=1.46diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.45 php-src/sapi/cgi/fastcgi.c:1.46 --- php-src/sapi/cgi/fastcgi.c:1.45 Thu Apr 3 10:25:08 2008 +++ php-src/sapi/cgi/fastcgi.c Tue Jul 15 13:10:42 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.45 2008/04/03 10:25:08 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.46 2008/07/15 13:10:42 dmitry Exp $ */ #include php.h #include fastcgi.h @@ -170,6 +170,20 @@ } } +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) @@ -229,18 +243,7 @@ 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 =
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Tue Jul 15 13:38:57 2008 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed bug #45151 (Crash with URI/file..php (filename contains 2 dots)) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.357r2=1.358diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.357 php-src/sapi/cgi/cgi_main.c:1.358 --- php-src/sapi/cgi/cgi_main.c:1.357 Tue Jul 15 13:10:42 2008 +++ php-src/sapi/cgi/cgi_main.c Tue Jul 15 13:38:56 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.357 2008/07/15 13:10:42 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.358 2008/07/15 13:38:56 dmitry Exp $ */ #include php.h #include php_globals.h @@ -876,6 +876,39 @@ } /* }}} */ +/* {{{ 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 @@ -1171,9 +1204,7 @@ 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 { @@ -1204,9 +1235,7 @@ } 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); @@ -1221,9 +1250,7 @@ if (!CGIG(discard_path) env_path_translated) { script_path_translated = env_path_translated; } - /* 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); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Mon Jun 23 11:38:10 2008 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed possible buffer overflow http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.355r2=1.356diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.355 php-src/sapi/cgi/cgi_main.c:1.356 --- php-src/sapi/cgi/cgi_main.c:1.355 Tue Apr 15 11:32:13 2008 +++ php-src/sapi/cgi/cgi_main.c Mon Jun 23 11:38:10 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.355 2008/04/15 11:32:13 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.356 2008/06/23 11:38:10 dmitry Exp $ */ #include php.h #include php_globals.h @@ -721,12 +721,16 @@ (PG(user_ini_filename) *PG(user_ini_filename))) { /* Prepare search path */ path_len = strlen(SG(request_info).path_translated); - path = estrndup(SG(request_info).path_translated, path_len); - path_len = zend_dirname(path, path_len); /* Make sure we have trailing slash! */ - if (!IS_SLASH(path[path_len])) { + if (!IS_SLASH(SG(request_info).path_translated[path_len])) { + path = emalloc(path_len + 2); + memcpy(path, SG(request_info).path_translated, path_len + 1); + path_len = zend_dirname(path, path_len); path[path_len++] = DEFAULT_SLASH; + } else { + path = estrndup(SG(request_info).path_translated, path_len); + path_len = zend_dirname(path, path_len); } path[path_len] = 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Wed Apr 9 09:17:02 2008 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed bug #44673 (With CGI argv/argc starts from arguments, not from script) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.353r2=1.354diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.353 php-src/sapi/cgi/cgi_main.c:1.354 --- php-src/sapi/cgi/cgi_main.c:1.353 Wed Mar 26 14:46:17 2008 +++ php-src/sapi/cgi/cgi_main.c Wed Apr 9 09:17:01 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.353 2008/03/26 14:46:17 scottmac Exp $ */ +/* $Id: cgi_main.c,v 1.354 2008/04/09 09:17:01 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1805,7 +1805,7 @@ } else if (argc php_optind) { /* file is on command line, but not in -f opt */ STR_FREE(SG(request_info).path_translated); - SG(request_info).path_translated = estrdup(argv[php_optind++]); + SG(request_info).path_translated = estrdup(argv[php_optind]); /* arguments after the file are considered script args */ SG(request_info).argc = argc - php_optind; SG(request_info).argv = argv[php_optind]; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
iliaa Thu Feb 28 00:52:11 2008 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: MFB: Fixed security issue detailed in CVE-2008-0599 http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.349r2=1.350diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.349 php-src/sapi/cgi/cgi_main.c:1.350 --- php-src/sapi/cgi/cgi_main.c:1.349 Fri Feb 15 14:51:52 2008 +++ php-src/sapi/cgi/cgi_main.c Thu Feb 28 00:52:11 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.349 2008/02/15 14:51:52 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.350 2008/02/28 00:52:11 iliaa Exp $ */ #include php.h #include php_globals.h @@ -,7 +,7 @@ ) { /* PATH_TRANSLATED = PATH_TRANSLATED - SCRIPT_NAME + PATH_INFO */ int ptlen = strlen(pt) - strlen(env_script_name); - int path_translated_len = ptlen + env_path_info ? strlen(env_path_info) : 0; + int path_translated_len = ptlen + (env_path_info ? strlen(env_path_info) : 0); char *path_translated = NULL; path_translated = (char *) emalloc(path_translated_len + 1); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c fastcgi.c
dmitry Fri Feb 15 14:51:53 2008 UTC Modified files: /php-src/sapi/cgi cgi_main.c fastcgi.c Log: optimization http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.348r2=1.349diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.348 php-src/sapi/cgi/cgi_main.c:1.349 --- php-src/sapi/cgi/cgi_main.c:1.348 Mon Dec 31 07:12:19 2007 +++ php-src/sapi/cgi/cgi_main.c Fri Feb 15 14:51:52 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.348 2007/12/31 07:12:19 sebastian Exp $ */ +/* $Id: cgi_main.c,v 1.349 2008/02/15 14:51:52 dmitry Exp $ */ #include php.h #include php_globals.h @@ -754,7 +754,17 @@ 2. When the first call occurs and the request is not set up, flush fails on FastCGI. */ if (SG(sapi_started)) { - sapi_cgibin_flush(SG(server_context)); + if (fcgi_is_fastcgi()) { + if ( +#ifndef PHP_WIN32 + !parent +#endif + !fcgi_finish_request((fcgi_request*)SG(server_context))) { + php_handle_aborted_connection(); + } + } else { + sapi_cgibin_flush(SG(server_context)); + } } return SUCCESS; } http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.43r2=1.44diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.43 php-src/sapi/cgi/fastcgi.c:1.44 --- php-src/sapi/cgi/fastcgi.c:1.43 Mon Dec 31 07:12:19 2007 +++ php-src/sapi/cgi/fastcgi.c Fri Feb 15 14:51:52 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.43 2007/12/31 07:12:19 sebastian Exp $ */ +/* $Id: fastcgi.c,v 1.44 2008/02/15 14:51:52 dmitry Exp $ */ #include php.h #include fastcgi.h @@ -632,7 +632,7 @@ } memcpy(tmp, p, name_len); tmp[name_len] = 0; - s = zend_strndup((char*)p + name_len, val_len); + s = estrndup((char*)p + name_len, val_len); zend_hash_update(req-env, tmp, name_len+1, s, sizeof(char*), NULL); p += name_len + val_len; } @@ -644,7 +644,7 @@ static void fcgi_free_var(char **s) { - free(*s); + efree(*s); } static int fcgi_read_request(fcgi_request *req) @@ -657,7 +657,7 @@ req-in_len = 0; req-out_hdr = NULL; req-out_pos = req-out_buf; - zend_hash_init(req-env, 0, NULL, (void (*)(void *)) fcgi_free_var, 1); + zend_hash_init(req-env, 0, NULL, (void (*)(void *)) fcgi_free_var, 0); if (safe_read(req, hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) || hdr.version FCGI_VERSION_1) { @@ -693,15 +693,15 @@ req-keep = (((fcgi_begin_request*)buf)-flags FCGI_KEEP_CONN); switch fcgi_begin_request*)buf)-roleB1 8) + ((fcgi_begin_request*)buf)-roleB0) { case FCGI_RESPONDER: - val = strdup(RESPONDER); + val = estrdup(RESPONDER); zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); break; case FCGI_AUTHORIZER: - val = strdup(AUTHORIZER); + val = estrdup(AUTHORIZER); zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); break; case FCGI_FILTER: - val = strdup(FILTER); + val = estrdup(FILTER); zend_hash_update(req-env, FCGI_ROLE, sizeof(FCGI_ROLE), val, sizeof(char*), NULL); break; default: @@ -1168,11 +1168,13 @@ int fcgi_finish_request(fcgi_request *req) { + int ret = 1; + if (req-fd = 0) { - fcgi_flush(req, 1); + ret = fcgi_flush(req, 1); fcgi_close(req, 0, 1); } - return 1; + return ret; } char* fcgi_getenv(fcgi_request *req, const char* var, int var_len) @@ -1195,7 +1197,7 @@ } else { char **ret; - val = strdup(val); + val = estrdup(val); if (zend_hash_update(req-env, var, var_len+1, val, sizeof(char*), (void**)ret) == SUCCESS) { return *ret; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Mon Dec 3 09:38:25 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: The -f option is fixed to work in the same way as in CLI sapi http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.346r2=1.347diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.346 php-src/sapi/cgi/cgi_main.c:1.347 --- php-src/sapi/cgi/cgi_main.c:1.346 Fri Nov 9 16:02:50 2007 +++ php-src/sapi/cgi/cgi_main.c Mon Dec 3 09:38:25 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.346 2007/11/09 16:02:50 jani Exp $ */ +/* $Id: cgi_main.c,v 1.347 2007/12/03 09:38:25 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1697,12 +1697,12 @@ } script_file = estrdup(php_optarg); no_headers = 1; - /* arguments after the file are considered script args */ - SG(request_info).argc = argc - (php_optind - 1); - SG(request_info).argv = argv[php_optind - 1]; break; case 'i': /* php info quit */ + if (script_file) { + efree(script_file); + } if (php_request_startup(TSRMLS_C) == FAILURE) { SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); @@ -1723,6 +1723,9 @@ break; case 'm': /* list compiled in modules */ + if (script_file) { + efree(script_file); + } SG(headers_sent) = 1; php_printf([PHP Modules]\n); print_modules(TSRMLS_C); @@ -1744,6 +1747,9 @@ break; case 'v': /* show php version quit */ + if (script_file) { + efree(script_file); + } no_headers = 1; if (php_request_startup(TSRMLS_C) == FAILURE) { SG(server_context) = NULL; @@ -1780,6 +1786,18 @@ /* override path_translated if -f on command line */ STR_FREE(SG(request_info).path_translated); SG(request_info).path_translated = script_file; + /* before registering argv to module exchange the *new* argv[0] */ + /* we can achieve this without allocating more memory */ + SG(request_info).argc = argc - (php_optind - 1); + SG(request_info).argv = argv[php_optind - 1]; + SG(request_info).argv[0] = script_file; + } else if (argc php_optind) { + /* file is on command line, but not in -f opt */ + STR_FREE(SG(request_info).path_translated); + SG(request_info).path_translated = estrdup(argv[php_optind++]); + /* arguments after the file are considered script args */ + SG(request_info).argc = argc - php_optind; + SG(request_info).argv = argv[php_optind]; } if (no_headers) { @@ -1787,14 +1805,6 @@ SG(request_info).no_headers = 1; } - if (!SG(request_info).path_translated argc php_optind) { -
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Thu Nov 1 11:13:07 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed bug #42848 (Status: header incorrect under FastCGI) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.343r2=1.344diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.343 php-src/sapi/cgi/cgi_main.c:1.344 --- php-src/sapi/cgi/cgi_main.c:1.343 Fri Oct 26 04:46:28 2007 +++ php-src/sapi/cgi/cgi_main.c Thu Nov 1 11:13:06 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.343 2007/10/26 04:46:28 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.344 2007/11/01 11:13:06 dmitry Exp $ */ #include php.h #include php_globals.h @@ -318,6 +318,52 @@ #define SAPI_CGI_MAX_HEADER_LENGTH 1024 +typedef struct _http_error { + int code; + const char* msg; +} http_error; + +static const http_error http_error_codes[] = { + {100, Continue}, + {101, Switching Protocols}, + {200, OK}, + {201, Created}, + {202, Accepted}, + {203, Non-Authoritative Information}, + {204, No Content}, + {205, Reset Content}, + {206, Partial Content}, + {300, Multiple Choices}, + {301, Moved Permanently}, + {302, Moved Temporarily}, + {303, See Other}, + {304, Not Modified}, + {305, Use Proxy}, + {400, Bad Request}, + {401, Unauthorized}, + {402, Payment Required}, + {403, Forbidden}, + {404, Not Found}, + {405, Method Not Allowed}, + {406, Not Acceptable}, + {407, Proxy Authentication Required}, + {408, Request Time-out}, + {409, Conflict}, + {410, Gone}, + {411, Length Required}, + {412, Precondition Failed}, + {413, Request Entity Too Large}, + {414, Request-URI Too Large}, + {415, Unsupported Media Type}, + {500, Internal Server Error}, + {501, Not Implemented}, + {502, Bad Gateway}, + {503, Service Unavailable}, + {504, Gateway Time-out}, + {505, HTTP Version not supported}, + {0, NULL} +}; + static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { char buf[SAPI_CGI_MAX_HEADER_LENGTH]; @@ -331,6 +377,7 @@ if (CGIG(nph) || SG(sapi_headers).http_response_code != 200) { int len; + zend_bool has_status = 0; if (CGIG(rfc2616_headers) SG(sapi_headers).http_status_line) { len = snprintf(buf, SAPI_CGI_MAX_HEADER_LENGTH, %s\r\n, SG(sapi_headers).http_status_line); @@ -349,11 +396,36 @@ ) { len = sprintf(buf, Status:%s\r\n, s); } else { - len = sprintf(buf, Status: %d\r\n, SG(sapi_headers).http_response_code); + h = (sapi_header_struct*)zend_llist_get_first_ex(sapi_headers-headers, pos); + while (h) { + if (h-header_len sizeof(Status:)-1 + strncasecmp(h-header, Status:, sizeof(Status:)-1) == 0) { + has_status = 1; + break; + } + h = (sapi_header_struct*)zend_llist_get_next_ex(sapi_headers-headers, pos); + } + if (!has_status) { + http_error *err = (http_error*)http_error_codes; + + while (err-code != 0) { + if (err-code == SG(sapi_headers).http_response_code) { + break; + } + err++; + } + if (err-msg) { + len = slprintf(buf, sizeof(buf), Status: %d %s\r\n, SG(sapi_headers).http_response_code, err-msg); + } else { + len = slprintf(buf, sizeof(buf), Status: %d\r\n, SG(sapi_headers).http_response_code); + } + } } } - PHPWRITE_H(buf, len); + if (!has_status) { + PHPWRITE_H(buf, len); + } } h = (sapi_header_struct*)zend_llist_get_first_ex(sapi_headers-headers, pos); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Thu Nov 1 11:49:28 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: use slprintf() http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.344r2=1.345diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.344 php-src/sapi/cgi/cgi_main.c:1.345 --- php-src/sapi/cgi/cgi_main.c:1.344 Thu Nov 1 11:13:06 2007 +++ php-src/sapi/cgi/cgi_main.c Thu Nov 1 11:49:27 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.344 2007/11/01 11:13:06 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.345 2007/11/01 11:49:27 dmitry Exp $ */ #include php.h #include php_globals.h @@ -394,7 +394,7 @@ (s - SG(sapi_headers).http_status_line) = 5 strncasecmp(SG(sapi_headers).http_status_line, HTTP/, 5) == 0 ) { - len = sprintf(buf, Status:%s\r\n, s); + len = slprintf(buf, sizeof(buf), Status:%s\r\n, s); } else { h = (sapi_header_struct*)zend_llist_get_first_ex(sapi_headers-headers, pos); while (h) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
janiThu Oct 25 10:01:25 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: ws http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.341r2=1.342diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.341 php-src/sapi/cgi/cgi_main.c:1.342 --- php-src/sapi/cgi/cgi_main.c:1.341 Thu Oct 25 05:39:24 2007 +++ php-src/sapi/cgi/cgi_main.c Thu Oct 25 10:01:25 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.341 2007/10/25 05:39:24 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.342 2007/10/25 10:01:25 jani Exp $ */ #include php.h #include php_globals.h @@ -769,7 +769,7 @@ -v Version number\n -w Display source with stripped comments and whitespace.\n -z fileLoad Zend extension file.\n --T count Measure execution time of script repeated count times.\n, + -T count Measure execution time of script repeated count times.\n, prog, prog); } /* }}} */ @@ -1549,7 +1549,7 @@ while ((c = php_getopt(argc, argv, OPTIONS, php_optarg, php_optind, 1, 2)) != -1) { switch (c) { case 'T': - benchmark = 1; + benchmark = 1; repeats = atoi(php_optarg); gettimeofday(start, NULL); break; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
And you're sure gettimeofday() is available always? Hint: It isn't. :) --Jani On Thu, 2007-10-25 at 05:39 +, Dmitry Stogov wrote: dmitryThu Oct 25 05:39:24 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Added CGI SAPI -T option, to measure execution time of script repeated several times. http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.340r2=1.341diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.340 php-src/sapi/cgi/cgi_main.c:1.341 --- php-src/sapi/cgi/cgi_main.c:1.340 Mon Oct 1 12:32:39 2007 +++ php-src/sapi/cgi/cgi_main.c Thu Oct 25 05:39:24 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.340 2007/10/01 12:32:39 jani Exp $ */ +/* $Id: cgi_main.c,v 1.341 2007/10/25 05:39:24 dmitry Exp $ */ #include php.h #include php_globals.h @@ -137,6 +137,7 @@ {'?', 0, usage},/* help alias (both '?' and 'usage') */ {'v', 0, version}, {'z', 1, zend-extension}, + {'T', 1, timing}, {'-', 0, NULL} /* end of args */ }; @@ -767,7 +768,8 @@ -s Display colour syntax highlighted source.\n -v Version number\n -w Display source with stripped comments and whitespace.\n - -z fileLoad Zend extension file.\n, + -z fileLoad Zend extension file.\n + -T count Measure execution time of script repeated count times.\n, prog, prog); } /* }}} */ @@ -1266,6 +1268,9 @@ char *bindpath = NULL; int fcgi_fd = 0; fcgi_request request; + int repeats = 1; + int benchmark = 0; + struct timeval start, end; #ifndef PHP_WIN32 int status = 0; #endif @@ -1543,6 +1548,11 @@ zend_first_try { while ((c = php_getopt(argc, argv, OPTIONS, php_optarg, php_optind, 1, 2)) != -1) { switch (c) { + case 'T': + benchmark = 1; + repeats = atoi(php_optarg); + gettimeofday(start, NULL); + break; case 'h': case '?': fcgi_shutdown(); @@ -1912,8 +1922,18 @@ } } - if (!fastcgi) + if (!fastcgi) { + if (benchmark) { + repeats--; + if (repeats 0) { + script_file = NULL; + php_optind = orig_optind; + php_optarg = orig_optarg; + continue; + } + } break; + } /* only fastcgi will get here */ requests++; @@ -1943,6 +1963,21 @@ } zend_end_try(); out: + if (benchmark) { + int sec; + int usec; + + gettimeofday(end, NULL); + sec = (int)(end.tv_sec - start.tv_sec); + if (end.tv_usec = start.tv_usec) { + usec = (int)(end.tv_usec - start.tv_usec); + } else { + sec -= 1; + usec = (int)(end.tv_usec + 100 - start.tv_usec); + } + fprintf(stderr, \nElapsed time: %d.%06d sec\n, sec, usec); + } + SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); sapi_shutdown(); -- Patches/Donations: http://pecl.php.net/~jani/ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
And you're sure gettimeofday() is available always? Hint: It isn't. :) Which systems don't have it? If there are such beasts, maybe we add #ifdef HAVE_GETTIMEOFDAY there... -- Stanislav Malyshev, Zend Software Architect [EMAIL PROTECTED] http://www.zend.com/ (408)253-8829 MSN: [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
Thank you for hint. I'll fix it tomorrow. Dmitry. -Original Message- From: Jani Taskinen [mailto:[EMAIL PROTECTED] Sent: Thursday, October 25, 2007 2:04 PM To: Dmitry Stogov Cc: php-cvs@lists.php.net Subject: Re: [PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c And you're sure gettimeofday() is available always? Hint: It isn't. :) --Jani On Thu, 2007-10-25 at 05:39 +, Dmitry Stogov wrote: dmitry Thu Oct 25 05:39:24 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Added CGI SAPI -T option, to measure execution time of script repeated several times. http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.340r2= 1.341diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.340 php-src/sapi/cgi/cgi_main.c:1.341 --- php-src/sapi/cgi/cgi_main.c:1.340 Mon Oct 1 12:32:39 2007 +++ php-src/sapi/cgi/cgi_main.c Thu Oct 25 05:39:24 2007 @@ -21,7 +21,7 @@ +- -+ */ -/* $Id: cgi_main.c,v 1.340 2007/10/01 12:32:39 jani Exp $ */ +/* $Id: cgi_main.c,v 1.341 2007/10/25 05:39:24 dmitry Exp $ */ #include php.h #include php_globals.h @@ -137,6 +137,7 @@ {'?', 0, usage},/* help alias (both '?' and 'usage') */ {'v', 0, version}, {'z', 1, zend-extension}, + {'T', 1, timing}, {'-', 0, NULL} /* end of args */ }; @@ -767,7 +768,8 @@ -s Display colour syntax highlighted source.\n -v Version number\n -w Display source with stripped comments and whitespace.\n - -z fileLoad Zend extension file.\n, + -z fileLoad Zend extension file.\n +-T count Measure execution time of script repeated count times.\n, prog, prog); } /* }}} */ @@ -1266,6 +1268,9 @@ char *bindpath = NULL; int fcgi_fd = 0; fcgi_request request; + int repeats = 1; + int benchmark = 0; + struct timeval start, end; #ifndef PHP_WIN32 int status = 0; #endif @@ -1543,6 +1548,11 @@ zend_first_try { while ((c = php_getopt(argc, argv, OPTIONS, php_optarg, php_optind, 1, 2)) != -1) { switch (c) { + case 'T': + benchmark = 1; + repeats = atoi(php_optarg); + gettimeofday(start, NULL); + break; case 'h': case '?': fcgi_shutdown(); @@ -1912,8 +1922,18 @@ } } - if (!fastcgi) + if (!fastcgi) { + if (benchmark) { + repeats--; + if (repeats 0) { + script_file = NULL; + php_optind = orig_optind; + php_optarg = orig_optarg; + continue; + } + } break; + } /* only fastcgi will get here */ requests++; @@ -1943,6 +1963,21 @@ } zend_end_try(); out: + if (benchmark) { + int sec; + int usec; + + gettimeofday(end, NULL); + sec = (int)(end.tv_sec - start.tv_sec); + if (end.tv_usec = start.tv_usec) { + usec = (int)(end.tv_usec - start.tv_usec); + } else { + sec -= 1; + usec = (int)(end.tv_usec + 100 - start.tv_usec); + } + fprintf(stderr, \nElapsed time: %d.%06d sec\n, sec, usec); + } + SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); sapi_shutdown(); -- Patches/Donations: http://pecl.php.net/~jani/ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Fri Oct 26 04:46:28 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Added check for HAVE_GETTIMEOFDAY http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.342r2=1.343diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.342 php-src/sapi/cgi/cgi_main.c:1.343 --- php-src/sapi/cgi/cgi_main.c:1.342 Thu Oct 25 10:01:25 2007 +++ php-src/sapi/cgi/cgi_main.c Fri Oct 26 04:46:28 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.342 2007/10/25 10:01:25 jani Exp $ */ +/* $Id: cgi_main.c,v 1.343 2007/10/26 04:46:28 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1270,7 +1270,11 @@ fcgi_request request; int repeats = 1; int benchmark = 0; +#if HAVE_GETTIMEOFDAY struct timeval start, end; +#else + time_t start, end; +#endif #ifndef PHP_WIN32 int status = 0; #endif @@ -1551,7 +1555,11 @@ case 'T': benchmark = 1; repeats = atoi(php_optarg); +#ifdef HAVE_GETTIMEOFDAY gettimeofday(start, NULL); +#else + time(start); +#endif break; case 'h': case '?': @@ -1965,6 +1973,7 @@ out: if (benchmark) { int sec; +#ifdef HAVE_GETTIMEOFDAY int usec; gettimeofday(end, NULL); @@ -1976,6 +1985,11 @@ usec = (int)(end.tv_usec + 100 - start.tv_usec); } fprintf(stderr, \nElapsed time: %d.%06d sec\n, sec, usec); +#else + time(end); + sec = (int)(end - start); + fprintf(stderr, \nElapsed time: %d sec\n, sec); +#endif } SG(server_context) = NULL; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Thu Oct 25 05:39:24 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Added CGI SAPI -T option, to measure execution time of script repeated several times. http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.340r2=1.341diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.340 php-src/sapi/cgi/cgi_main.c:1.341 --- php-src/sapi/cgi/cgi_main.c:1.340 Mon Oct 1 12:32:39 2007 +++ php-src/sapi/cgi/cgi_main.c Thu Oct 25 05:39:24 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.340 2007/10/01 12:32:39 jani Exp $ */ +/* $Id: cgi_main.c,v 1.341 2007/10/25 05:39:24 dmitry Exp $ */ #include php.h #include php_globals.h @@ -137,6 +137,7 @@ {'?', 0, usage},/* help alias (both '?' and 'usage') */ {'v', 0, version}, {'z', 1, zend-extension}, + {'T', 1, timing}, {'-', 0, NULL} /* end of args */ }; @@ -767,7 +768,8 @@ -s Display colour syntax highlighted source.\n -v Version number\n -w Display source with stripped comments and whitespace.\n - -z fileLoad Zend extension file.\n, + -z fileLoad Zend extension file.\n +-T count Measure execution time of script repeated count times.\n, prog, prog); } /* }}} */ @@ -1266,6 +1268,9 @@ char *bindpath = NULL; int fcgi_fd = 0; fcgi_request request; + int repeats = 1; + int benchmark = 0; + struct timeval start, end; #ifndef PHP_WIN32 int status = 0; #endif @@ -1543,6 +1548,11 @@ zend_first_try { while ((c = php_getopt(argc, argv, OPTIONS, php_optarg, php_optind, 1, 2)) != -1) { switch (c) { + case 'T': + benchmark = 1; + repeats = atoi(php_optarg); + gettimeofday(start, NULL); + break; case 'h': case '?': fcgi_shutdown(); @@ -1912,8 +1922,18 @@ } } - if (!fastcgi) + if (!fastcgi) { + if (benchmark) { + repeats--; + if (repeats 0) { + script_file = NULL; + php_optind = orig_optind; + php_optarg = orig_optarg; + continue; + } + } break; + } /* only fastcgi will get here */ requests++; @@ -1943,6 +1963,21 @@ } zend_end_try(); out: + if (benchmark) { + int sec; + int usec; + + gettimeofday(end, NULL); + sec = (int)(end.tv_sec - start.tv_sec); + if (end.tv_usec = start.tv_usec) { + usec = (int)(end.tv_usec - start.tv_usec); + } else { + sec -= 1; + usec = (int)(end.tv_usec + 100 - start.tv_usec); + } + fprintf(stderr, \nElapsed time: %d.%06d sec\n, sec, usec); + } + SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); sapi_shutdown(); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Thu Sep 27 07:29:58 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: ws http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.335r2=1.336diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.335 php-src/sapi/cgi/cgi_main.c:1.336 --- php-src/sapi/cgi/cgi_main.c:1.335 Mon Sep 24 11:43:02 2007 +++ php-src/sapi/cgi/cgi_main.c Thu Sep 27 07:29:58 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.335 2007/09/24 11:43:02 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.336 2007/09/27 07:29:58 dmitry Exp $ */ #include php.h #include php_globals.h @@ -148,8 +148,8 @@ zend_bool fix_pathinfo; zend_bool force_redirect; zend_bool discard_path; - char *redirect_status_env; zend_bool fcgi_logging; + char *redirect_status_env; #ifdef PHP_WIN32 zend_bool impersonate; #endif @@ -283,7 +283,7 @@ fcgi_request *request = (fcgi_request*) server_context; if ( #ifndef PHP_WIN32 - !parent + !parent #endif request !fcgi_flush(request, 0)) { php_handle_aborted_connection(); @@ -420,7 +420,7 @@ #if !HAVE_SETENV || !HAVE_UNSETENV /* if cgi, or fastcgi and not found in fcgi env - check the regular environment + check the regular environment this leaks, but it's only cgi anyway, we'll fix it for 5.0 */ @@ -457,19 +457,19 @@ Z_TYPE_P(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_ENV])) 0) { zval_dtor(array_ptr); - *array_ptr = *PG(http_globals)[TRACK_VARS_ENV]; - INIT_PZVAL(array_ptr); - zval_copy_ctor(array_ptr); - return; + *array_ptr = *PG(http_globals)[TRACK_VARS_ENV]; + INIT_PZVAL(array_ptr); + zval_copy_ctor(array_ptr); + return; } else if (PG(http_globals)[TRACK_VARS_SERVER] - array_ptr != PG(http_globals)[TRACK_VARS_SERVER] - Z_TYPE_P(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY - zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER])) 0) { + array_ptr != PG(http_globals)[TRACK_VARS_SERVER] + Z_TYPE_P(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY + zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER])) 0) { zval_dtor(array_ptr); - *array_ptr = *PG(http_globals)[TRACK_VARS_SERVER]; - INIT_PZVAL(array_ptr); - zval_copy_ctor(array_ptr); - return; + *array_ptr = *PG(http_globals)[TRACK_VARS_SERVER]; + INIT_PZVAL(array_ptr); + zval_copy_ctor(array_ptr); + return; } /* call php's original import as a catch-all */ @@ -511,7 +511,7 @@ unsigned int script_name_len = script_name ? strlen(script_name) : 0; char *path_info = sapi_cgibin_getenv(PATH_INFO, sizeof(PATH_INFO)-1 TSRMLS_CC); unsigned int path_info_len = path_info ? strlen(path_info) : 0; - + php_self_len = script_name_len + path_info_len; php_self = emalloc(php_self_len + 1); @@ -542,9 +542,9 @@ if (fcgi_is_fastcgi() CGIG(fcgi_logging)) { fcgi_request *request; - + request = (fcgi_request*) SG(server_context); - if (request) { + if (request) { int len = strlen(message); char *buf = malloc(len+2); @@ -565,7 +565,7 @@ { /* flush only when SAPI was started. The reasons are: 1. SAPI Deactivate is called from two places: module init and request shutdown - 2. When the first call occurs and the request is not set up, flush fails on + 2. When the first call occurs and the request is not set up, flush fails on FastCGI. */ if (SG(sapi_started)) { @@ -672,14 +672,14 @@ for: PATH_INFO - derived from the portion of the URI path following + derived from the portion of the URI path following the script name but preceding any query data may be empty PATH_TRANSLATED -derived by taking any path-info component of the - request URI and performing any virtual-to-physical - translation appropriate to map it onto the server's +derived by taking any path-info component of the + request URI and performing any virtual-to-physical + translation appropriate to map it onto the server's document
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
janiThu Sep 27 22:08:55 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: ws + cs fixes http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.337r2=1.338diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.337 php-src/sapi/cgi/cgi_main.c:1.338 --- php-src/sapi/cgi/cgi_main.c:1.337 Thu Sep 27 18:28:43 2007 +++ php-src/sapi/cgi/cgi_main.c Thu Sep 27 22:08:54 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.337 2007/09/27 18:28:43 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.338 2007/09/27 22:08:54 jani Exp $ */ #include php.h #include php_globals.h @@ -83,8 +83,7 @@ #include fastcgi.h #ifndef PHP_WIN32 -/* XXX this will need to change later when threaded fastcgi is - implemented. shane */ +/* XXX this will need to change later when threaded fastcgi is implemented. shane */ struct sigaction act, old_term, old_quit, old_int; #endif @@ -187,8 +186,8 @@ Bucket *f = *((Bucket **) a); Bucket *s = *((Bucket **) b); - return strcasecmp(((zend_module_entry *)f-pData)-name, - ((zend_module_entry *)s-pData)-name); + return strcasecmp( ((zend_module_entry *)f-pData)-name, + ((zend_module_entry *)s-pData)-name); } static void print_modules(TSRMLS_D) @@ -209,11 +208,10 @@ return 0; } -static int extension_name_cmp(const zend_llist_element **f, - const zend_llist_element **s TSRMLS_DC) +static int extension_name_cmp(const zend_llist_element **f, const zend_llist_element **s TSRMLS_DC) { - return strcmp(((zend_extension *)(*f)-data)-name, - ((zend_extension *)(*s)-data)-name); + return strcmp( ((zend_extension *)(*f)-data)-name, + ((zend_extension *)(*s)-data)-name); } static void print_extensions(TSRMLS_D) @@ -312,8 +310,7 @@ int len; if (CGIG(rfc2616_headers) SG(sapi_headers).http_status_line) { - len = snprintf(buf, SAPI_CGI_MAX_HEADER_LENGTH, - %s\r\n, SG(sapi_headers).http_status_line); + len = snprintf(buf, SAPI_CGI_MAX_HEADER_LENGTH, %s\r\n, SG(sapi_headers).http_status_line); if (len SAPI_CGI_MAX_HEADER_LENGTH) { len = SAPI_CGI_MAX_HEADER_LENGTH; @@ -323,9 +320,10 @@ char *s; if (SG(sapi_headers).http_status_line - (s = strchr(SG(sapi_headers).http_status_line, ' ')) != 0 - (s - SG(sapi_headers).http_status_line) = 5 - strncasecmp(SG(sapi_headers).http_status_line, HTTP/, 5) == 0) { + (s = strchr(SG(sapi_headers).http_status_line, ' ')) != 0 + (s - SG(sapi_headers).http_status_line) = 5 + strncasecmp(SG(sapi_headers).http_status_line, HTTP/, 5) == 0 + ) { len = sprintf(buf, Status:%s\r\n, s); } else { len = sprintf(buf, Status: %d\r\n, SG(sapi_headers).http_response_code); @@ -453,18 +451,20 @@ void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC) { if (PG(http_globals)[TRACK_VARS_ENV] - array_ptr != PG(http_globals)[TRACK_VARS_ENV] - Z_TYPE_P(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY - zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_ENV])) 0) { + array_ptr != PG(http_globals)[TRACK_VARS_ENV] + Z_TYPE_P(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY + zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_ENV])) 0 + ) { zval_dtor(array_ptr); *array_ptr = *PG(http_globals)[TRACK_VARS_ENV]; INIT_PZVAL(array_ptr); zval_copy_ctor(array_ptr); return; } else if (PG(http_globals)[TRACK_VARS_SERVER] - array_ptr != PG(http_globals)[TRACK_VARS_SERVER] - Z_TYPE_P(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY - zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER])) 0) { + array_ptr != PG(http_globals)[TRACK_VARS_SERVER] + Z_TYPE_P(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY + zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER])) 0 + ) { zval_dtor(array_ptr); *array_ptr = *PG(http_globals)[TRACK_VARS_SERVER]; INIT_PZVAL(array_ptr);
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Mon Sep 24 11:43:02 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed bug #42699 (PHP_SELF duplicates path) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.334r2=1.335diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.334 php-src/sapi/cgi/cgi_main.c:1.335 --- php-src/sapi/cgi/cgi_main.c:1.334 Mon Sep 10 10:55:41 2007 +++ php-src/sapi/cgi/cgi_main.c Mon Sep 24 11:43:02 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.334 2007/09/10 10:55:41 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.335 2007/09/24 11:43:02 dmitry Exp $ */ #include php.h #include php_globals.h @@ -498,29 +498,42 @@ static void sapi_cgi_register_variables(zval *track_vars_array TSRMLS_DC) { - char *script_name = SG(request_info).request_uri; - unsigned int script_name_len = script_name ? strlen(script_name) : 0; - char *path_info = sapi_cgibin_getenv(PATH_INFO, sizeof(PATH_INFO)-1 TSRMLS_CC); - unsigned int path_info_len = path_info ? strlen(path_info) : 0; - unsigned int php_self_len = script_name_len + path_info_len; - char *php_self = emalloc(php_self_len + 1); - - if (script_name) { - memcpy(php_self, script_name, script_name_len + 1); - } - if (path_info) { - memcpy(php_self + script_name_len, path_info, path_info_len + 1); - } + unsigned int php_self_len; + char *php_self; /* In CGI mode, we consider the environment to be a part of the server * variables */ php_import_environment_variables(track_vars_array TSRMLS_CC); - /* Build the special-case PHP_SELF variable for the CGI version */ - if (sapi_module.input_filter(PARSE_SERVER, PHP_SELF, php_self, php_self_len, php_self_len TSRMLS_CC)) { - php_register_variable_safe(PHP_SELF, php_self, php_self_len, track_vars_array TSRMLS_CC); + + if (CGIG(fix_pathinfo)) { + char *script_name = SG(request_info).request_uri; + unsigned int script_name_len = script_name ? strlen(script_name) : 0; + char *path_info = sapi_cgibin_getenv(PATH_INFO, sizeof(PATH_INFO)-1 TSRMLS_CC); + unsigned int path_info_len = path_info ? strlen(path_info) : 0; + + php_self_len = script_name_len + path_info_len; + php_self = emalloc(php_self_len + 1); + + if (script_name) { + memcpy(php_self, script_name, script_name_len + 1); + } + if (path_info) { + memcpy(php_self + script_name_len, path_info, path_info_len + 1); + } + + /* Build the special-case PHP_SELF variable for the CGI version */ + if (sapi_module.input_filter(PARSE_SERVER, PHP_SELF, php_self, php_self_len, php_self_len TSRMLS_CC)) { + php_register_variable_safe(PHP_SELF, php_self, php_self_len, track_vars_array TSRMLS_CC); + } + efree(php_self); + } else { + php_self = SG(request_info).request_uri ? SG(request_info).request_uri : ; + php_self_len = strlen(php_self); + if (sapi_module.input_filter(PARSE_SERVER, PHP_SELF, php_self, php_self_len, php_self_len TSRMLS_CC)) { + php_register_variable_safe(PHP_SELF, php_self, php_self_len, track_vars_array TSRMLS_CC); + } } - efree(php_self); } static void sapi_cgi_log_message(char *message) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Mon Sep 10 10:55:41 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed bug #42587 (behaviour change regarding symlinked .php files) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.333r2=1.334diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.333 php-src/sapi/cgi/cgi_main.c:1.334 --- php-src/sapi/cgi/cgi_main.c:1.333 Sat Sep 8 11:10:37 2007 +++ php-src/sapi/cgi/cgi_main.c Mon Sep 10 10:55:41 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.333 2007/09/08 11:10:37 tony2001 Exp $ */ +/* $Id: cgi_main.c,v 1.334 2007/09/10 10:55:41 dmitry Exp $ */ #include php.h #include php_globals.h @@ -775,6 +775,7 @@ char *orig_path_info = env_path_info; char *orig_script_name = env_script_name; char *orig_script_filename = env_script_filename; + int script_path_translated_len; if (!env_document_root PG(doc_root)) { env_document_root = _sapi_cgibin_putenv(DOCUMENT_ROOT, PG(doc_root) TSRMLS_CC); @@ -805,9 +806,11 @@ * this fixes url's like /info.php/test */ if (script_path_translated - (real_path = tsrm_realpath(script_path_translated, NULL TSRMLS_CC)) == NULL) { - char *pt = estrdup(script_path_translated); - int len = strlen(pt); + (script_path_translated_len = strlen(script_path_translated)) 0 + (script_path_translated[script_path_translated_len-1] == '/' || +(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; char *ptr; while ((ptr = strrchr(pt, '/')) || (ptr = strrchr(pt, '\\'))) { @@ -947,9 +950,6 @@ SG(request_info).path_translated = estrdup(script_path_translated); } } else { - if (real_path) { - script_path_translated = real_path; - } /* make sure path_info/translated are empty */ if (!orig_script_filename || (script_path_translated != orig_script_filename @@ -982,9 +982,7 @@ if (script_path_translated !strstr(script_path_translated, ..)) { SG(request_info).path_translated = estrdup(script_path_translated); } - if (real_path) { - free(real_path); - } + free(real_path); } } else { /* pre 4.3 behaviour, shouldn't be used but provides BC */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
tony2001Sat Sep 8 11:10:37 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: output is started in php_module_startup(), no need to start it twice fixes leaks in sapi/cgi/tests/005.phpt http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.332r2=1.333diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.332 php-src/sapi/cgi/cgi_main.c:1.333 --- php-src/sapi/cgi/cgi_main.c:1.332 Wed Sep 5 08:26:49 2007 +++ php-src/sapi/cgi/cgi_main.c Sat Sep 8 11:10:37 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.332 2007/09/05 08:26:49 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.333 2007/09/08 11:10:37 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -1422,7 +1422,6 @@ case '?': fcgi_shutdown(); no_headers = 1; - php_output_tearup(); SG(headers_sent) = 1; php_cgi_usage(argv[0]); php_output_end_all(TSRMLS_C); @@ -1450,7 +1449,6 @@ if (!cgi !fastcgi) { if (cgi_sapi_module.php_ini_path_override cgi_sapi_module.php_ini_ignore) { no_headers = 1; - php_output_tearup(); SG(headers_sent) = 1; php_printf(You cannot use both -n and -c switch. Use -h for help.\n); php_output_end_all(TSRMLS_C); @@ -1506,7 +1504,6 @@ break; case 'm': /* list compiled in modules */ - php_output_tearup(); SG(headers_sent) = 1; php_printf([PHP Modules]\n); print_modules(TSRMLS_C); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Wed Sep 5 08:26:49 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed bug #42523 (PHP_SELF duplicates path) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.331r2=1.332diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.331 php-src/sapi/cgi/cgi_main.c:1.332 --- php-src/sapi/cgi/cgi_main.c:1.331 Fri Aug 31 12:18:04 2007 +++ php-src/sapi/cgi/cgi_main.c Wed Sep 5 08:26:49 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.331 2007/08/31 12:18:04 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.332 2007/09/05 08:26:49 dmitry Exp $ */ #include php.h #include php_globals.h @@ -751,6 +751,21 @@ char *env_path_info = sapi_cgibin_getenv(PATH_INFO, sizeof(PATH_INFO)-1 TSRMLS_CC); char *env_script_name = sapi_cgibin_getenv(SCRIPT_NAME, sizeof(SCRIPT_NAME)-1 TSRMLS_CC); + /* Hack for buggy IIS that sets incorrect PATH_INFO */ + char *env_server_software = sapi_cgibin_getenv(SERVER_SOFTWARE, sizeof(SERVER_SOFTWARE)-1 TSRMLS_CC); + if (env_server_software + env_script_name + env_path_info + strncmp(env_server_software, Microsoft-IIS, sizeof(Microsoft-IIS)-1) == 0 + strncmp(env_path_info, env_script_name, strlen(env_script_name)) == 0) { + env_path_info = _sapi_cgibin_putenv(ORIG_PATH_INFO, env_path_info TSRMLS_CC); + env_path_info += strlen(env_script_name); + if (*env_path_info == 0) { + env_path_info = NULL; + } + env_path_info = _sapi_cgibin_putenv(PATH_INFO, env_path_info TSRMLS_CC); + } + if (CGIG(fix_pathinfo)) { struct stat st; char *real_path = NULL; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Fri Aug 31 12:18:04 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed bug #42453 (CGI SAPI does not shut down cleanly with -i/-m/-v cmdline options) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.330r2=1.331diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.330 php-src/sapi/cgi/cgi_main.c:1.331 --- php-src/sapi/cgi/cgi_main.c:1.330 Wed Aug 8 23:55:42 2007 +++ php-src/sapi/cgi/cgi_main.c Fri Aug 31 12:18:04 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.330 2007/08/08 23:55:42 stas Exp $ */ +/* $Id: cgi_main.c,v 1.331 2007/08/31 12:18:04 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1410,9 +1410,9 @@ php_output_tearup(); SG(headers_sent) = 1; php_cgi_usage(argv[0]); - php_output_teardown(); - exit(1); - break; + php_output_end_all(TSRMLS_C); + exit_status = 0; + goto out; } } php_optind = orig_optind; @@ -1438,8 +1438,9 @@ php_output_tearup(); SG(headers_sent) = 1; php_printf(You cannot use both -n and -c switch. Use -h for help.\n); - php_output_teardown(); - exit(1); + php_output_end_all(TSRMLS_C); + exit_status = 1; + goto out; } while ((c = php_getopt(argc, argv, OPTIONS, php_optarg, php_optind, 0)) != -1) { @@ -1480,9 +1481,9 @@ SG(request_info).no_headers = 1; } php_print_info(0x TSRMLS_CC); - php_output_teardown(); - exit(0); - break; + php_request_shutdown((void *) 0); + exit_status = 0; + goto out; case 'l': /* syntax check mode */ no_headers = 1; @@ -1497,9 +1498,9 @@ php_printf(\n[Zend Modules]\n); print_extensions(TSRMLS_C); php_printf(\n); - php_output_teardown(); - exit(0); - break; + php_output_end_all(TSRMLS_C); + exit_status = 0; + goto out; #if 0 /* not yet operational, see also below ... */ case '': /* generate indented source mode*/ @@ -1527,9 +1528,9 @@ #else php_printf(PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2007 The PHP Group\n%s, PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #endif - php_output_teardown(); - exit(0); - break; + php_request_shutdown((void *) 0); + exit_status = 0; + goto out; case 'w': behavior = PHP_MODE_STRIP; @@ -1802,6 +1803,7 @@ exit_status = 255; } zend_end_try(); +out: SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); sapi_shutdown(); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
janiWed Aug 8 10:00:20 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: - Fix typos in comments http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.327r2=1.328diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.327 php-src/sapi/cgi/cgi_main.c:1.328 --- php-src/sapi/cgi/cgi_main.c:1.327 Tue Jun 26 14:47:33 2007 +++ php-src/sapi/cgi/cgi_main.c Wed Aug 8 10:00:20 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.327 2007/06/26 14:47:33 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.328 2007/08/08 10:00:20 jani Exp $ */ #include php.h #include php_globals.h @@ -841,7 +841,7 @@ */ env_script_name = pt + l; - /* PATH_TRANSATED = DOCUMENT_ROOT + PATH_INFO */ + /* PATH_TRANSLATED = DOCUMENT_ROOT + PATH_INFO */ path_translated_len = l + (env_path_info ? strlen(env_path_info) : 0); path_translated = (char *) emalloc(path_translated_len + 1); memcpy(path_translated, env_document_root, l); @@ -857,7 +857,7 @@ } else if (env_script_name strstr(pt, env_script_name) ) { - /* PATH_TRANSATED = PATH_TRANSATED - SCRIPT_NAME + PATH_INFO */ + /* PATH_TRANSLATED = PATH_TRANSLATED - SCRIPT_NAME + PATH_INFO */ int ptlen = strlen(pt) - strlen(env_script_name); int path_translated_len = ptlen + env_path_info ? strlen(env_path_info) : 0; char *path_translated = NULL; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Wed Aug 8 13:02:01 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: - Fixed bug #42198 (SCRIPT_NAME and PHP_SELF truncated when inside a userdir and using PATH_INFO). - Fixed bug #31892 (PHP_SELF incorrect without cgi.fix_pathinfo, but turning on screws up PATH_INFO). http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.328r2=1.329diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.328 php-src/sapi/cgi/cgi_main.c:1.329 --- php-src/sapi/cgi/cgi_main.c:1.328 Wed Aug 8 10:00:20 2007 +++ php-src/sapi/cgi/cgi_main.c Wed Aug 8 13:02:01 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.328 2007/08/08 10:00:20 jani Exp $ */ +/* $Id: cgi_main.c,v 1.329 2007/08/08 13:02:01 dmitry Exp $ */ #include php.h #include php_globals.h @@ -498,16 +498,29 @@ static void sapi_cgi_register_variables(zval *track_vars_array TSRMLS_DC) { - unsigned int new_val_len; - char *val = SG(request_info).request_uri ? SG(request_info).request_uri : ; + char *script_name = SG(request_info).request_uri; + unsigned int script_name_len = script_name ? strlen(script_name) : 0; + char *path_info = sapi_cgibin_getenv(PATH_INFO, sizeof(PATH_INFO)-1 TSRMLS_CC); + unsigned int path_info_len = path_info ? strlen(path_info) : 0; + unsigned int php_self_len = script_name_len + path_info_len; + char *php_self = emalloc(php_self_len + 1); + + if (script_name) { + memcpy(php_self, script_name, script_name_len + 1); + } + if (path_info) { + memcpy(php_self + script_name_len, path_info, path_info_len + 1); + } + /* In CGI mode, we consider the environment to be a part of the server * variables */ php_import_environment_variables(track_vars_array TSRMLS_CC); /* Build the special-case PHP_SELF variable for the CGI version */ - if (sapi_module.input_filter(PARSE_SERVER, PHP_SELF, val, strlen(val), new_val_len TSRMLS_CC)) { - php_register_variable_safe(PHP_SELF, val, new_val_len, track_vars_array TSRMLS_CC); + if (sapi_module.input_filter(PARSE_SERVER, PHP_SELF, php_self, php_self_len, php_self_len TSRMLS_CC)) { + php_register_variable_safe(PHP_SELF, php_self, php_self_len, track_vars_array TSRMLS_CC); } + efree(php_self); } static void sapi_cgi_log_message(char *message) @@ -664,7 +677,7 @@ SCRIPT_NAME set to a URL path that could identify the CGI script - rather than the interpreter. PHP_SELF is set to this. + rather than the interpreter. PHP_SELF is set to this REQUEST_URI uri section following the domain:port part of a URI @@ -806,7 +819,21 @@ if (orig_path_info != path_info) { if (orig_path_info) { + char old; + _sapi_cgibin_putenv(ORIG_PATH_INFO, orig_path_info TSRMLS_CC); + old = path_info[0]; + path_info[0] = 0; + if (!orig_script_name || + strcmp(orig_script_name, env_path_info) != 0) { + if (orig_script_name) { + _sapi_cgibin_putenv(ORIG_SCRIPT_NAME, orig_script_name TSRMLS_CC); + } + SG(request_info).request_uri = _sapi_cgibin_putenv(SCRIPT_NAME, env_path_info TSRMLS_CC); + } else { + SG(request_info).request_uri = orig_script_name; + } + path_info[0] = old; } env_path_info = _sapi_cgibin_putenv(PATH_INFO, path_info TSRMLS_CC); } @@ -823,8 +850,7 @@ SCRIPT_FILENAME minus SCRIPT_NAME */ - if (env_document_root) - { +
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
stasWed Aug 8 23:55:42 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: remove unneeded variables http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.329r2=1.330diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.329 php-src/sapi/cgi/cgi_main.c:1.330 --- php-src/sapi/cgi/cgi_main.c:1.329 Wed Aug 8 13:02:01 2007 +++ php-src/sapi/cgi/cgi_main.c Wed Aug 8 23:55:42 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.329 2007/08/08 13:02:01 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.330 2007/08/08 23:55:42 stas Exp $ */ #include php.h #include php_globals.h @@ -1117,10 +1117,6 @@ /* end of temporary locals */ #ifdef ZTS - zend_compiler_globals *compiler_globals; - zend_executor_globals *executor_globals; - php_core_globals *core_globals; - sapi_globals_struct *sapi_globals; void ***tsrm_ls; #endif @@ -1158,6 +1154,7 @@ #ifdef ZTS tsrm_startup(1, 1, 0, NULL); + tsrm_ls = ts_resource(0); #endif sapi_startup(cgi_sapi_module); @@ -1240,11 +1237,6 @@ php_optarg = orig_optarg; #ifdef ZTS - compiler_globals = ts_resource(compiler_globals_id); - executor_globals = ts_resource(executor_globals_id); - core_globals = ts_resource(core_globals_id); - sapi_globals = ts_resource(sapi_globals_id); - tsrm_ls = ts_resource(0); SG(request_info).path_translated = NULL; #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Tue Jun 26 14:47:33 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed bug #40419 (Trailing Slash in CGI request don't work) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.326r2=1.327diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.326 php-src/sapi/cgi/cgi_main.c:1.327 --- php-src/sapi/cgi/cgi_main.c:1.326 Thu Jun 21 08:40:56 2007 +++ php-src/sapi/cgi/cgi_main.c Tue Jun 26 14:47:33 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.326 2007/06/21 08:40:56 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.327 2007/06/26 14:47:33 dmitry Exp $ */ #include php.h #include php_globals.h @@ -738,9 +738,9 @@ char *env_path_info = sapi_cgibin_getenv(PATH_INFO, sizeof(PATH_INFO)-1 TSRMLS_CC); char *env_script_name = sapi_cgibin_getenv(SCRIPT_NAME, sizeof(SCRIPT_NAME)-1 TSRMLS_CC); - if (CGIG(fix_pathinfo)) { + if (CGIG(fix_pathinfo)) { struct stat st; - char *real_path; + char *real_path = NULL; char *env_redirect_url = sapi_cgibin_getenv(REDIRECT_URL, sizeof(REDIRECT_URL)-1 TSRMLS_CC); char *env_document_root = sapi_cgibin_getenv(DOCUMENT_ROOT, sizeof(DOCUMENT_ROOT)-1 TSRMLS_CC); char *orig_path_translated = env_path_translated; @@ -902,6 +902,9 @@ efree(pt); } } else { + if (real_path) { + script_path_translated = real_path; + } /* make sure path_info/translated are empty */ if (!orig_script_filename || (script_path_translated != orig_script_filename) || @@ -927,8 +930,10 @@ } else { SG(request_info).request_uri = env_script_name; } + if (real_path) { + free(real_path); + } } - free(real_path); } else { /* pre 4.3 behaviour, shouldn't be used but provides BC */ if (env_path_info) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Thu Jun 21 08:40:56 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: no need to return exit status of the last fastcgi request http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.325r2=1.326diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.325 php-src/sapi/cgi/cgi_main.c:1.326 --- php-src/sapi/cgi/cgi_main.c:1.325 Mon Jun 4 15:37:38 2007 +++ php-src/sapi/cgi/cgi_main.c Thu Jun 21 08:40:56 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.325 2007/06/04 15:37:38 tony2001 Exp $ */ +/* $Id: cgi_main.c,v 1.326 2007/06/21 08:40:56 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1748,6 +1748,10 @@ if (bindpath) { free(bindpath); } + if (max_requests != 1) { + /* no need to return exit_status of the last request */ + exit_status = 0; + } break; } /* end of fastcgi loop */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
tony2001Mon Jun 4 15:37:38 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: add missing open_basedir checks to CGI http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.324r2=1.325diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.324 php-src/sapi/cgi/cgi_main.c:1.325 --- php-src/sapi/cgi/cgi_main.c:1.324 Tue May 29 00:01:14 2007 +++ php-src/sapi/cgi/cgi_main.c Mon Jun 4 15:37:38 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.324 2007/05/29 00:01:14 iliaa Exp $ */ +/* $Id: cgi_main.c,v 1.325 2007/06/04 15:37:38 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -1603,7 +1603,9 @@ */ retval = FAILURE; if (cgi || SG(request_info).path_translated) { - retval = php_fopen_primary_script(file_handle TSRMLS_CC); + if (!php_check_open_basedir(SG(request_info).path_translated TSRMLS_CC)) { + retval = php_fopen_primary_script(file_handle TSRMLS_CC); + } } /* if we are unable to open path_translated and we are not @@ -1623,9 +1625,21 @@ if (fastcgi) { goto fastcgi_request_done; } + + STR_FREE(SG(request_info).path_translated); + + if (free_query_string SG(request_info).query_string) { + free(SG(request_info).query_string); + SG(request_info).query_string = NULL; + } + php_request_shutdown((void *) 0); SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); + sapi_shutdown(); +#ifdef ZTS + tsrm_shutdown(); +#endif return FAILURE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Mon May 28 08:12:11 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Removed deprecated comment http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.322r2=1.323diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.322 php-src/sapi/cgi/cgi_main.c:1.323 --- php-src/sapi/cgi/cgi_main.c:1.322 Mon May 21 09:08:25 2007 +++ php-src/sapi/cgi/cgi_main.c Mon May 28 08:12:11 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.322 2007/05/21 09:08:25 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.323 2007/05/28 08:12:11 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1253,8 +1253,6 @@ } } - /* for windows, socket listening is broken in the fastcgi library itself - so dissabling this feature on windows till time is available to fix it */ if (bindpath) { fcgi_fd = fcgi_listen(bindpath, 128); if (fcgi_fd 0) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c fastcgi.c fastcgi.h
dmitry Mon May 21 09:08:25 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c fastcgi.c fastcgi.h Log: Fixed crash on php -b 1234 -unknown-option http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.321r2=1.322diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.321 php-src/sapi/cgi/cgi_main.c:1.322 --- php-src/sapi/cgi/cgi_main.c:1.321 Tue May 15 08:17:20 2007 +++ php-src/sapi/cgi/cgi_main.c Mon May 21 09:08:25 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.321 2007/05/15 08:17:20 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.322 2007/05/21 09:08:25 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1369,6 +1369,7 @@ switch (c) { case 'h': case '?': + fcgi_shutdown(); no_headers = 1; php_output_tearup(); SG(headers_sent) = 1; @@ -1735,6 +1736,7 @@ } /* end of fastcgi loop */ } + fcgi_shutdown(); if (cgi_sapi_module.php_ini_path_override) { free(cgi_sapi_module.php_ini_path_override); http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.38r2=1.39diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.38 php-src/sapi/cgi/fastcgi.c:1.39 --- php-src/sapi/cgi/fastcgi.c:1.38 Thu May 10 15:22:15 2007 +++ php-src/sapi/cgi/fastcgi.c Mon May 21 09:08:25 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.38 2007/05/10 15:22:15 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.39 2007/05/21 09:08:25 dmitry Exp $ */ #include php.h #include fastcgi.h @@ -177,6 +177,11 @@ return in_shutdown; } +void fcgi_shutdown(void) +{ + is_fastcgi = 0; +} + int fcgi_init(void) { if (!is_initialized) { http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.h?r1=1.8r2=1.9diff_format=u Index: php-src/sapi/cgi/fastcgi.h diff -u php-src/sapi/cgi/fastcgi.h:1.8 php-src/sapi/cgi/fastcgi.h:1.9 --- php-src/sapi/cgi/fastcgi.h:1.8 Wed Mar 28 15:39:35 2007 +++ php-src/sapi/cgi/fastcgi.h Mon May 21 09:08:25 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.h,v 1.8 2007/03/28 15:39:35 dmitry Exp $ */ +/* $Id: fastcgi.h,v 1.9 2007/05/21 09:08:25 dmitry Exp $ */ /* FastCGI protocol */ @@ -112,6 +112,7 @@ } fcgi_request; int fcgi_init(void); +void fcgi_shutdown(void); int fcgi_is_fastcgi(void); int fcgi_in_shutdown(void); int fcgi_listen(const char *path, int backlog); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Tue May 15 08:17:21 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed bug #41378 (fastcgi protocol lacks support for Reason-Phrase in Status: header) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.320r2=1.321diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.320 php-src/sapi/cgi/cgi_main.c:1.321 --- php-src/sapi/cgi/cgi_main.c:1.320 Tue Apr 17 20:01:22 2007 +++ php-src/sapi/cgi/cgi_main.c Tue May 15 08:17:20 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.320 2007/04/17 20:01:22 sniper Exp $ */ +/* $Id: cgi_main.c,v 1.321 2007/05/15 08:17:20 dmitry Exp $ */ #include php.h #include php_globals.h @@ -320,7 +320,16 @@ } } else { - len = sprintf(buf, Status: %d\r\n, SG(sapi_headers).http_response_code); + char *s; + + if (SG(sapi_headers).http_status_line + (s = strchr(SG(sapi_headers).http_status_line, ' ')) != 0 + (s - SG(sapi_headers).http_status_line) = 5 + strncasecmp(SG(sapi_headers).http_status_line, HTTP/, 5) == 0) { + len = sprintf(buf, Status:%s\r\n, s); + } else { + len = sprintf(buf, Status: %d\r\n, SG(sapi_headers).http_response_code); + } } PHPWRITE_H(buf, len); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
tony2001Tue Apr 17 18:51:24 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: fix leak appearing when more than one -f option specified http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.318r2=1.319diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.318 php-src/sapi/cgi/cgi_main.c:1.319 --- php-src/sapi/cgi/cgi_main.c:1.318 Sun Apr 15 23:02:05 2007 +++ php-src/sapi/cgi/cgi_main.c Tue Apr 17 18:51:24 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.318 2007/04/15 23:02:05 sniper Exp $ */ +/* $Id: cgi_main.c,v 1.319 2007/04/17 18:51:24 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -1409,6 +1409,9 @@ break; case 'f': /* parse file */ + if (script_file) { + efree(script_file); + } script_file = estrdup(php_optarg); no_headers = 1; /* arguments after the file are considered script args */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
sniper Sun Apr 15 23:02:05 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: MFB: Allow using syntax highlighting in fastcgi mode http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.317r2=1.318diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.317 php-src/sapi/cgi/cgi_main.c:1.318 --- php-src/sapi/cgi/cgi_main.c:1.317 Wed Mar 28 15:39:35 2007 +++ php-src/sapi/cgi/cgi_main.c Sun Apr 15 23:02:05 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.317 2007/03/28 15:39:35 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.318 2007/04/15 23:02:05 sniper Exp $ */ #include php.h #include php_globals.h @@ -1172,8 +1172,10 @@ bindpath = strdup(php_optarg); } break; + case 's': /* generate highlighted HTML from source */ + behavior = PHP_MODE_HIGHLIGHT; + break; } - } php_optind = orig_optind; php_optarg = orig_optarg; @@ -1456,10 +1458,6 @@ no_headers = 1; break; - case 's': /* generate highlighted HTML from source */ - behavior = PHP_MODE_HIGHLIGHT; - break; - case 'v': /* show php version quit */ no_headers = 1; if (php_request_startup(TSRMLS_C) == FAILURE) { @@ -1660,6 +1658,9 @@ if (open_file_for_scanning(file_handle TSRMLS_CC) == SUCCESS) { php_get_highlight_struct(syntax_highlighter_ini); zend_highlight(syntax_highlighter_ini TSRMLS_CC); + if (fastcgi) { + goto fastcgi_request_done; + } fclose(file_handle.handle.fp); php_output_teardown(); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c fastcgi.c fastcgi.h
dmitry Wed Mar 28 15:39:35 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c fastcgi.c fastcgi.h Log: Improved FastCGI SAPI to support external pipe and socket servers on win32 http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.316r2=1.317diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.316 php-src/sapi/cgi/cgi_main.c:1.317 --- php-src/sapi/cgi/cgi_main.c:1.316 Fri Mar 9 16:50:17 2007 +++ php-src/sapi/cgi/cgi_main.c Wed Mar 28 15:39:35 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.316 2007/03/09 16:50:17 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.317 2007/03/28 15:39:35 dmitry Exp $ */ #include php.h #include php_globals.h @@ -120,9 +120,7 @@ static const opt_struct OPTIONS[] = { {'a', 0, interactive}, -#ifndef PHP_WIN32 {'b', 1, bindpath}, -#endif {'C', 0, no-chdir}, {'c', 1, php-ini}, {'d', 1, define}, @@ -611,9 +609,7 @@ php_printf(Usage: %s [-q] [-h] [-s] [-v] [-i] [-f file]\n %s file [args...]\n -a Run interactively\n -#if !defined(PHP_WIN32) -b address:port|port Bind Path for external FASTCGI Server mode\n -#endif -C Do not chdir to the script's directory\n -c path|file Look for php.ini file in this directory\n -n No php.ini file will be used\n @@ -970,19 +966,6 @@ exit(0); } -#ifndef PHP_WIN32 -static int is_port_number(const char *bindpath) -{ - while (*bindpath) { - if (*bindpath '0' || *bindpath '9') { - return 0; - } - bindpath++; - } - return 1; -} -#endif - PHP_INI_BEGIN() STD_PHP_INI_ENTRY(cgi.rfc2616_headers, 0, PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals) STD_PHP_INI_ENTRY(cgi.nph, 0, PHP_INI_ALL, OnUpdateBool, nph, php_cgi_globals_struct, php_cgi_globals) @@ -1089,9 +1072,7 @@ int max_requests = 500; int requests = 0; int fastcgi = fcgi_is_fastcgi(); -#ifndef PHP_WIN32 char *bindpath = NULL; -#endif int fcgi_fd = 0; fcgi_request request; #ifndef PHP_WIN32 @@ -1152,7 +1133,6 @@ case 'n': cgi_sapi_module.php_ini_ignore = 1; break; -#ifndef PHP_WIN32 /* if we're started on command line, check to see if we are being started as an 'external' fastcgi server by accepting a bindpath parameter. */ @@ -1192,7 +1172,6 @@ bindpath = strdup(php_optarg); } break; -#endif } } @@ -1259,26 +1238,10 @@ } } -#ifndef PHP_WIN32 /* for windows, socket listening is broken in the fastcgi library itself so dissabling this feature on windows till time is available to fix it */ if (bindpath) { - /* Pass on the arg to the FastCGI library, with one exception. -* If just a port is specified, then we prepend a ':' onto the -* path (it's what the fastcgi library expects) -*/ - if (strchr(bindpath, ':') == NULL is_port_number(bindpath)) { - char *tmp; - - tmp = malloc(strlen(bindpath) + 2); - tmp[0] = ':'; - memcpy(tmp + 1, bindpath, strlen(bindpath) + 1); - - fcgi_fd = fcgi_listen(tmp, 128); - free(tmp); - } else { - fcgi_fd = fcgi_listen(bindpath, 128); - } + fcgi_fd = fcgi_listen(bindpath, 128); if (fcgi_fd 0) { fprintf(stderr, Couldn't create FastCGI listen socket on port %s\n, bindpath); #ifdef ZTS @@ -1288,7 +1251,6 @@ } fastcgi = fcgi_is_fastcgi(); } -#endif if (fastcgi) { /* How many times to run PHP scripts before dying */ if (getenv(PHP_FCGI_MAX_REQUESTS)) { @@ -1749,11 +1711,9 @@ requests++; if (max_requests (requests == max_requests)) { fcgi_finish_request(request); -#ifndef PHP_WIN32 if (bindpath) { free(bindpath); } -#endif break; }
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Fri Mar 9 16:50:17 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Return HTTP 403 in case of access denied. http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.315r2=1.316diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.315 php-src/sapi/cgi/cgi_main.c:1.316 --- php-src/sapi/cgi/cgi_main.c:1.315 Wed Feb 21 08:08:47 2007 +++ php-src/sapi/cgi/cgi_main.c Fri Mar 9 16:50:17 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.315 2007/02/21 08:08:47 tony2001 Exp $ */ +/* $Id: cgi_main.c,v 1.316 2007/03/09 16:50:17 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1631,8 +1631,13 @@ running from shell (so fp == NULL), then fail. */ if (retval == FAILURE file_handle.handle.fp == NULL) { - SG(sapi_headers).http_response_code = 404; - PUTS(No input file specified.\n); + if (errno == EACCES) { + SG(sapi_headers).http_response_code = 403; + PUTS(Access denied.\n); + } else { + SG(sapi_headers).http_response_code = 404; + PUTS(No input file specified.\n); + } /* we want to serve more requests if this is fastcgi so cleanup and continue, request shutdown is handled later */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
tony2001Tue Feb 20 09:09:47 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: MFB http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.312r2=1.313diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.312 php-src/sapi/cgi/cgi_main.c:1.313 --- php-src/sapi/cgi/cgi_main.c:1.312 Mon Feb 19 20:01:17 2007 +++ php-src/sapi/cgi/cgi_main.c Tue Feb 20 09:09:47 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.312 2007/02/19 20:01:17 tony2001 Exp $ */ +/* $Id: cgi_main.c,v 1.313 2007/02/20 09:09:47 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -1569,7 +1569,8 @@ } } - s = malloc(++len + 1); + len += 2; + s = malloc(len); *s = '\0'; /* we are pretending it came from the environment */ for (i = php_optind; i argc; i++) { strlcat(s, argv[i], len); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c /sapi/cli php_cli.c
tony2001Tue Feb 20 19:19:14 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c /php-src/sapi/cli php_cli.c Log: don't call php_module_startup() directly, use startup functions patch by Andrei Nigmatulin http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.313r2=1.314diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.313 php-src/sapi/cgi/cgi_main.c:1.314 --- php-src/sapi/cgi/cgi_main.c:1.313 Tue Feb 20 09:09:47 2007 +++ php-src/sapi/cgi/cgi_main.c Tue Feb 20 19:19:14 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.313 2007/02/20 09:09:47 tony2001 Exp $ */ +/* $Id: cgi_main.c,v 1.314 2007/02/20 19:19:14 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -116,6 +116,7 @@ static char *php_optarg = NULL; static int php_optind = 1; +static zend_module_entry cgi_module_entry; static const opt_struct OPTIONS[] = { {'a', 0, interactive}, @@ -542,7 +543,7 @@ static int php_cgi_startup(sapi_module_struct *sapi_module) { - if (php_module_startup(sapi_module, NULL, 0) == FAILURE) { + if (php_module_startup(sapi_module, cgi_module_entry, 1) == FAILURE) { return FAILURE; } return SUCCESS; @@ -1211,7 +1212,7 @@ cgi_sapi_module.additional_functions = additional_functions; /* startup after we get the above ini override se we get things right */ - if (php_module_startup(cgi_sapi_module, cgi_module_entry, 1) == FAILURE) { + if (cgi_sapi_module.startup(cgi_sapi_module) == FAILURE) { #ifdef ZTS tsrm_shutdown(); #endif http://cvs.php.net/viewvc.cgi/php-src/sapi/cli/php_cli.c?r1=1.167r2=1.168diff_format=u Index: php-src/sapi/cli/php_cli.c diff -u php-src/sapi/cli/php_cli.c:1.167 php-src/sapi/cli/php_cli.c:1.168 --- php-src/sapi/cli/php_cli.c:1.167Tue Jan 23 20:02:29 2007 +++ php-src/sapi/cli/php_cli.c Tue Feb 20 19:19:14 2007 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: php_cli.c,v 1.167 2007/01/23 20:02:29 helly Exp $ */ +/* $Id: php_cli.c,v 1.168 2007/02/20 19:19:14 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -710,7 +710,7 @@ #endif /* startup after we get the above ini override se we get things right */ - if (php_module_startup(cli_sapi_module, NULL, 0)==FAILURE) { + if (cli_sapi_module.startup(cli_sapi_module)==FAILURE) { /* there is no way to see if we must call zend_ini_deactivate() * since we cannot check if EG(ini_directives) has been initialised * because the executor's constructor does not set initialize it. -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Mon Feb 19 14:13:35 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Initialize retval on each request http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.310r2=1.311diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.310 php-src/sapi/cgi/cgi_main.c:1.311 --- php-src/sapi/cgi/cgi_main.c:1.310 Fri Feb 16 11:30:38 2007 +++ php-src/sapi/cgi/cgi_main.c Mon Feb 19 14:13:35 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.310 2007/02/16 11:30:38 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.311 2007/02/19 14:13:35 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1615,6 +1615,7 @@ 1. we are running from shell and got filename was there 2. we are running as cgi or fastcgi */ + retval = FAILURE; if (cgi || SG(request_info).path_translated) { retval = php_fopen_primary_script(file_handle TSRMLS_CC); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Fri Feb 16 11:30:38 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed bug #40286 (PHP fastcgi with PHP_FCGI_CHILDREN don't kill children when parent is killed) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.309r2=1.310diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.309 php-src/sapi/cgi/cgi_main.c:1.310 --- php-src/sapi/cgi/cgi_main.c:1.309 Thu Feb 15 12:33:54 2007 +++ php-src/sapi/cgi/cgi_main.c Fri Feb 16 11:30:38 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.309 2007/02/15 12:33:54 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.310 2007/02/16 11:30:38 dmitry Exp $ */ #include php.h #include php_globals.h @@ -344,15 +344,13 @@ static int sapi_cgi_read_post(char *buffer, uint count_bytes TSRMLS_DC) { - uint read_bytes=0, tmp_read_bytes; - char *pos = buffer; + int read_bytes=0, tmp_read_bytes; count_bytes = MIN(count_bytes, (uint) SG(request_info).content_length - SG(read_post_bytes)); while (read_bytes count_bytes) { if (fcgi_is_fastcgi()) { fcgi_request *request = (fcgi_request*) SG(server_context); - tmp_read_bytes = fcgi_read(request, pos, count_bytes - read_bytes); - pos += tmp_read_bytes; + tmp_read_bytes = fcgi_read(request, buffer + read_bytes, count_bytes - read_bytes); } else { tmp_read_bytes = read(0, buffer + read_bytes, count_bytes - read_bytes); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c fastcgi.c fastcgi.h
dmitry Thu Feb 15 12:33:54 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c fastcgi.c fastcgi.h Log: Fixed bug #40414 (possivle endless fork() loop when running fastcgi) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.308r2=1.309diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.308 php-src/sapi/cgi/cgi_main.c:1.309 --- php-src/sapi/cgi/cgi_main.c:1.308 Mon Jan 29 19:38:21 2007 +++ php-src/sapi/cgi/cgi_main.c Thu Feb 15 12:33:54 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.308 2007/01/29 19:38:21 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.309 2007/02/15 12:33:54 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1338,6 +1338,10 @@ exit(1); } + if (fcgi_in_shutdown()) { + exit(0); + } + while (parent) { do { #ifdef DEBUG_FASTCGI http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.29r2=1.30diff_format=u Index: php-src/sapi/cgi/fastcgi.c diff -u php-src/sapi/cgi/fastcgi.c:1.29 php-src/sapi/cgi/fastcgi.c:1.30 --- php-src/sapi/cgi/fastcgi.c:1.29 Thu Feb 15 12:05:25 2007 +++ php-src/sapi/cgi/fastcgi.c Thu Feb 15 12:33:54 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.c,v 1.29 2007/02/15 12:05:25 dmitry Exp $ */ +/* $Id: fastcgi.c,v 1.30 2007/02/15 12:33:54 dmitry Exp $ */ #include php.h #include fastcgi.h @@ -164,6 +164,11 @@ #endif +int fcgi_in_shutdown(void) +{ + return in_shutdown; +} + int fcgi_init(void) { if (!is_initialized) { http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.h?r1=1.6r2=1.7diff_format=u Index: php-src/sapi/cgi/fastcgi.h diff -u php-src/sapi/cgi/fastcgi.h:1.6 php-src/sapi/cgi/fastcgi.h:1.7 --- php-src/sapi/cgi/fastcgi.h:1.6 Mon Jan 1 09:29:36 2007 +++ php-src/sapi/cgi/fastcgi.h Thu Feb 15 12:33:54 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: fastcgi.h,v 1.6 2007/01/01 09:29:36 sebastian Exp $ */ +/* $Id: fastcgi.h,v 1.7 2007/02/15 12:33:54 dmitry Exp $ */ /* FastCGI protocol */ @@ -110,6 +110,7 @@ int fcgi_init(void); int fcgi_is_fastcgi(void); +int fcgi_in_shutdown(void); int fcgi_listen(const char *path, int backlog); void fcgi_init_request(fcgi_request *req, int listen_socket); int fcgi_accept_request(fcgi_request *req); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Mon Jan 29 19:38:21 2007 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Prevent flush() of closed handle on php_module_shutdown() http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.307r2=1.308diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.307 php-src/sapi/cgi/cgi_main.c:1.308 --- php-src/sapi/cgi/cgi_main.c:1.307 Mon Jan 1 09:29:36 2007 +++ php-src/sapi/cgi/cgi_main.c Mon Jan 29 19:38:21 2007 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.307 2007/01/01 09:29:36 sebastian Exp $ */ +/* $Id: cgi_main.c,v 1.308 2007/01/29 19:38:21 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1451,6 +1451,7 @@ case 'i': /* php info quit */ if (php_request_startup(TSRMLS_C) == FAILURE) { + SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); return FAILURE; } @@ -1497,6 +1498,7 @@ case 'v': /* show php version quit */ no_headers = 1; if (php_request_startup(TSRMLS_C) == FAILURE) { + SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); return FAILURE; } @@ -1597,6 +1599,7 @@ if (fastcgi) { fcgi_finish_request(request); } + SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); return FAILURE; } @@ -1627,6 +1630,7 @@ goto fastcgi_request_done; } php_request_shutdown((void *) 0); + SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); return FAILURE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
tony2001Thu Dec 28 22:36:45 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: make sure l != 0 http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.305r2=1.306diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.305 php-src/sapi/cgi/cgi_main.c:1.306 --- php-src/sapi/cgi/cgi_main.c:1.305 Wed Nov 15 13:34:05 2006 +++ php-src/sapi/cgi/cgi_main.c Thu Dec 28 22:36:45 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.305 2006/11/15 13:34:05 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.306 2006/12/28 22:36:45 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -825,7 +825,7 @@ int path_translated_len = 0; char *path_translated = NULL; - if (env_document_root[l - 1] == '/') { + if (l env_document_root[l - 1] == '/') { --l; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Wed Nov 15 13:34:05 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Removed unnecessary getenv/putenv calls http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.304r2=1.305diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.304 php-src/sapi/cgi/cgi_main.c:1.305 --- php-src/sapi/cgi/cgi_main.c:1.304 Wed Nov 15 11:14:27 2006 +++ php-src/sapi/cgi/cgi_main.c Wed Nov 15 13:34:05 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.304 2006/11/15 11:14:27 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.305 2006/11/15 13:34:05 dmitry Exp $ */ #include php.h #include php_globals.h @@ -736,35 +736,19 @@ if (CGIG(fix_pathinfo)) { struct stat st; + char *real_path; char *env_redirect_url = sapi_cgibin_getenv(REDIRECT_URL, sizeof(REDIRECT_URL)-1 TSRMLS_CC); char *env_document_root = sapi_cgibin_getenv(DOCUMENT_ROOT, sizeof(DOCUMENT_ROOT)-1 TSRMLS_CC); - - /* save the originals first for anything we change later */ - if (env_path_translated) { - _sapi_cgibin_putenv(ORIG_PATH_TRANSLATED, env_path_translated TSRMLS_CC); - } - if (env_path_info) { - _sapi_cgibin_putenv(ORIG_PATH_INFO, env_path_info TSRMLS_CC); - } - if (env_script_name) { - _sapi_cgibin_putenv(ORIG_SCRIPT_NAME, env_script_name TSRMLS_CC); - } - if (env_script_filename) { - _sapi_cgibin_putenv(ORIG_SCRIPT_FILENAME, env_script_filename TSRMLS_CC); - } - if (!env_document_root) { - /* ini version of document root */ - if (!env_document_root) { - env_document_root = PG(doc_root); - } - /* set the document root, this makes a more - consistent env for php scripts */ - if (env_document_root) { - env_document_root = _sapi_cgibin_putenv(DOCUMENT_ROOT, env_document_root TSRMLS_CC); - /* fix docroot */ - TRANSLATE_SLASHES(env_document_root); - } - } + char *orig_path_translated = env_path_translated; + char *orig_path_info = env_path_info; + char *orig_script_name = env_script_name; + char *orig_script_filename = env_script_filename; + + if (!env_document_root PG(doc_root)) { + env_document_root = _sapi_cgibin_putenv(DOCUMENT_ROOT, PG(doc_root) TSRMLS_CC); + /* fix docroot */ + TRANSLATE_SLASHES(env_document_root); + } if (env_path_translated != NULL env_redirect_url != NULL) { /* @@ -774,7 +758,7 @@ */ script_path_translated = env_path_translated; /* we correct SCRIPT_NAME now in case we don't have PATH_INFO */ - env_script_name = _sapi_cgibin_putenv(SCRIPT_NAME, env_redirect_url TSRMLS_CC); + env_script_name = env_redirect_url; } #ifdef __riscos__ @@ -788,7 +772,8 @@ * of it by stat'ing back through the '/' * this fixes url's like /info.php/test */ - if (script_path_translated stat(script_path_translated, st) == -1 ) { + if (script_path_translated + (real_path = tsrm_realpath(script_path_translated, NULL TSRMLS_CC)) == NULL) { char *pt = estrdup(script_path_translated); int len = strlen(pt); char *ptr; @@ -815,8 +800,19 @@ int pilen = strlen(env_path_info); char *path_info = env_path_info + pilen - slen; - env_path_info = _sapi_cgibin_putenv(PATH_INFO, path_info TSRMLS_CC); - script_path_translated = _sapi_cgibin_putenv(SCRIPT_FILENAME, pt TSRMLS_CC); +
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Tue Nov 14 10:32:11 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: cgi.* and fastcgi.* directives are moved to INI subsystem. The new directive cgi.check_shebang_line can be used to ommiting checnk for #! /usr/bin/php line. http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.302r2=1.303diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.302 php-src/sapi/cgi/cgi_main.c:1.303 --- php-src/sapi/cgi/cgi_main.c:1.302 Wed Oct 25 14:04:48 2006 +++ php-src/sapi/cgi/cgi_main.c Tue Nov 14 10:32:11 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.302 2006/10/25 14:04:48 iliaa Exp $ */ +/* $Id: cgi_main.c,v 1.303 2006/11/14 10:32:11 dmitry Exp $ */ #include php.h #include php_globals.h @@ -142,13 +142,27 @@ {'-', 0, NULL} /* end of args */ }; -/* true global. this is retreived once only, even for fastcgi */ -static long fix_pathinfo = 1; -static long discard_path = 0; -static long fcgi_logging = 1; +typedef struct _php_cgi_globals_struct { + zend_bool rfc2616_headers; + zend_bool nph; + zend_bool check_shebang_line; + zend_bool fix_pathinfo; + zend_bool force_redirect; + zend_bool discard_path; + char *redirect_status_env; + zend_bool fcgi_logging; +#ifdef PHP_WIN32 + zend_bool impersonate; +#endif +} php_cgi_globals_struct; -static long rfc2616_headers = 0; -static long cgi_nph = 0; +#ifdef ZTS +static int php_cgi_globals_id; +#define CGIG(v) TSRMG(php_cgi_globals_id, php_cgi_globals_struct *, v) +#else +static php_cgi_globals_struct php_cgi_globals; +#define CGIG(v) (php_cgi_globals.v) +#endif #ifdef PHP_WIN32 #define TRANSLATE_SLASHES(path) \ @@ -294,11 +308,11 @@ return SAPI_HEADER_SENT_SUCCESSFULLY; } - if (cgi_nph || SG(sapi_headers).http_response_code != 200) + if (CGIG(nph) || SG(sapi_headers).http_response_code != 200) { int len; - if (rfc2616_headers SG(sapi_headers).http_status_line) { + if (CGIG(rfc2616_headers) SG(sapi_headers).http_status_line) { len = snprintf(buf, SAPI_CGI_MAX_HEADER_LENGTH, %s\r\n, SG(sapi_headers).http_status_line); @@ -491,9 +505,10 @@ static void sapi_cgi_log_message(char *message) { - if (fcgi_is_fastcgi() fcgi_logging) { + TSRMLS_FETCH(); + + if (fcgi_is_fastcgi() CGIG(fcgi_logging)) { fcgi_request *request; - TSRMLS_FETCH(); request = (fcgi_request*) SG(server_context); if (request) { @@ -718,7 +733,7 @@ char *env_path_info = sapi_cgibin_getenv(PATH_INFO, sizeof(PATH_INFO)-1 TSRMLS_CC); char *env_script_name = sapi_cgibin_getenv(SCRIPT_NAME, sizeof(SCRIPT_NAME)-1 TSRMLS_CC); - if (fix_pathinfo) { + if (CGIG(fix_pathinfo)) { struct stat st; char *env_redirect_url = sapi_cgibin_getenv(REDIRECT_URL, sizeof(REDIRECT_URL)-1 TSRMLS_CC); char *env_document_root = sapi_cgibin_getenv(DOCUMENT_ROOT, sizeof(DOCUMENT_ROOT)-1 TSRMLS_CC); @@ -877,7 +892,7 @@ } else { SG(request_info).request_uri = env_script_name; } - if (!discard_path env_path_translated) { + if (!CGIG(discard_path) env_path_translated) { script_path_translated = env_path_translated; } } @@ -933,6 +948,82 @@ } #endif +PHP_INI_BEGIN() + STD_PHP_INI_ENTRY(cgi.rfc2616_headers, 0, PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals) + STD_PHP_INI_ENTRY(cgi.nph, 0, PHP_INI_ALL, OnUpdateBool, nph, php_cgi_globals_struct, php_cgi_globals) + STD_PHP_INI_ENTRY(cgi.check_shebang_line, 1, PHP_INI_SYSTEM, OnUpdateBool, check_shebang_line, php_cgi_globals_struct, php_cgi_globals) + STD_PHP_INI_ENTRY(cgi.force_redirect, 1, PHP_INI_SYSTEM, OnUpdateBool, force_redirect, php_cgi_globals_struct, php_cgi_globals) + STD_PHP_INI_ENTRY(cgi.redirect_status_env, NULL, PHP_INI_SYSTEM, OnUpdateString, redirect_status_env, php_cgi_globals_struct, php_cgi_globals) + STD_PHP_INI_ENTRY(cgi.fix_pathinfo,1, PHP_INI_SYSTEM, OnUpdateBool, fix_pathinfo, php_cgi_globals_struct, php_cgi_globals) + STD_PHP_INI_ENTRY(cgi.discard_path,0, PHP_INI_SYSTEM, OnUpdateBool, discard_path, php_cgi_globals_struct, php_cgi_globals) + STD_PHP_INI_ENTRY(fastcgi.logging, 1, PHP_INI_SYSTEM, OnUpdateBool, fcgi_logging,
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
iliaa Wed Oct 25 14:04:49 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed build http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.301r2=1.302diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.301 php-src/sapi/cgi/cgi_main.c:1.302 --- php-src/sapi/cgi/cgi_main.c:1.301 Mon Oct 23 19:17:51 2006 +++ php-src/sapi/cgi/cgi_main.c Wed Oct 25 14:04:48 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.301 2006/10/23 19:17:51 iliaa Exp $ */ +/* $Id: cgi_main.c,v 1.302 2006/10/25 14:04:48 iliaa Exp $ */ #include php.h #include php_globals.h @@ -485,7 +485,7 @@ php_import_environment_variables(track_vars_array TSRMLS_CC); /* Build the special-case PHP_SELF variable for the CGI version */ if (sapi_module.input_filter(PARSE_SERVER, PHP_SELF, val, strlen(val), new_val_len TSRMLS_CC)) { - php_register_variable_safe(PHP_SELF, var, new_val_len, track_vars_array TSRMLS_CC); + php_register_variable_safe(PHP_SELF, val, new_val_len, track_vars_array TSRMLS_CC); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
tony2001Sat Sep 23 12:27:35 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: fix CGI build http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.299r2=1.300diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.299 php-src/sapi/cgi/cgi_main.c:1.300 --- php-src/sapi/cgi/cgi_main.c:1.299 Fri Sep 22 17:42:08 2006 +++ php-src/sapi/cgi/cgi_main.c Sat Sep 23 12:27:35 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.299 2006/09/22 17:42:08 iliaa Exp $ */ +/* $Id: cgi_main.c,v 1.300 2006/09/23 12:27:35 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -1033,19 +1033,19 @@ if ((val = strchr(php_optarg, '='))) { val++; if (!isalnum(*val) *val != '' *val != '\'' *val != '\0') { - cli_sapi_module.ini_entries = realloc(cli_sapi_module.ini_entries, ini_entries_len + len + sizeof(\\\n\0)); - memcpy(cli_sapi_module.ini_entries + ini_entries_len, php_optarg, (val - php_optarg)); + cgi_sapi_module.ini_entries = realloc(cgi_sapi_module.ini_entries, ini_entries_len + len + sizeof(\\\n\0)); + memcpy(cgi_sapi_module.ini_entries + ini_entries_len, php_optarg, (val - php_optarg)); ini_entries_len += (val - php_optarg); - memcpy(cli_sapi_module.ini_entries + ini_entries_len, \, 1); + memcpy(cgi_sapi_module.ini_entries + ini_entries_len, \, 1); ini_entries_len++; - memcpy(cli_sapi_module.ini_entries + ini_entries_len, val, len - (val - php_optarg)); + memcpy(cgi_sapi_module.ini_entries + ini_entries_len, val, len - (val - php_optarg)); ini_entries_len += len - (val - php_optarg); - memcpy(cli_sapi_module.ini_entries + ini_entries_len, \\n\0, sizeof(\\n\0)); + memcpy(cgi_sapi_module.ini_entries + ini_entries_len, \\n\0, sizeof(\\n\0)); ini_entries_len += sizeof(\n\0\) - 2; } else { - cli_sapi_module.ini_entries = realloc(cli_sapi_module.ini_entries, ini_entries_len + len + sizeof(\n\0)); - memcpy(cli_sapi_module.ini_entries + ini_entries_len, php_optarg, len); - memcpy(cli_sapi_module.ini_entries + ini_entries_len + len, \n\0, sizeof(\n\0)); + cgi_sapi_module.ini_entries = realloc(cgi_sapi_module.ini_entries, ini_entries_len + len + sizeof(\n\0)); + memcpy(cgi_sapi_module.ini_entries + ini_entries_len, php_optarg, len); + memcpy(cgi_sapi_module.ini_entries + ini_entries_len + len, \n\0, sizeof(\n\0)); ini_entries_len += len + sizeof(\n\0) - 2; } } else { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Thu Aug 31 13:12:18 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: FastCGI environment variables must not be overriden by system environment variables http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.297r2=1.298diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.297 php-src/sapi/cgi/cgi_main.c:1.298 --- php-src/sapi/cgi/cgi_main.c:1.297 Tue Jun 27 08:26:53 2006 +++ php-src/sapi/cgi/cgi_main.c Thu Aug 31 13:12:18 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.297 2006/06/27 08:26:53 tony2001 Exp $ */ +/* $Id: cgi_main.c,v 1.298 2006/08/31 13:12:18 dmitry Exp $ */ #include php.h #include php_globals.h @@ -451,6 +451,10 @@ zval_copy_ctor(array_ptr); return; } + + /* call php's original import as a catch-all */ + php_php_import_environment_variables(array_ptr TSRMLS_CC); + if (fcgi_is_fastcgi()) { fcgi_request *request = (fcgi_request*) SG(server_context); HashPosition pos; @@ -466,8 +470,6 @@ php_register_variable(var.s, *val, array_ptr TSRMLS_CC); } } - /* call php's original import as a catch-all */ - php_php_import_environment_variables(array_ptr TSRMLS_CC); } static void sapi_cgi_register_variables(zval *track_vars_array TSRMLS_DC) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c /sapi/cli php_cli.c
tony2001Tue Jun 27 08:26:54 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c /php-src/sapi/cli php_cli.c Log: fix #37920 (compilation problems on z/OS) http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.296r2=1.297diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.296 php-src/sapi/cgi/cgi_main.c:1.297 --- php-src/sapi/cgi/cgi_main.c:1.296 Sun Jun 25 19:17:20 2006 +++ php-src/sapi/cgi/cgi_main.c Tue Jun 27 08:26:53 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.296 2006/06/25 19:17:20 bjori Exp $ */ +/* $Id: cgi_main.c,v 1.297 2006/06/27 08:26:53 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -1525,12 +1525,12 @@ /* #!php support */ c = fgetc(file_handle.handle.fp); if (c == '#') { - while (c != 10 c != 13) { + while (c != '\n' c != '\r') { c = fgetc(file_handle.handle.fp); /* skip to end of line */ } /* handle situations where line is terminated by \r\n */ - if (c == 13) { - if (fgetc(file_handle.handle.fp) != 10) { + if (c == '\r') { + if (fgetc(file_handle.handle.fp) != '\n') { long pos = ftell(file_handle.handle.fp); fseek(file_handle.handle.fp, pos - 1, SEEK_SET); } http://cvs.php.net/viewvc.cgi/php-src/sapi/cli/php_cli.c?r1=1.159r2=1.160diff_format=u Index: php-src/sapi/cli/php_cli.c diff -u php-src/sapi/cli/php_cli.c:1.159 php-src/sapi/cli/php_cli.c:1.160 --- php-src/sapi/cli/php_cli.c:1.159Sun Jun 25 19:17:20 2006 +++ php-src/sapi/cli/php_cli.c Tue Jun 27 08:26:54 2006 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: php_cli.c,v 1.159 2006/06/25 19:17:20 bjori Exp $ */ +/* $Id: php_cli.c,v 1.160 2006/06/27 08:26:54 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -537,12 +537,12 @@ /* #!php support */ c = fgetc(file_handle-handle.fp); if (c == '#') { - while (c != 10 c != 13) { + while (c != '\n' c != '\r') { c = fgetc(file_handle-handle.fp); /* skip to end of line */ } /* handle situations where line is terminated by \r\n */ - if (c == 13) { - if (fgetc(file_handle-handle.fp) != 10) { + if (c == '\r') { + if (fgetc(file_handle-handle.fp) != '\n') { long pos = ftell(file_handle-handle.fp); fseek(file_handle-handle.fp, pos - 1, SEEK_SET); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
tony2001Mon Jun 19 11:38:51 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: add missing ifdef and avoid unused variable warning http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.293r2=1.294diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.293 php-src/sapi/cgi/cgi_main.c:1.294 --- php-src/sapi/cgi/cgi_main.c:1.293 Sat Jun 17 11:14:21 2006 +++ php-src/sapi/cgi/cgi_main.c Mon Jun 19 11:38:51 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.293 2006/06/17 11:14:21 nlopess Exp $ */ +/* $Id: cgi_main.c,v 1.294 2006/06/19 11:38:51 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -368,8 +368,10 @@ static char *_sapi_cgibin_putenv(char *name, char *value TSRMLS_DC) { int name_len; +#if !HAVE_SETENV || !HAVE_UNSETENV int len; char *buf; +#endif if (!name) { return NULL; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
tony2001Mon Jun 19 17:49:20 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: plug leak in CGI SAPI when running scripts with query string in console http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.294r2=1.295diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.294 php-src/sapi/cgi/cgi_main.c:1.295 --- php-src/sapi/cgi/cgi_main.c:1.294 Mon Jun 19 11:38:51 2006 +++ php-src/sapi/cgi/cgi_main.c Mon Jun 19 17:49:20 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.294 2006/06/19 11:38:51 tony2001 Exp $ */ +/* $Id: cgi_main.c,v 1.295 2006/06/19 17:49:20 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -922,6 +922,7 @@ */ int main(int argc, char *argv[]) { + int free_query_string = 0; int exit_status = SUCCESS; int cgi = 0, c, i, len; zend_file_handle file_handle; @@ -1443,7 +1444,7 @@ len += strlen(argv[i]) + 1; } - s = malloc(len + 1);/* leak - but only for command line version, so ok */ + s = malloc(len + 1); *s = '\0'; /* we are pretending it came from the environment */ for (i = php_optind, len = 0; i argc; i++) { strcat(s, argv[i]); @@ -1452,6 +1453,7 @@ } } SG(request_info).query_string = s; + free_query_string = 1; } } /* end !cgi !fastcgi */ @@ -1601,6 +1603,10 @@ free(SG(request_info).path_translated); SG(request_info).path_translated = NULL; } + if (free_query_string SG(request_info).query_string) { + free(SG(request_info).query_string); + SG(request_info).query_string = NULL; + } } if (!fastcgi) break; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Tue Jun 13 14:22:27 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Removed warnings http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.291r2=1.292diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.291 php-src/sapi/cgi/cgi_main.c:1.292 --- php-src/sapi/cgi/cgi_main.c:1.291 Sat Jun 3 22:00:30 2006 +++ php-src/sapi/cgi/cgi_main.c Tue Jun 13 14:22:27 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.291 2006/06/03 22:00:30 johannes Exp $ */ +/* $Id: cgi_main.c,v 1.292 2006/06/13 14:22:27 dmitry Exp $ */ #include php.h #include php_globals.h @@ -313,14 +313,14 @@ PHPWRITE_H(buf, len); } - h = zend_llist_get_first_ex(sapi_headers-headers, pos); + h = (sapi_header_struct*)zend_llist_get_first_ex(sapi_headers-headers, pos); while (h) { /* prevent CRLFCRLF */ if (h-header_len) { PHPWRITE_H(h-header, h-header_len); PHPWRITE_H(\r\n, 2); } - h = zend_llist_get_next_ex(sapi_headers-headers, pos); + h = (sapi_header_struct*)zend_llist_get_next_ex(sapi_headers-headers, pos); } PHPWRITE_H(\r\n, 2); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c /sapi/cli php_cli.c
johannesSat Jun 3 22:00:31 2006 UTC Modified files: /php-src/sapi/cli php_cli.c /php-src/sapi/cgi cgi_main.c Log: - Removed useless -g command line option from CGI and CLI - Fixed conflicting behaviour if -B and -a are set with CLI - Fixed handling of auto_prepend and exceptions in readline-a-mode http://cvs.php.net/viewcvs.cgi/php-src/sapi/cli/php_cli.c?r1=1.155r2=1.156diff_format=u Index: php-src/sapi/cli/php_cli.c diff -u php-src/sapi/cli/php_cli.c:1.155 php-src/sapi/cli/php_cli.c:1.156 --- php-src/sapi/cli/php_cli.c:1.155Sat Jun 3 11:19:44 2006 +++ php-src/sapi/cli/php_cli.c Sat Jun 3 22:00:30 2006 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: php_cli.c,v 1.155 2006/06/03 11:19:44 mike Exp $ */ +/* $Id: php_cli.c,v 1.156 2006/06/03 22:00:30 johannes Exp $ */ #include php.h #include php_globals.h @@ -130,7 +130,6 @@ {'e', 0, profile-info}, {'F', 1, process-file}, {'f', 1, file}, - {'g', 1, global}, {'h', 0, help}, {'i', 0, info}, {'l', 0, syntax-check}, @@ -424,7 +423,7 @@ -n No php.ini file will be used\n -d foo[=bar] Define INI entry foo with value 'bar'\n -e Generate extended information for debugger/profiler\n - -f fileParse file.\n + -f fileParse and execute file.\n -h This help\n -i PHP information\n -l Syntax check only (lint)\n @@ -453,21 +452,6 @@ } /* }}} */ -static void php_register_command_line_global_vars(char **arg TSRMLS_DC) -{ - char *var, *val; - - var = *arg; - val = strchr(var, '='); - if (!val) { - printf(No value specified for variable '%s'\n, var); - } else { - *val++ = '\0'; - php_register_variable(var, val, NULL TSRMLS_CC); - } - efree(*arg); -} - static php_stream *s_in_process = NULL; static void cli_register_file_handles(TSRMLS_D) @@ -577,7 +561,6 @@ char *orig_optarg=php_optarg; char *arg_free=NULL, **arg_excp=arg_free; char *script_file=NULL; - zend_llist global_vars; int interactive=0; int module_started = 0; int lineno = 0; @@ -699,8 +682,6 @@ module_started = 1; zend_first_try { - zend_llist_init(global_vars, sizeof(char *), NULL, 0); - CG(in_compilation) = 0; /* not initialized but needed for several options */ EG(uninitialized_zval_ptr) = NULL; @@ -782,12 +763,11 @@ case 'a': /* interactive mode */ if (!interactive) { -#if (HAVE_LIBREADLINE || HAVE_LIBEDIT) !defined(COMPILE_DL_READLINE) - printf(Interactive shell\n\n); -#else - printf(Interactive mode enabled\n\n); -#endif - fflush(stdout); + if (behavior != PHP_MODE_STANDARD) { + param_error = param_mode_conflict; + break; + } + interactive=1; } break; @@ -825,14 +805,6 @@ script_file = php_optarg; break; - case 'g': /* define global variables on command line */ - { - char *arg = estrdup(php_optarg); - - zend_llist_add_element(global_vars, arg); - } - break; - case 'l': /* syntax check mode */ if (behavior != PHP_MODE_STANDARD) { break; @@ -860,7 +832,7 @@ param_error = You can use -r only once.\n; break; } - } else if (behavior != PHP_MODE_STANDARD) { + } else if (behavior != PHP_MODE_STANDARD || interactive) { param_error = param_mode_conflict; break; } @@ -888,7 +860,7 @@ param_error = You can use -B only once.\n;
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Wed May 24 07:52:59 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed bug #37341 ($_SERVER in included file is shortened to two entries, if $_ENV gets used). http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.287r2=1.288diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.287 php-src/sapi/cgi/cgi_main.c:1.288 --- php-src/sapi/cgi/cgi_main.c:1.287 Mon May 15 14:30:50 2006 +++ php-src/sapi/cgi/cgi_main.c Wed May 24 07:52:58 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.287 2006/05/15 14:30:50 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.288 2006/05/24 07:52:58 dmitry Exp $ */ #include php.h #include php_globals.h @@ -413,14 +413,18 @@ void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC) { if (PG(http_globals)[TRACK_VARS_ENV] - array_ptr != PG(http_globals)[TRACK_VARS_ENV]) { + array_ptr != PG(http_globals)[TRACK_VARS_ENV] + Z_TYPE_P(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY + zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_ENV])) 0) { zval_dtor(array_ptr); *array_ptr = *PG(http_globals)[TRACK_VARS_ENV]; INIT_PZVAL(array_ptr); zval_copy_ctor(array_ptr); return; } else if (PG(http_globals)[TRACK_VARS_SERVER] - array_ptr != PG(http_globals)[TRACK_VARS_SERVER]) { + array_ptr != PG(http_globals)[TRACK_VARS_SERVER] + Z_TYPE_P(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY + zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER])) 0) { zval_dtor(array_ptr); *array_ptr = *PG(http_globals)[TRACK_VARS_SERVER]; INIT_PZVAL(array_ptr); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Wed May 24 09:41:55 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed bug #37256 (php-fastcgi dosen't handle connection abort) http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.288r2=1.289diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.288 php-src/sapi/cgi/cgi_main.c:1.289 --- php-src/sapi/cgi/cgi_main.c:1.288 Wed May 24 07:52:58 2006 +++ php-src/sapi/cgi/cgi_main.c Wed May 24 09:41:55 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.288 2006/05/24 07:52:58 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.289 2006/05/24 09:41:55 dmitry Exp $ */ #include php.h #include php_globals.h @@ -273,7 +273,7 @@ #ifndef PHP_WIN32 !parent #endif - request fcgi_flush(request, 0) == -1) { + request !fcgi_flush(request, 0)) { php_handle_aborted_connection(); } return; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c fastcgi.c fastcgi.h
dmitry Mon May 15 14:30:50 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c fastcgi.c fastcgi.h Log: - Removed source compatibility with libfcgi - Optimized access to FastCGI environment using HashTable instead of linear sear ch - Allowed PHP_FCGI_MAX_REQUESTS=0 to disable PHP die - Allowed PHP_FCGI_CHILDREN=0 to disable PHP spawn workers http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.286r2=1.287diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.286 php-src/sapi/cgi/cgi_main.c:1.287 --- php-src/sapi/cgi/cgi_main.c:1.286 Wed May 3 19:40:49 2006 +++ php-src/sapi/cgi/cgi_main.c Mon May 15 14:30:50 2006 @@ -17,10 +17,11 @@ | Zeev Suraski [EMAIL PROTECTED]| | FastCGI: Ben Mansell [EMAIL PROTECTED] | | Shane Caraveo [EMAIL PROTECTED] | + | Dmitry Stogov [EMAIL PROTECTED] | +--+ */ -/* $Id: cgi_main.c,v 1.286 2006/05/03 19:40:49 tony2001 Exp $ */ +/* $Id: cgi_main.c,v 1.287 2006/05/15 14:30:50 dmitry Exp $ */ #include php.h #include php_globals.h @@ -81,9 +82,7 @@ #include fastcgi.h -#ifdef PHP_WIN32 -extern int OS_SetImpersonate(void); -#else +#ifndef PHP_WIN32 /* XXX this will need to change later when threaded fastcgi is implemented. shane */ struct sigaction act, old_term, old_quit, old_int; @@ -227,9 +226,9 @@ size_t ret; #endif - if (!FCGX_IsCGI()) { - FCGX_Request *request = (FCGX_Request *) SG(server_context); - long ret = FCGX_PutStr(str, str_length, request-out); + if (fcgi_is_fastcgi()) { + fcgi_request *request = (fcgi_request*) SG(server_context); + long ret = fcgi_write(request, FCGI_STDOUT, str, str_length); if (ret = 0) { return 0; } @@ -268,13 +267,13 @@ static void sapi_cgibin_flush(void *server_context) { - if (!FCGX_IsCGI()) { - FCGX_Request *request = (FCGX_Request *) server_context; + if (fcgi_is_fastcgi()) { + fcgi_request *request = (fcgi_request*) server_context; if ( #ifndef PHP_WIN32 !parent #endif - request FCGX_FFlush(request-out) == -1) { + request fcgi_flush(request, 0) == -1) { php_handle_aborted_connection(); } return; @@ -337,9 +336,9 @@ count_bytes = MIN(count_bytes, (uint) SG(request_info).content_length - SG(read_post_bytes)); while (read_bytes count_bytes) { - if (!FCGX_IsCGI()) { - FCGX_Request *request = (FCGX_Request *) SG(server_context); - tmp_read_bytes = FCGX_GetStr(pos, count_bytes - read_bytes, request-in); + if (fcgi_is_fastcgi()) { + fcgi_request *request = (fcgi_request*) SG(server_context); + tmp_read_bytes = fcgi_read(request, pos, count_bytes - read_bytes); pos += tmp_read_bytes; } else { tmp_read_bytes = read(0, buffer + read_bytes, count_bytes - read_bytes); @@ -358,9 +357,9 @@ is provided to PHP. It is always sent to PHP at the start of a request. So we have to do our own lookup to get env vars. This could probably be faster somehow. */ - if (!FCGX_IsCGI()) { - FCGX_Request *request = (FCGX_Request *) SG(server_context); - return FCGX_GetParam(name,request-envp); + if (fcgi_is_fastcgi()) { + fcgi_request *request = (fcgi_request*) SG(server_context); + return fcgi_getenv(request, name, name_len); } /* if cgi, or fastcgi and not found in fcgi env check the regular environment */ @@ -369,43 +368,46 @@ static char *_sapi_cgibin_putenv(char *name, char *value TSRMLS_DC) { - int len = 0; - char *buf = NULL; + int name_len; + int len; + char *buf; + if (!name) { return NULL; } - len = strlen(name) + (value ? strlen(value) : 0) + sizeof(=) + 2; - buf = (char *) malloc(len); - if (buf == NULL) { - return getenv(name); - } - if (value) { - snprintf(buf, len - 1, %s=%s, name, value); - } else { - snprintf(buf, len - 1, %s=, name); - } + name_len = strlen(name); + /* when php is started by mod_fastcgi, no regular environment is provided to PHP. It is always sent to PHP at the start of a request. So we have to do our own lookup to get env vars. This could probably be faster somehow. */ -
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
tony2001Wed May 3 19:40:49 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: plug leak http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.285r2=1.286diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.285 php-src/sapi/cgi/cgi_main.c:1.286 --- php-src/sapi/cgi/cgi_main.c:1.285 Tue Apr 18 06:58:10 2006 +++ php-src/sapi/cgi/cgi_main.c Wed May 3 19:40:49 2006 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.285 2006/04/18 06:58:10 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.286 2006/05/03 19:40:49 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -1408,6 +1408,7 @@ if (script_file) { /* override path_translated if -f on command line */ + STR_FREE(SG(request_info).path_translated); SG(request_info).path_translated = script_file; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Tue Apr 18 06:58:10 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed memory leaks http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.284r2=1.285diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.284 php-src/sapi/cgi/cgi_main.c:1.285 --- php-src/sapi/cgi/cgi_main.c:1.284 Fri Apr 7 13:45:51 2006 +++ php-src/sapi/cgi/cgi_main.c Tue Apr 18 06:58:10 2006 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.284 2006/04/07 13:45:51 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.285 2006/04/18 06:58:10 dmitry Exp $ */ #include php.h #include php_globals.h @@ -412,12 +412,16 @@ { if (PG(http_globals)[TRACK_VARS_ENV] array_ptr != PG(http_globals)[TRACK_VARS_ENV]) { + zval_dtor(array_ptr); *array_ptr = *PG(http_globals)[TRACK_VARS_ENV]; + INIT_PZVAL(array_ptr); zval_copy_ctor(array_ptr); return; } else if (PG(http_globals)[TRACK_VARS_SERVER] array_ptr != PG(http_globals)[TRACK_VARS_SERVER]) { + zval_dtor(array_ptr); *array_ptr = *PG(http_globals)[TRACK_VARS_SERVER]; + INIT_PZVAL(array_ptr); zval_copy_ctor(array_ptr); return; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Fri Apr 7 12:39:28 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Removed unnecessary copying http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.282r2=1.283diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.282 php-src/sapi/cgi/cgi_main.c:1.283 --- php-src/sapi/cgi/cgi_main.c:1.282 Thu Mar 23 10:20:14 2006 +++ php-src/sapi/cgi/cgi_main.c Fri Apr 7 12:39:28 2006 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.282 2006/03/23 10:20:14 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.283 2006/04/07 12:39:28 dmitry Exp $ */ #include php.h #include php_globals.h @@ -412,16 +412,16 @@ { if (!FCGX_IsCGI()) { FCGX_Request *request = (FCGX_Request *) SG(server_context); - char **env, *p, *t; + char **env, *p; for (env = request-envp; env != NULL *env != NULL; env++) { p = strchr(*env, '='); if (!p) { /* malformed entry? */ continue; } - t = estrndup(*env, p - *env); - php_register_variable(t, p + 1, array_ptr TSRMLS_CC); - efree(t); + *p = 0; + php_register_variable(*env, p + 1, array_ptr TSRMLS_CC); + *p = '='; } } /* call php's original import as a catch-all */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Fri Apr 7 13:45:51 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: CGI anf FastCGI assume $_SERVER and $_ENV have the same values, so we don't need construct the same arrays twich and may just copy it http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.283r2=1.284diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.283 php-src/sapi/cgi/cgi_main.c:1.284 --- php-src/sapi/cgi/cgi_main.c:1.283 Fri Apr 7 12:39:28 2006 +++ php-src/sapi/cgi/cgi_main.c Fri Apr 7 13:45:51 2006 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.283 2006/04/07 12:39:28 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.284 2006/04/07 13:45:51 dmitry Exp $ */ #include php.h #include php_globals.h @@ -410,6 +410,17 @@ void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC) { + if (PG(http_globals)[TRACK_VARS_ENV] + array_ptr != PG(http_globals)[TRACK_VARS_ENV]) { + *array_ptr = *PG(http_globals)[TRACK_VARS_ENV]; + zval_copy_ctor(array_ptr); + return; + } else if (PG(http_globals)[TRACK_VARS_SERVER] + array_ptr != PG(http_globals)[TRACK_VARS_SERVER]) { + *array_ptr = *PG(http_globals)[TRACK_VARS_SERVER]; + zval_copy_ctor(array_ptr); + return; + } if (!FCGX_IsCGI()) { FCGX_Request *request = (FCGX_Request *) SG(server_context); char **env, *p; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Thu Mar 23 10:20:14 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: MTH: Allowed '-b' with UNIX sockets http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.281r2=1.282diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.281 php-src/sapi/cgi/cgi_main.c:1.282 --- php-src/sapi/cgi/cgi_main.c:1.281 Fri Mar 17 13:45:43 2006 +++ php-src/sapi/cgi/cgi_main.c Thu Mar 23 10:20:14 2006 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.281 2006/03/17 13:45:43 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.282 2006/03/23 10:20:14 dmitry Exp $ */ #include php.h #include php_globals.h @@ -869,6 +869,19 @@ exit(0); } +#ifndef PHP_WIN32 +static int is_port_number(const char *bindpath) +{ + while (*bindpath) { + if (*bindpath '0' || *bindpath '9') { + return 0; + } + bindpath++; + } + return 1; +} +#endif + /* {{{ main */ int main(int argc, char *argv[]) @@ -1104,7 +1117,7 @@ * path (it's what the fastcgi library expects) */ - if (strchr(bindpath, ':') == NULL) { + if (strchr(bindpath, ':') == NULL is_port_number(bindpath)) { char *tmp; tmp = malloc(strlen(bindpath) + 2); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Fri Mar 17 09:32:47 2006 UTC Modified files: /php-src/sapi/cgi cgi_main.c Log: Optimized FastCGI SAPI check. Check for ini options only once. http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.279r2=1.280diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.279 php-src/sapi/cgi/cgi_main.c:1.280 --- php-src/sapi/cgi/cgi_main.c:1.279 Thu Mar 16 16:53:09 2006 +++ php-src/sapi/cgi/cgi_main.c Fri Mar 17 09:32:47 2006 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.279 2006/03/16 16:53:09 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.280 2006/03/17 09:32:47 dmitry Exp $ */ #include php.h #include php_globals.h @@ -147,6 +147,10 @@ /* true global. this is retreived once only, even for fastcgi */ static long fix_pathinfo = 1; static long discard_path = 0; +static long fcgi_logging = 1; + +static long rfc2616_headers = 0; +static long cgi_nph = 0; #ifdef PHP_WIN32 #define TRANSLATE_SLASHES(path) \ @@ -287,25 +291,12 @@ char buf[SAPI_CGI_MAX_HEADER_LENGTH]; sapi_header_struct *h; zend_llist_position pos; - long rfc2616_headers = 0, nph = 0; if (SG(request_info).no_headers == 1) { return SAPI_HEADER_SENT_SUCCESSFULLY; } - /* Check wheater to send RFC2616 style headers compatible with -* PHP versions 4.2.3 and earlier compatible with web servers -* such as IIS. Default is informal CGI RFC header compatible -* with Apache. -*/ - if (cfg_get_long(cgi.rfc2616_headers, rfc2616_headers) == FAILURE) { - rfc2616_headers = 0; - } - - if (cfg_get_long(cgi.nph, nph) == FAILURE) { - nph = 0; - } - if (nph || SG(sapi_headers).http_response_code != 200) + if (cgi_nph || SG(sapi_headers).http_response_code != 200) { int len; @@ -449,14 +440,9 @@ static void sapi_cgi_log_message(char *message) { - long logging = 1; - TSRMLS_FETCH(); + if (!FCGX_IsCGI() fcgi_logging) { + TSRMLS_FETCH(); - if (cfg_get_long(fastcgi.logging, logging) == FAILURE) { - logging = 1; - } - - if (!FCGX_IsCGI() logging) { FCGX_Request *request = (FCGX_Request *) SG(server_context); if (request) { FCGX_FPrintF(request-err, %s\n, message); @@ -1084,6 +1070,24 @@ discard_path = 0; } + if (cfg_get_long(fastcgi.logging, fcgi_logging) == FAILURE) { + fcgi_logging = 1; + } + + + /* Check wheater to send RFC2616 style headers compatible with +* PHP versions 4.2.3 and earlier compatible with web servers +* such as IIS. Default is informal CGI RFC header compatible +* with Apache. +*/ + if (cfg_get_long(cgi.rfc2616_headers, rfc2616_headers) == FAILURE) { + rfc2616_headers = 0; + } + + if (cfg_get_long(cgi.nph, cgi_nph) == FAILURE) { + cgi_nph = 0; + } + #ifndef PHP_WIN32 /* for windows, socket listening is broken in the fastcgi library itself so dissabling this feature on windows till time is available to fix it */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c config.w32 config9.m4
zeevSun Dec 25 12:45:01 2005 EDT Modified files: /php-src/sapi/cgi cgi_main.c config.w32 config9.m4 Log: Reimplement FastCGI interface Due to licensing restrictions that actually don't allow anybody to use the libfcgi code without prior approval from Open Market, which is impossible to obtain - we decided to reimplement this interface from scratch. The result is actually slightly faster, and more importantly, clear of any copyright issues. Implementation by Dmitry http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.272r2=1.273diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.272 php-src/sapi/cgi/cgi_main.c:1.273 --- php-src/sapi/cgi/cgi_main.c:1.272 Fri Dec 9 16:58:02 2005 +++ php-src/sapi/cgi/cgi_main.c Sun Dec 25 12:45:01 2005 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.272 2005/12/09 16:58:02 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.273 2005/12/25 12:45:01 zeev Exp $ */ #include php.h #include php_globals.h @@ -78,9 +78,8 @@ #include php_getopt.h -#include fcgi_config.h -#include fcgiapp.h -/* don't want to include fcgios.h, causes conflicts */ +#include fastcgi.h + #ifdef PHP_WIN32 extern int OS_SetImpersonate(void); #else http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/config.w32?r1=1.3r2=1.4diff_format=u Index: php-src/sapi/cgi/config.w32 diff -u php-src/sapi/cgi/config.w32:1.3 php-src/sapi/cgi/config.w32:1.4 --- php-src/sapi/cgi/config.w32:1.3 Wed Nov 23 18:08:51 2005 +++ php-src/sapi/cgi/config.w32 Sun Dec 25 12:45:01 2005 @@ -1,10 +1,9 @@ // vim:ft=javascript -// $Id: config.w32,v 1.3 2005/11/23 18:08:51 dmitry Exp $ +// $Id: config.w32,v 1.4 2005/12/25 12:45:01 zeev Exp $ ARG_ENABLE('cgi', 'Build CGI version of PHP', 'yes'); if (PHP_CGI == yes) { - SAPI('cgi', 'cgi_main.c getopt.c', 'php-cgi.exe', '/I sapi/cgi/libfcgi/include /D FCGI_STATIC'); - ADD_SOURCES('sapi/cgi/libfcgi', 'fcgi_stdio.c fcgiapp.c os_win32.c', 'cgi'); + SAPI('cgi', 'cgi_main.c getopt.c fastcgi.c', 'php-cgi.exe'); ADD_FLAG('LIBS_CGI', 'ws2_32.lib kernel32.lib advapi32.lib'); } http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/config9.m4?r1=1.18r2=1.19diff_format=u Index: php-src/sapi/cgi/config9.m4 diff -u php-src/sapi/cgi/config9.m4:1.18 php-src/sapi/cgi/config9.m4:1.19 --- php-src/sapi/cgi/config9.m4:1.18Wed Nov 23 18:08:51 2005 +++ php-src/sapi/cgi/config9.m4 Sun Dec 25 12:45:01 2005 @@ -1,5 +1,5 @@ dnl -dnl $Id: config9.m4,v 1.18 2005/11/23 18:08:51 dmitry Exp $ +dnl $Id: config9.m4,v 1.19 2005/12/25 12:45:01 zeev Exp $ dnl AC_ARG_ENABLE(cgi, @@ -45,6 +45,32 @@ if test $PHP_SAPI_CGI != no; then AC_MSG_RESULT(yes) +AC_MSG_CHECKING([for socklen_t in sys/socket.h]) +AC_EGREP_HEADER([socklen_t], [sys/socket.h], + [AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_SOCKLEN_T], [1], +[Define if the socklen_t typedef is in sys/socket.h])], + AC_MSG_RESULT([no])) + +AC_MSG_CHECKING([for sun_len in sys/un.h]) +AC_EGREP_HEADER([sun_len], [sys/un.h], + [AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_SOCKADDR_UN_SUN_LEN], [1], +[Define if sockaddr_un in sys/un.h contains a sun_len component])], + AC_MSG_RESULT([no])) + +AC_MSG_CHECKING([whether cross-process locking is required by accept()]) +case `uname -sr` in + IRIX\ 5.* | SunOS\ 5.* | UNIX_System_V\ 4.0) +AC_MSG_RESULT([yes]) +AC_DEFINE([USE_LOCKING], [1], + [Define if cross-process locking is required by accept()]) + ;; + *) +AC_MSG_RESULT([no]) + ;; +esac + PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/sapi/cgi/Makefile.frag) case $host_alias in *cygwin* ) @@ -58,11 +84,8 @@ PHP_TEST_WRITE_STDOUT -PHP_ADD_BUILD_DIR($abs_builddir/sapi/cgi/libfcgi) -PHP_FCGI_INCLUDE=-I$abs_srcdir/sapi/cgi/libfcgi/include - INSTALL_IT=@echo \Installing PHP CGI into: \$(INSTALL_ROOT)\$(bindir)/\; \$(INSTALL) -m 0755 \$(SAPI_CGI_PATH) \$(INSTALL_ROOT)\$(bindir)/\$(program_prefix)php\$(program_suffix)\$(EXEEXT) -PHP_SELECT_SAPI(cgi, program, libfcgi/fcgi_stdio.c libfcgi/fcgiapp.c libfcgi/os_unix.c cgi_main.c getopt.c, $PHP_FCGI_INCLUDE, '$(SAPI_CGI_PATH)') +PHP_SELECT_SAPI(cgi, program, fastcgi.c cgi_main.c getopt.c, '', '$(SAPI_CGI_PATH)') case $host_alias in *aix*) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
dmitry Fri Dec 9 11:58:05 2005 EDT Modified files: /php-src/sapi/cgi cgi_main.c Log: Bug #34429 (Output buffering cannot be turned off with FastCGI) http://cvs.php.net/diff.php/php-src/sapi/cgi/cgi_main.c?r1=1.271r2=1.272ty=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.271 php-src/sapi/cgi/cgi_main.c:1.272 --- php-src/sapi/cgi/cgi_main.c:1.271 Fri Dec 2 20:27:37 2005 +++ php-src/sapi/cgi/cgi_main.c Fri Dec 9 11:58:02 2005 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.271 2005/12/03 01:27:37 sniper Exp $ */ +/* $Id: cgi_main.c,v 1.272 2005/12/09 16:58:02 dmitry Exp $ */ #include php.h #include php_globals.h @@ -1205,6 +1205,8 @@ running--; } } + } else { + parent = 0; } #endif /* WIN32 */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
sniper Fri Dec 2 20:27:39 2005 EDT Modified files: /php-src/sapi/cgi cgi_main.c Log: - fix possible compile error http://cvs.php.net/diff.php/php-src/sapi/cgi/cgi_main.c?r1=1.270r2=1.271ty=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.270 php-src/sapi/cgi/cgi_main.c:1.271 --- php-src/sapi/cgi/cgi_main.c:1.270 Wed Nov 23 13:08:50 2005 +++ php-src/sapi/cgi/cgi_main.c Fri Dec 2 20:27:37 2005 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.270 2005/11/23 18:08:50 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.271 2005/12/03 01:27:37 sniper Exp $ */ #include php.h #include php_globals.h @@ -1595,7 +1595,7 @@ /*tsrm_shutdown();*/ #endif -#if PHP_WIN32 ZEND_DEBUG 0 +#if defined(PHP_WIN32) ZEND_DEBUG 0 _CrtDumpMemoryLeaks(); #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c /sapi/cli php_cli.c
johannesThu Oct 6 16:29:14 2005 EDT Modified files: /php-src/sapi/cgi cgi_main.c /php-src/sapi/cli php_cli.c Log: - Fix #34557 php -m exits with error 1 http://cvs.php.net/diff.php/php-src/sapi/cgi/cgi_main.c?r1=1.267r2=1.268ty=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267 php-src/sapi/cgi/cgi_main.c:1.268 --- php-src/sapi/cgi/cgi_main.c:1.267 Wed Aug 3 07:12:17 2005 +++ php-src/sapi/cgi/cgi_main.c Thu Oct 6 16:29:09 2005 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.267 2005/08/03 11:12:17 sniper Exp $ */ +/* $Id: cgi_main.c,v 1.268 2005/10/06 20:29:09 johannes Exp $ */ #include php.h #include php_globals.h @@ -1366,7 +1366,7 @@ } php_print_info(0x TSRMLS_CC); php_end_ob_buffers(1 TSRMLS_CC); - exit(1); + exit(0); break; case 'l': /* syntax check mode */ @@ -1384,7 +1384,7 @@ print_extensions(TSRMLS_C); php_printf(\n); php_end_ob_buffers(1 TSRMLS_CC); - exit(1); + exit(0); break; #if 0 /* not yet operational, see also below ... */ @@ -1417,7 +1417,7 @@ php_printf(PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2005 The PHP Group\n%s, PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #endif php_end_ob_buffers(1 TSRMLS_CC); - exit(1); + exit(0); break; case 'w': http://cvs.php.net/diff.php/php-src/sapi/cli/php_cli.c?r1=1.130r2=1.131ty=u Index: php-src/sapi/cli/php_cli.c diff -u php-src/sapi/cli/php_cli.c:1.130 php-src/sapi/cli/php_cli.c:1.131 --- php-src/sapi/cli/php_cli.c:1.130Mon Oct 3 07:54:46 2005 +++ php-src/sapi/cli/php_cli.c Thu Oct 6 16:29:13 2005 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: php_cli.c,v 1.130 2005/10/03 11:54:46 johannes Exp $ */ +/* $Id: php_cli.c,v 1.131 2005/10/06 20:29:13 johannes Exp $ */ #include php.h #include php_globals.h @@ -704,8 +704,9 @@ php_output_activate(TSRMLS_C); php_cli_usage(argv[0]); php_end_ob_buffers(1 TSRMLS_CC); - exit_status=1; - goto err; + exit_status=0; + zend_ini_deactivate(TSRMLS_C); + goto out_err; case 'i': /* php info quit */ @@ -714,7 +715,7 @@ } php_print_info(0x TSRMLS_CC); php_end_ob_buffers(1 TSRMLS_CC); - exit_status=1; + exit_status=0; goto out; case 'm': /* list compiled in modules */ @@ -726,8 +727,9 @@ print_extensions(TSRMLS_C); php_printf(\n); php_end_ob_buffers(1 TSRMLS_CC); - exit_status=1; - goto err; + exit_status=0; + zend_ini_deactivate(TSRMLS_C); + goto out_err; case 'v': /* show php version quit */ if (php_request_startup(TSRMLS_C)==FAILURE) { @@ -739,7 +741,7 @@ php_printf(PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2005 The PHP Group\n%s, PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #endif php_end_ob_buffers(1 TSRMLS_CC); - exit_status=1; + exit_status=0; goto out; default: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
sniper Fri Jun 3 19:11:51 2005 EDT Modified files: /php-src/sapi/cgi cgi_main.c Log: cs + ws http://cvs.php.net/diff.php/php-src/sapi/cgi/cgi_main.c?r1=1.264r2=1.265ty=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.264 php-src/sapi/cgi/cgi_main.c:1.265 --- php-src/sapi/cgi/cgi_main.c:1.264 Thu Apr 28 10:23:57 2005 +++ php-src/sapi/cgi/cgi_main.c Fri Jun 3 19:11:51 2005 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.264 2005/04/28 14:23:57 sniper Exp $ */ +/* $Id: cgi_main.c,v 1.265 2005/06/03 23:11:51 sniper Exp $ */ #include php.h #include php_globals.h @@ -76,7 +76,6 @@ #include zend_highlight.h #include zend_indent.h - #include php_getopt.h #if PHP_FASTCGI @@ -150,7 +149,7 @@ #if ENABLE_PATHINFO_CHECK /* true global. this is retreived once only, even for fastcgi */ -long fix_pathinfo=1; +long fix_pathinfo = 1; #endif #ifdef PHP_WIN32 @@ -178,7 +177,7 @@ Bucket *s = *((Bucket **) b); return strcasecmp(((zend_module_entry *)f-pData)-name, - ((zend_module_entry *)s-pData)-name); + ((zend_module_entry *)s-pData)-name); } static void print_modules(TSRMLS_D) @@ -230,8 +229,8 @@ #if PHP_FASTCGI if (!FCGX_IsCGI()) { - FCGX_Request *request = (FCGX_Request *)SG(server_context); - long ret = FCGX_PutStr( str, str_length, request-out ); + FCGX_Request *request = (FCGX_Request *) SG(server_context); + long ret = FCGX_PutStr(str, str_length, request-out); if (ret = 0) { return 0; } @@ -272,7 +271,7 @@ { #if PHP_FASTCGI if (!FCGX_IsCGI()) { - FCGX_Request *request = (FCGX_Request *)server_context; + FCGX_Request *request = (FCGX_Request *) server_context; if ( #ifndef PHP_WIN32 !parent @@ -283,7 +282,7 @@ return; } #endif - if (fflush(stdout)==EOF) { + if (fflush(stdout) == EOF) { php_handle_aborted_connection(); } } @@ -297,7 +296,7 @@ zend_llist_position pos; long rfc2616_headers = 0, nph = 0; - if(SG(request_info).no_headers == 1) { + if (SG(request_info).no_headers == 1) { return SAPI_HEADER_SENT_SUCCESSFULLY; } /* Check wheater to send RFC2616 style headers compatible with @@ -313,7 +312,8 @@ nph = 0; } - if (nph || SG(sapi_headers).http_response_code != 200) { + if (nph || SG(sapi_headers).http_response_code != 200) + { int len; if (rfc2616_headers SG(sapi_headers).http_status_line) { @@ -331,18 +331,19 @@ PHPWRITE_H(buf, len); } - if (SG(sapi_headers).send_default_content_type) { + if (SG(sapi_headers).send_default_content_type) + { char *hd; hd = sapi_get_default_content_type(TSRMLS_C); - PHPWRITE_H(Content-type: , sizeof(Content-type: )-1); + PHPWRITE_H(Content-type: , sizeof(Content-type: ) - 1); PHPWRITE_H(hd, strlen(hd)); PHPWRITE_H(\r\n, 2); efree(hd); } h = zend_llist_get_first_ex(sapi_headers-headers, pos); -while (h) { + while (h) { PHPWRITE_H(h-header, h-header_len); PHPWRITE_H(\r\n, 2); h = zend_llist_get_next_ex(sapi_headers-headers, pos); @@ -360,21 +361,21 @@ char *pos = buffer; #endif - count_bytes = MIN(count_bytes, (uint)SG(request_info).content_length-SG(read_post_bytes)); + count_bytes = MIN(count_bytes, (uint) SG(request_info).content_length - SG(read_post_bytes)); while (read_bytes count_bytes) { #if PHP_FASTCGI if (!FCGX_IsCGI()) { - FCGX_Request *request = (FCGX_Request *)SG(server_context); - tmp_read_bytes = FCGX_GetStr( pos, count_bytes-read_bytes, request-in ); + FCGX_Request *request = (FCGX_Request *) SG(server_context); + tmp_read_bytes = FCGX_GetStr(pos, count_bytes - read_bytes, request-in); pos += tmp_read_bytes; } else { - tmp_read_bytes = read(0, buffer+read_bytes, count_bytes-read_bytes); + tmp_read_bytes = read(0, buffer + read_bytes, count_bytes - read_bytes); } #else - tmp_read_bytes = read(0, buffer+read_bytes, count_bytes-read_bytes); + tmp_read_bytes = read(0, buffer + read_bytes, count_bytes - read_bytes); #endif - if (tmp_read_bytes=0) { + if (tmp_read_bytes = 0) {
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
sniper Thu Apr 28 10:23:58 2005 EDT Modified files: /php-src/sapi/cgi cgi_main.c Log: int != long http://cvs.php.net/diff.php/php-src/sapi/cgi/cgi_main.c?r1=1.263r2=1.264ty=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.263 php-src/sapi/cgi/cgi_main.c:1.264 --- php-src/sapi/cgi/cgi_main.c:1.263 Thu Apr 28 09:14:26 2005 +++ php-src/sapi/cgi/cgi_main.c Thu Apr 28 10:23:57 2005 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.263 2005/04/28 13:14:26 sniper Exp $ */ +/* $Id: cgi_main.c,v 1.264 2005/04/28 14:23:57 sniper Exp $ */ #include php.h #include php_globals.h @@ -482,7 +482,7 @@ static void sapi_cgi_log_message(char *message) { #if PHP_FASTCGI - int logging = 1; + long logging = 1; TSRMLS_FETCH(); if (cfg_get_long(fastcgi.logging, logging) == FAILURE) { @@ -979,7 +979,7 @@ int fcgi_fd = 0; FCGX_Request request; #ifdef PHP_WIN32 - int impersonate = 0; + long impersonate = 0; #else int status = 0; #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
sniper Thu Feb 10 21:03:56 2005 EDT Modified files: /php-src/sapi/cgi cgi_main.c Log: Revert previous patch http://cvs.php.net/diff.php/php-src/sapi/cgi/cgi_main.c?r1=1.260r2=1.261ty=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.260 php-src/sapi/cgi/cgi_main.c:1.261 --- php-src/sapi/cgi/cgi_main.c:1.260 Fri Feb 4 05:39:33 2005 +++ php-src/sapi/cgi/cgi_main.c Thu Feb 10 21:03:51 2005 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.260 2005/02/04 10:39:33 sniper Exp $ */ +/* $Id: cgi_main.c,v 1.261 2005/02/11 02:03:51 sniper Exp $ */ #include php.h #include php_globals.h @@ -662,19 +662,8 @@ { char *env_script_filename = sapi_cgibin_getenv(SCRIPT_FILENAME,0 TSRMLS_CC); char *env_path_translated = sapi_cgibin_getenv(PATH_TRANSLATED,0 TSRMLS_CC); - char *env_script_name = sapi_cgibin_getenv(SCRIPT_NAME, 0 TSRMLS_CC); char *script_path_translated = env_script_filename; - /* -* CGI/1.1, as documented at: http://cgi-spec.golux.com/ -* mentions SCRIPT_NAME but not SCRIPT_FILENAME. -*/ - if (!script_path_translated env_script_name *env_script_name == '/') { - env_script_filename = _sapi_cgibin_putenv(SCRIPT_FILENAME,(env_script_name + 1) TSRMLS_CC); - - script_path_translated = env_script_filename; - } - #if !DISCARD_PATH /* some broken servers do not have script_filename or argv0 an example, IIS configured in some ways. then they do more @@ -702,6 +691,7 @@ char *content_length = sapi_cgibin_getenv(CONTENT_LENGTH,0 TSRMLS_CC); char *content_type = sapi_cgibin_getenv(CONTENT_TYPE,0 TSRMLS_CC); char *env_path_info = sapi_cgibin_getenv(PATH_INFO,0 TSRMLS_CC); + char *env_script_name = sapi_cgibin_getenv(SCRIPT_NAME,0 TSRMLS_CC); #if ENABLE_PATHINFO_CHECK struct stat st; char *env_redirect_url = sapi_cgibin_getenv(REDIRECT_URL,0 TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
sniper Fri Feb 4 05:39:34 2005 EDT Modified files: /php-src/sapi/cgi cgi_main.c Log: - Fixed bug #28227 (PHP CGI depends upon non-standard SCRIPT_FILENAME) # patch by: lukem at NetBSD dot org http://cvs.php.net/diff.php/php-src/sapi/cgi/cgi_main.c?r1=1.259r2=1.260ty=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.259 php-src/sapi/cgi/cgi_main.c:1.260 --- php-src/sapi/cgi/cgi_main.c:1.259 Tue Jan 11 08:35:56 2005 +++ php-src/sapi/cgi/cgi_main.c Fri Feb 4 05:39:33 2005 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.259 2005/01/11 13:35:56 sniper Exp $ */ +/* $Id: cgi_main.c,v 1.260 2005/02/04 10:39:33 sniper Exp $ */ #include php.h #include php_globals.h @@ -662,8 +662,19 @@ { char *env_script_filename = sapi_cgibin_getenv(SCRIPT_FILENAME,0 TSRMLS_CC); char *env_path_translated = sapi_cgibin_getenv(PATH_TRANSLATED,0 TSRMLS_CC); + char *env_script_name = sapi_cgibin_getenv(SCRIPT_NAME, 0 TSRMLS_CC); char *script_path_translated = env_script_filename; + /* +* CGI/1.1, as documented at: http://cgi-spec.golux.com/ +* mentions SCRIPT_NAME but not SCRIPT_FILENAME. +*/ + if (!script_path_translated env_script_name *env_script_name == '/') { + env_script_filename = _sapi_cgibin_putenv(SCRIPT_FILENAME,(env_script_name + 1) TSRMLS_CC); + + script_path_translated = env_script_filename; + } + #if !DISCARD_PATH /* some broken servers do not have script_filename or argv0 an example, IIS configured in some ways. then they do more @@ -691,7 +702,6 @@ char *content_length = sapi_cgibin_getenv(CONTENT_LENGTH,0 TSRMLS_CC); char *content_type = sapi_cgibin_getenv(CONTENT_TYPE,0 TSRMLS_CC); char *env_path_info = sapi_cgibin_getenv(PATH_INFO,0 TSRMLS_CC); - char *env_script_name = sapi_cgibin_getenv(SCRIPT_NAME,0 TSRMLS_CC); #if ENABLE_PATHINFO_CHECK struct stat st; char *env_redirect_url = sapi_cgibin_getenv(REDIRECT_URL,0 TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
sniper Mon Jan 10 10:38:24 2005 EDT Modified files: /php-src/sapi/cgi cgi_main.c Log: - Fixed bug #28074 (FastCGI: stderr should be written in a FCGI stderr stream). http://cvs.php.net/diff.php/php-src/sapi/cgi/cgi_main.c?r1=1.257r2=1.258ty=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.257 php-src/sapi/cgi/cgi_main.c:1.258 --- php-src/sapi/cgi/cgi_main.c:1.257 Mon Dec 20 14:33:37 2004 +++ php-src/sapi/cgi/cgi_main.c Mon Jan 10 10:38:24 2005 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.257 2004/12/20 19:33:37 rasmus Exp $ */ +/* $Id: cgi_main.c,v 1.258 2005/01/10 15:38:24 sniper Exp $ */ #include php.h #include php_globals.h @@ -481,6 +481,13 @@ static void sapi_cgi_log_message(char *message) { +#if PHP_FASTCGI + if (!FCGX_IsCGI()) { + FCGX_Request *request = (FCGX_Request *)SG(server_context); + FCGX_FPrintF( request-err, %s\n, message ); + /* ignore return code */ + } else +#endif /* PHP_FASTCGI */ fprintf(stderr, %s\n, message); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c /sapi/cli php_cli.c
edink Wed Jul 14 18:30:29 2004 EDT Modified files: /php-src/sapi/cgi cgi_main.c /php-src/sapi/cli php_cli.c Log: Made php -m output sorted case-insensitevly http://cvs.php.net/diff.php/php-src/sapi/cgi/cgi_main.c?r1=1.255r2=1.256ty=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.255 php-src/sapi/cgi/cgi_main.c:1.256 --- php-src/sapi/cgi/cgi_main.c:1.255 Mon Jul 5 07:41:31 2004 +++ php-src/sapi/cgi/cgi_main.c Wed Jul 14 18:30:27 2004 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.255 2004/07/05 11:41:31 sas Exp $ */ +/* $Id: cgi_main.c,v 1.256 2004/07/14 22:30:27 edink Exp $ */ #include php.h #include php_globals.h @@ -177,7 +177,7 @@ Bucket *f = *((Bucket **) a); Bucket *s = *((Bucket **) b); - return strcmp(((zend_module_entry *)f-pData)-name, + return strcasecmp(((zend_module_entry *)f-pData)-name, ((zend_module_entry *)s-pData)-name); } http://cvs.php.net/diff.php/php-src/sapi/cli/php_cli.c?r1=1.112r2=1.113ty=u Index: php-src/sapi/cli/php_cli.c diff -u php-src/sapi/cli/php_cli.c:1.112 php-src/sapi/cli/php_cli.c:1.113 --- php-src/sapi/cli/php_cli.c:1.112Thu Mar 4 17:53:09 2004 +++ php-src/sapi/cli/php_cli.c Wed Jul 14 18:30:29 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: php_cli.c,v 1.112 2004/03/04 22:53:09 moriyoshi Exp $ */ +/* $Id: php_cli.c,v 1.113 2004/07/14 22:30:29 edink Exp $ */ #include php.h #include php_globals.h @@ -132,7 +132,7 @@ Bucket *f = *((Bucket **) a); Bucket *s = *((Bucket **) b); - return strcmp(((zend_module_entry *)f-pData)-name, + return strcasecmp(((zend_module_entry *)f-pData)-name, ((zend_module_entry *)s-pData)-name); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
sas Mon Jul 5 07:41:31 2004 EDT Modified files: /php-src/sapi/cgi cgi_main.c Log: - revert to proper behaviour http://cvs.php.net/diff.php/php-src/sapi/cgi/cgi_main.c?r1=1.254r2=1.255ty=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.254 php-src/sapi/cgi/cgi_main.c:1.255 --- php-src/sapi/cgi/cgi_main.c:1.254 Thu May 6 11:41:59 2004 +++ php-src/sapi/cgi/cgi_main.c Mon Jul 5 07:41:31 2004 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.254 2004/05/06 15:41:59 stas Exp $ */ +/* $Id: cgi_main.c,v 1.255 2004/07/05 11:41:31 sas Exp $ */ #include php.h #include php_globals.h @@ -98,7 +98,7 @@ /** * Number of child processes that will get created to service requests */ -static int children = 8; +static int children = 0; /** * Set to non-zero if we are the parent process -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
On Thu, 6 May 2004, Stanislav Malyshev wrote: stas Thu May 6 11:23:53 2004 EDT Modified files: /php-src/sapi/cgi cgi_main.c Log: Fix fastCGI breakage: due to calling flush on unitialized requests, request was aborted unless ignore_user_abort is set Please put back the unix line endings (you know, a simple cvs diff shows this just fine ;-) Derick -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
My bad. Should be fixed. My cvs diff doesn't show whitespace diffs, so didn't notice that :) DROn Thu, 6 May 2004, Stanislav Malyshev wrote: DR DR stas Thu May 6 11:23:53 2004 EDT DR DR Modified files: DR /php-src/sapi/cgi cgi_main.c DR Log: DR Fix fastCGI breakage: due to calling flush on unitialized requests, DR request was aborted unless ignore_user_abort is set DR DRPlease put back the unix line endings (you know, a simple cvs diff DRshows this just fine ;-) DR DRDerick DR DR -- Stanislav Malyshev, Zend Products Engineer [EMAIL PROTECTED] http://www.zend.com/ +972-3-6139665 ext.115 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
rasmus Fri Feb 27 18:31:29 2004 EDT Modified files: /php-src/sapi/cgi cgi_main.c Log: As discussed a while ago. There is no reason to disallow command-line arguments for the cgi version when run in a cgi context. Our own test framework is in fact broken because of this unnecessary restriction. http://cvs.php.net/diff.php/php-src/sapi/cgi/cgi_main.c?r1=1.249r2=1.250ty=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.249 php-src/sapi/cgi/cgi_main.c:1.250 --- php-src/sapi/cgi/cgi_main.c:1.249 Wed Feb 11 16:00:44 2004 +++ php-src/sapi/cgi/cgi_main.c Fri Feb 27 18:31:28 2004 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.249 2004/02/11 21:00:44 helly Exp $ */ +/* $Id: cgi_main.c,v 1.250 2004/02/27 23:31:28 rasmus Exp $ */ #include php.h #include php_globals.h @@ -1013,37 +1013,31 @@ } #endif - if (!cgi -#if PHP_FASTCGI - /* allow ini override for fastcgi */ -#endif - ) { - while ((c=php_getopt(argc, argv, OPTIONS, php_optarg, php_optind, 0))!=-1) { - switch (c) { - case 'c': - cgi_sapi_module.php_ini_path_override = strdup(php_optarg); - break; - case 'n': - cgi_sapi_module.php_ini_ignore = 1; - break; + while ((c=php_getopt(argc, argv, OPTIONS, php_optarg, php_optind, 0))!=-1) { + switch (c) { + case 'c': + cgi_sapi_module.php_ini_path_override = strdup(php_optarg); + break; + case 'n': + cgi_sapi_module.php_ini_ignore = 1; + break; #if PHP_FASTCGI #ifndef PHP_WIN32 - /* if we're started on command line, check to see if - we are being started as an 'external' fastcgi - server by accepting a bindpath parameter. */ - case 'b': - if (!fastcgi) { - bindpath = strdup(php_optarg); - } - break; + /* if we're started on command line, check to see if + we are being started as an 'external' fastcgi + server by accepting a bindpath parameter. */ + case 'b': + if (!fastcgi) { + bindpath = strdup(php_optarg); + } + break; #endif #endif - } - } - php_optind = orig_optind; - php_optarg = orig_optarg; + } + php_optind = orig_optind; + php_optarg = orig_optarg; #ifdef ZTS compiler_globals = ts_resource(compiler_globals_id); @@ -1249,28 +1243,22 @@ #endif /* FASTCGI */ zend_first_try { - if (!cgi -#if PHP_FASTCGI -!fastcgi -#endif - ) { - while ((c=php_getopt(argc, argv, OPTIONS, php_optarg, php_optind, 1))!=-1) { - switch (c) { - case 'h': - case '?': - no_headers = 1; - php_output_startup(); - php_output_activate(TSRMLS_C); - SG(headers_sent) = 1; - php_cgi_usage(argv[0]); - php_end_ob_buffers(1 TSRMLS_CC); - exit(1); - break; - } + while ((c=php_getopt(argc, argv, OPTIONS, php_optarg, php_optind, 1))!=-1) { + switch (c) { + case 'h': + case '?': + no_headers = 1; + php_output_startup(); + php_output_activate(TSRMLS_C); + SG(headers_sent) = 1; + php_cgi_usage(argv[0]); + php_end_ob_buffers(1 TSRMLS_CC); + exit(1); +
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
iliaa Wed Feb 11 09:52:13 2004 EDT Modified files: /php-src/sapi/cgi cgi_main.c Log: Proper win32 fix. http://cvs.php.net/diff.php/php-src/sapi/cgi/cgi_main.c?r1=1.247r2=1.248ty=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.247 php-src/sapi/cgi/cgi_main.c:1.248 --- php-src/sapi/cgi/cgi_main.c:1.247 Tue Feb 10 12:44:30 2004 +++ php-src/sapi/cgi/cgi_main.c Wed Feb 11 09:52:12 2004 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.247 2004/02/10 17:44:30 iliaa Exp $ */ +/* $Id: cgi_main.c,v 1.248 2004/02/11 14:52:12 iliaa Exp $ */ #include php.h #include php_globals.h @@ -274,7 +274,7 @@ if (!FCGX_IsCGI()) { FCGX_Request *request = (FCGX_Request *)server_context; if ( -#ifdef PHP_WIN32 +#ifndef PHP_WIN32 !parent #endif (!request || FCGX_FFlush(request-out) == -1)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c /sapi/cli php_cli.c
helly Wed Feb 11 16:00:47 2004 EDT Modified files: /php-src/sapi/cgi cgi_main.c /php-src/sapi/cli php_cli.c Log: Bugfix #27104 CLI/CGI SAPI module variable name conflict http://cvs.php.net/diff.php/php-src/sapi/cgi/cgi_main.c?r1=1.248r2=1.249ty=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.248 php-src/sapi/cgi/cgi_main.c:1.249 --- php-src/sapi/cgi/cgi_main.c:1.248 Wed Feb 11 09:52:12 2004 +++ php-src/sapi/cgi/cgi_main.c Wed Feb 11 16:00:44 2004 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.248 2004/02/11 14:52:12 iliaa Exp $ */ +/* $Id: cgi_main.c,v 1.249 2004/02/11 21:00:44 helly Exp $ */ #include php.h #include php_globals.h @@ -119,8 +119,8 @@ #define PHP_MODE_LINT 4 #define PHP_MODE_STRIP 5 -static char *optarg = NULL; -static int optind = 1; +static char *php_optarg = NULL; +static int php_optind = 1; static const opt_struct OPTIONS[] = { {'a', 0, interactive}, @@ -928,8 +928,8 @@ /* temporary locals */ int behavior=PHP_MODE_STANDARD; int no_headers=0; - int orig_optind=optind; - char *orig_optarg=optarg; + int orig_optind=php_optind; + char *orig_optarg=php_optarg; char *script_file=NULL; zend_llist global_vars; #if FORCE_CGI_REDIRECT @@ -1018,10 +1018,10 @@ /* allow ini override for fastcgi */ #endif ) { - while ((c=php_getopt(argc, argv, OPTIONS, optarg, optind, 0))!=-1) { + while ((c=php_getopt(argc, argv, OPTIONS, php_optarg, php_optind, 0))!=-1) { switch (c) { case 'c': - cgi_sapi_module.php_ini_path_override = strdup(optarg); + cgi_sapi_module.php_ini_path_override = strdup(php_optarg); break; case 'n': cgi_sapi_module.php_ini_ignore = 1; @@ -1033,7 +1033,7 @@ server by accepting a bindpath parameter. */ case 'b': if (!fastcgi) { - bindpath = strdup(optarg); + bindpath = strdup(php_optarg); } break; #endif @@ -1041,8 +1041,8 @@ } } - optind = orig_optind; - optarg = orig_optarg; + php_optind = orig_optind; + php_optarg = orig_optarg; } #ifdef ZTS @@ -1254,7 +1254,7 @@ !fastcgi #endif ) { - while ((c=php_getopt(argc, argv, OPTIONS, optarg, optind, 1))!=-1) { + while ((c=php_getopt(argc, argv, OPTIONS, php_optarg, php_optind, 1))!=-1) { switch (c) { case 'h': case '?': @@ -1268,8 +1268,8 @@ break; } } - optind = orig_optind; - optarg = orig_optarg; + php_optind = orig_optind; + php_optarg = orig_optarg; } #if PHP_FASTCGI @@ -1319,7 +1319,7 @@ exit(1); } - while ((c = php_getopt(argc, argv, OPTIONS, optarg, optind, 0)) != -1) { + while ((c = php_getopt(argc, argv, OPTIONS, php_optarg, php_optind, 0)) != -1) { switch (c) { case 'a': /* interactive mode */ @@ -1331,7 +1331,7 @@ SG(options) |= SAPI_OPTION_NO_CHDIR; break; case 'd': /* define ini entries on command line */ - define_command_line_ini_entry(optarg); + define_command_line_ini_entry(php_optarg); break; case 'e': /* enable extended info output */ @@ -1339,16 +1339,16 @@ break; case 'f': /* parse file */ - script_file = estrdup(optarg); + script_file = estrdup(php_optarg); no_headers = 1;
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c /sapi/cgi/libfcgi/include fcgi_config.h
iliaa Tue Feb 10 12:44:31 2004 EDT Modified files: /php-src/sapi/cgi cgi_main.c /php-src/sapi/cgi/libfcgi/include fcgi_config.h Log: Fixed win32 build. Fixed building of libfcgi when PHP is built from another directory. Added missing headers needed for wait(). Removed duplicate signal.h header. Removed unneeded variables. http://cvs.php.net/diff.php/php-src/sapi/cgi/cgi_main.c?r1=1.246r2=1.247ty=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.246 php-src/sapi/cgi/cgi_main.c:1.247 --- php-src/sapi/cgi/cgi_main.c:1.246 Mon Feb 9 19:29:46 2004 +++ php-src/sapi/cgi/cgi_main.c Tue Feb 10 12:44:30 2004 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.246 2004/02/10 00:29:46 iliaa Exp $ */ +/* $Id: cgi_main.c,v 1.247 2004/02/10 17:44:30 iliaa Exp $ */ #include php.h #include php_globals.h @@ -48,6 +48,12 @@ #if HAVE_SETLOCALE #include locale.h #endif +#if HAVE_SYS_TYPES_H +#include sys/types.h +#endif +#if HAVE_SYS_WAIT_H +#include sys/wait.h +#endif #include zend.h #include zend_extensions.h #include php_ini.h @@ -61,10 +67,6 @@ #include win32/php_registry.h #endif -#if HAVE_SIGNAL_H -#include signal.h -#endif - #ifdef __riscos__ #include unixlib/local.h #endif @@ -271,7 +273,11 @@ #if PHP_FASTCGI if (!FCGX_IsCGI()) { FCGX_Request *request = (FCGX_Request *)server_context; - if (!parent (!request || FCGX_FFlush(request-out) == -1)) { + if ( +#ifdef PHP_WIN32 + !parent +#endif + (!request || FCGX_FFlush(request-out) == -1)) { php_handle_aborted_connection(); } return; @@ -1177,7 +1183,6 @@ if( children ) { int running = 0; - int i; pid_t pid; /* Create a process group for ourself children */ http://cvs.php.net/diff.php/php-src/sapi/cgi/libfcgi/include/fcgi_config.h?r1=1.2r2=1.3ty=u Index: php-src/sapi/cgi/libfcgi/include/fcgi_config.h diff -u php-src/sapi/cgi/libfcgi/include/fcgi_config.h:1.2 php-src/sapi/cgi/libfcgi/include/fcgi_config.h:1.3 --- php-src/sapi/cgi/libfcgi/include/fcgi_config.h:1.2 Tue Nov 26 00:51:16 2002 +++ php-src/sapi/cgi/libfcgi/include/fcgi_config.h Tue Feb 10 12:44:31 2004 @@ -2,6 +2,6 @@ #ifdef _WIN32 #include fcgi_config_win32.h #else -#include main/php_config.h +#include php_config.h #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
iliaa Mon Feb 9 19:29:47 2004 EDT Modified files: /php-src/sapi/cgi cgi_main.c Log: Fixed bug #26758 (FastCGI exits immediately with status 255). http://cvs.php.net/diff.php/php-src/sapi/cgi/cgi_main.c?r1=1.245r2=1.246ty=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.245 php-src/sapi/cgi/cgi_main.c:1.246 --- php-src/sapi/cgi/cgi_main.c:1.245 Mon Feb 9 19:02:38 2004 +++ php-src/sapi/cgi/cgi_main.c Mon Feb 9 19:29:46 2004 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.245 2004/02/10 00:02:38 iliaa Exp $ */ +/* $Id: cgi_main.c,v 1.246 2004/02/10 00:29:46 iliaa Exp $ */ #include php.h #include php_globals.h @@ -271,7 +271,7 @@ #if PHP_FASTCGI if (!FCGX_IsCGI()) { FCGX_Request *request = (FCGX_Request *)server_context; - if(!request || FCGX_FFlush( request-out ) == -1 ) { + if (!parent (!request || FCGX_FFlush(request-out) == -1)) { php_handle_aborted_connection(); } return; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
sniper Thu Oct 30 20:30:00 2003 EDT Modified files: /php-src/sapi/cgi cgi_main.c Log: MFB Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.242 php-src/sapi/cgi/cgi_main.c:1.243 --- php-src/sapi/cgi/cgi_main.c:1.242 Thu Oct 16 22:21:26 2003 +++ php-src/sapi/cgi/cgi_main.c Thu Oct 30 20:29:59 2003 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.242 2003/10/17 02:21:26 iliaa Exp $ */ +/* $Id: cgi_main.c,v 1.243 2003/10/31 01:29:59 sniper Exp $ */ #include php.h #include php_globals.h @@ -544,7 +544,7 @@ php_printf(Usage: %s [-q] [-h] [-s] [-v] [-i] [-f file]\n %s file [args...]\n -a Run interactively\n -#if PHP_FASTCGI +#if PHP_FASTCGI !defined(PHP_WIN32) -b address:port|port Bind Path for external FASTCGI Server mode\n #endif -C Do not chdir to the script's directory\n -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /sapi/cgi cgi_main.c
sas Wed Sep 3 04:15:10 2003 EDT Modified files: /php-src/sapi/cgi cgi_main.c Log: fix heuristic: if someone passed -b IP:port, this check would falsely recognize the parameter as defining only a port. Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.240 php-src/sapi/cgi/cgi_main.c:1.241 --- php-src/sapi/cgi/cgi_main.c:1.240 Sun Aug 17 14:36:27 2003 +++ php-src/sapi/cgi/cgi_main.c Wed Sep 3 04:15:09 2003 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: cgi_main.c,v 1.240 2003/08/17 18:36:27 helly Exp $ */ +/* $Id: cgi_main.c,v 1.241 2003/09/03 08:15:09 sas Exp $ */ #include php.h #include php_globals.h @@ -,7 +,6 @@ /* for windows, socket listening is broken in the fastcgi library itself so dissabling this feature on windows till time is available to fix it */ if (bindpath) { - int port = 0; /* this must be done to make FCGX_OpenSocket work correctly bug 23664 */ close(0); @@ -1119,11 +1118,16 @@ * If just a port is specified, then we prepend a ':' onto the * path (it's what the fastcgi library expects) */ - port = atoi(bindpath); - if (port) { - char bindport[32]; - snprintf(bindport, 32, :%s, bindpath); - fcgi_fd = FCGX_OpenSocket(bindport, 128); + + if (strchr(bindpath, ':') == NULL) { + char *tmp; + + tmp = malloc(strlen(bindpath) + 2); + tmp[0] = ':'; + memcpy(tmp + 1, bindpath, strlen(bindpath) + 1); + + fcgi_fd = FCGX_OpenSocket(tmp, 128); + free(tmp); } else { fcgi_fd = FCGX_OpenSocket(bindpath, 128); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php