[PHP-CVS] svn: /php/php-src/trunk/sapi/fpm/fpm/ fpm_main.c

2011-03-09 Thread Jim Jagielski
jimjag   Wed, 09 Mar 2011 18:53:22 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=309054

Log:
Close [PHP-BUG] Req #54152...
Apache 2.3.12 (and later) will now work correctly with PHP's fcgi
impl with this patch.

Bug: http://bugs.php.net/54152 (Assigned) Make FPM compatible with Apache HTTP 
Server 2.3 mod_proxy_fcgi
  
Changed paths:
U   php/php-src/trunk/sapi/fpm/fpm/fpm_main.c

Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_main.c
===
--- php/php-src/trunk/sapi/fpm/fpm/fpm_main.c   2011-03-09 18:27:30 UTC (rev 
309053)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_main.c   2011-03-09 18:53:22 UTC (rev 
309054)
@@ -1083,6 +1083,7 @@
char *env_path_translated = sapi_cgibin_getenv(PATH_TRANSLATED, 
sizeof(PATH_TRANSLATED)-1 TSRMLS_CC);
char *script_path_translated = env_script_filename;
char *ini;
+   int apache_was_here = 0;

/* some broken servers do not have script_filename or argv0
 * an example, IIS configured in some ways.  then they do more
@@ -1128,6 +1129,30 @@
env_path_info = _sapi_cgibin_putenv(PATH_INFO, 
env_path_info TSRMLS_CC);
}

+#define APACHE_PROXY_FCGI_PREFIX proxy:fcgi://
+   /* Fix proxy URLs in SCRIPT_FILENAME generated by Apache 
mod_proxy_fcgi:
+* proxy:fcgi://localhost:9000/some-dir/info.php/test
+* should be changed to:
+* /some-dir/info.php/test
+* See: http://bugs.php.net/bug.php?id=54152
+*  https://issues.apache.org/bugzilla/show_bug.cgi?id=50851
+*/
+   if (env_script_filename 
+   strncasecmp(env_script_filename, 
APACHE_PROXY_FCGI_PREFIX, sizeof(APACHE_PROXY_FCGI_PREFIX) - 1) == 0) {
+   /* advance to first character of hostname */
+   char *p = env_script_filename + 
(sizeof(APACHE_PROXY_FCGI_PREFIX) - 1);
+   while (*p != '\0'  *p != '/') {
+   p++;/* move past hostname and port */
+   }
+   if (*p != '\0') {
+   /* Copy path portion in place to avoid memory 
leak.  Note
+* that this also affects what 
script_path_translated points
+* to. */
+   memmove(env_script_filename, p, strlen(p) + 1);
+   apache_was_here = 1;
+   }
+   }
+
if (CGIG(fix_pathinfo)) {
struct stat st;
char *real_path = NULL;
@@ -1199,11 +1224,21 @@
 * we have to play the game of 
hide and seek to figure
 * out what SCRIPT_NAME should 
be
 */
-   int slen = len - strlen(pt);
+   int ptlen = strlen(pt);
+   int slen = len - ptlen;
int pilen = env_path_info ? 
strlen(env_path_info) : 0;
-   char *path_info = env_path_info 
? env_path_info + pilen - slen : NULL;
+   int tflag = 0;
+   char *path_info;
+   if (apache_was_here) {
+   /* recall that 
PATH_INFO won't exist */
+   path_info = 
script_path_translated + ptlen;
+   tflag = (slen != 0  
(!orig_path_info || strcmp(orig_path_info, path_info) != 0));
+   } else {
+   path_info = 
env_path_info ? env_path_info + pilen - slen : NULL;
+   tflag = (orig_path_info 
!= path_info);
+   }

-   if (orig_path_info != 
path_info) {
+   if (tflag) {
if (orig_path_info) {
char old;


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/trunk/sapi/fpm/fpm/ fpm_main.c

2010-06-01 Thread Michael Wallner
mike Tue, 01 Jun 2010 13:51:05 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=300050

Log:
fix fpm build

Changed paths:
U   php/php-src/trunk/sapi/fpm/fpm/fpm_main.c

Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_main.c
===
--- php/php-src/trunk/sapi/fpm/fpm/fpm_main.c   2010-06-01 13:48:50 UTC (rev 
300049)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_main.c   2010-06-01 13:51:05 UTC (rev 
300050)
@@ -1493,7 +1493,7 @@

if (fcgi_is_fastcgi()  request-fd = 0) {

-   php_end_ob_buffers(1 TSRMLS_CC);
+   php_output_end_all(TSRMLS_C);
php_header(TSRMLS_C);

fcgi_flush(request, 1);
@@ -1629,7 +1629,6 @@

case 'm': /* list compiled in modules */
cgi_sapi_module.startup(cgi_sapi_module);
-   php_output_startup();
php_output_activate(TSRMLS_C);
SG(headers_sent) = 1;
php_printf([PHP Modules]\n);
@@ -1637,7 +1636,8 @@
php_printf(\n[Zend Modules]\n);
print_extensions(TSRMLS_C);
php_printf(\n);
-   php_end_ob_buffers(1 TSRMLS_CC);
+   php_output_end_all(TSRMLS_C);
+   php_output_deactivate(TSRMLS_C);
exit_status = 0;
goto out;

@@ -1660,11 +1660,11 @@
case 'h':
case '?':
cgi_sapi_module.startup(cgi_sapi_module);
-   php_output_startup();
php_output_activate(TSRMLS_C);
SG(headers_sent) = 1;
php_cgi_usage(argv[0]);
-   php_end_ob_buffers(1 TSRMLS_CC);
+   php_output_end_all(TSRMLS_C);
+   php_output_deactivate(TSRMLS_C);
exit_status = 0;
goto out;

@@ -1692,11 +1692,11 @@
/* No other args are permitted here as there is not interactive mode */
if (argc != php_optind) {
cgi_sapi_module.startup(cgi_sapi_module);
-   php_output_startup();
php_output_activate(TSRMLS_C);
SG(headers_sent) = 1;
php_cgi_usage(argv[0]);
-   php_end_ob_buffers(1 TSRMLS_CC);
+   php_output_end_all(TSRMLS_C);
+   php_output_deactivate(TSRMLS_C);
exit_status = 0;
goto out;
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/trunk/sapi/fpm/fpm/ fpm_main.c

2010-04-30 Thread Antony Dovgal
tony2001 Fri, 30 Apr 2010 08:20:57 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=298795

Log:
merge the fix for #51688

Bug: http://bugs.php.net/51688 (Closed) php_cgi_ini_activate_user_config() 
crashes when given apache-rewritten URL
  
Changed paths:
U   php/php-src/trunk/sapi/fpm/fpm/fpm_main.c

Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_main.c
===
--- php/php-src/trunk/sapi/fpm/fpm/fpm_main.c   2010-04-30 08:15:09 UTC (rev 
298794)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_main.c   2010-04-30 08:20:57 UTC (rev 
298795)
@@ -753,6 +753,9 @@

if (!IS_ABSOLUTE_PATH(path, path_len)) {
real_path = tsrm_realpath(path, NULL TSRMLS_CC);
+   if (real_path == NULL) {
+   return;
+   }
real_path_len = strlen(real_path);
path = real_path;
path_len = real_path_len;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/trunk/sapi/fpm/fpm/ fpm_main.c

2010-04-23 Thread Jérôme Loyet
fat  Fri, 23 Apr 2010 16:05:52 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=298383

Log:
Add PHP_VALUE and PHP_ADMIN_VALUE interpretation from fastcgi headers.
It works as php_value and php_admin_value from the main conf file or apache 
sapi.

See bug (request) #51595

Bug: http://bugs.php.net/51595 (Open) passing ini settings via FASTCGI 
parameters
  
Changed paths:
U   php/php-src/trunk/sapi/fpm/fpm/fpm_main.c

Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_main.c
===
--- php/php-src/trunk/sapi/fpm/fpm/fpm_main.c   2010-04-23 15:52:45 UTC (rev 
298382)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_main.c   2010-04-23 16:05:52 UTC (rev 
298383)
@@ -27,6 +27,10 @@
 #include php_globals.h
 #include php_variables.h
 #include zend_modules.h
+#include php.h
+#include zend_ini_scanner.h
+#include zend_globals.h
+#include zend_stream.h

 #include SAPI.h

@@ -103,6 +107,8 @@
 #include fpm/fpm.h
 #include fpm/fpm_request.h
 #include fpm/fpm_status.h
+#include fpm/fpm_conf.h
+#include fpm/fpm_php.h

 #ifndef PHP_WIN32
 /* XXX this will need to change later when threaded fastcgi is implemented.  
shane */
@@ -123,6 +129,7 @@
 static int request_body_fd;

 static char *sapi_cgibin_getenv(char *name, size_t name_len TSRMLS_DC);
+static void fastcgi_ini_parser(zval *arg1, zval *arg2, zval *arg3, int 
callback_type, void *arg TSRMLS_DC);

 #define PHP_MODE_STANDARD  1
 #define PHP_MODE_HIGHLIGHT 2
@@ -1070,6 +1077,7 @@
char *env_script_filename = sapi_cgibin_getenv(SCRIPT_FILENAME, 
sizeof(SCRIPT_FILENAME)-1 TSRMLS_CC);
char *env_path_translated = sapi_cgibin_getenv(PATH_TRANSLATED, 
sizeof(PATH_TRANSLATED)-1 TSRMLS_CC);
char *script_path_translated = env_script_filename;
+   char *ini;

/* some broken servers do not have script_filename or argv0
 * an example, IIS configured in some ways.  then they do more
@@ -1354,9 +1362,61 @@
auth = sapi_cgibin_getenv(HTTP_AUTHORIZATION, 
sizeof(HTTP_AUTHORIZATION)-1 TSRMLS_CC);
php_handle_auth_data(auth TSRMLS_CC);
}
+
+   /* INI stuff */
+   ini = sapi_cgibin_getenv(PHP_VALUE, sizeof(PHP_VALUE)-1 TSRMLS_CC);
+   if (ini) {
+   int mode = ZEND_INI_USER;
+   char *tmp;
+   spprintf(tmp, 0, %s\n, ini);
+   zend_parse_ini_string(tmp, 1, ZEND_INI_SCANNER_RAW, 
(zend_ini_parser_cb_t)fastcgi_ini_parser, mode TSRMLS_CC);
+   efree(tmp);
+   }
+
+   ini = sapi_cgibin_getenv(PHP_ADMIN_VALUE, sizeof(PHP_ADMIN_VALUE)-1 
TSRMLS_CC);
+   if (ini) {
+   int mode = ZEND_INI_SYSTEM;
+   char *tmp;
+   spprintf(tmp, 0, %s\n, ini);
+   zend_parse_ini_string(tmp, 1, ZEND_INI_SCANNER_RAW, 
(zend_ini_parser_cb_t)fastcgi_ini_parser, mode TSRMLS_CC);
+   efree(tmp);
+   }
 }
 /* }}} */

+static void fastcgi_ini_parser(zval *arg1, zval *arg2, zval *arg3, int 
callback_type, void *arg TSRMLS_DC) /* {{{ */
+{
+   int *mode = (int *)arg;
+   char *key = Z_STRVAL_P(arg1);
+   char *value = Z_STRVAL_P(arg2);
+   struct key_value_s kv;
+
+   if (!mode) return;
+
+   if (callback_type != ZEND_INI_PARSER_ENTRY) {
+   fprintf(stderr, Passing INI directive through FastCGI: only 
classic entries are allowed\n);
+   return;
+   }
+
+   if (!key || strlen(key)  1) {
+   fprintf(stderr, Passing INI directive through FastCGI: empty 
key\n);
+   return;
+   }
+
+   if (!value || strlen(value)  1) {
+   fprintf(stderr, Passing INI directive through FastCGI: empty 
value for key '%s'\n, key);
+   return;
+   }
+
+   kv.key = key;
+   kv.value = value;
+   kv.next = NULL;
+   if (fpm_php_apply_defines_ex(kv, *mode) == -1) {
+   fprintf(stderr, Passing INI directive through FastCGI: unable 
to set '%s'\n, key);
+   }
+}
+/* }}} */
+
 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)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/trunk/sapi/fpm/fpm/ fpm_main.c

2010-04-20 Thread Jérôme Loyet
fat  Tue, 20 Apr 2010 23:28:20 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=298238

Log:
Add a check request_method. If fcgi protocol is not followed, a segfault can 
occur.

Changed paths:
U   php/php-src/trunk/sapi/fpm/fpm/fpm_main.c

Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_main.c
===
--- php/php-src/trunk/sapi/fpm/fpm/fpm_main.c   2010-04-20 22:47:06 UTC (rev 
298237)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_main.c   2010-04-20 23:28:20 UTC (rev 
298238)
@@ -1773,6 +1773,12 @@
return FAILURE;
}

+   /* check request_method has been sent.
+* if not, the certainly not an HTTP over fcgi request 
*/
+   if (!SG(request_info).request_method) {
+   goto fastcgi_request_done;
+   }
+
if (!strcasecmp(SG(request_info).request_method, GET) 
 fpm_status_handle_status(SG(request_info).request_uri, 
SG(request_info).query_string, status_buffer, status_content_type)) {
if (status_buffer) {
if (status_content_type) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/trunk/sapi/fpm/fpm/ fpm_main.c

2010-04-20 Thread Jérôme Loyet
fat  Tue, 20 Apr 2010 23:31:13 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=298239

Log:
typo

Changed paths:
U   php/php-src/trunk/sapi/fpm/fpm/fpm_main.c

Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_main.c
===
--- php/php-src/trunk/sapi/fpm/fpm/fpm_main.c   2010-04-20 23:28:20 UTC (rev 
298238)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_main.c   2010-04-20 23:31:13 UTC (rev 
298239)
@@ -1773,8 +1773,8 @@
return FAILURE;
}

-   /* check request_method has been sent.
-* if not, the certainly not an HTTP over fcgi request 
*/
+   /* check if request_method has been sent.
+* if not, it's certainly not an HTTP over fcgi request 
*/
if (!SG(request_info).request_method) {
goto fastcgi_request_done;
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/trunk/sapi/fpm/fpm/ fpm_main.c

2010-04-13 Thread Antony Dovgal
tony2001 Tue, 13 Apr 2010 12:16:26 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=297960

Log:
use new type + const static

Changed paths:
U   php/php-src/trunk/sapi/fpm/fpm/fpm_main.c

Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_main.c
===
--- php/php-src/trunk/sapi/fpm/fpm/fpm_main.c   2010-04-13 12:13:46 UTC (rev 
297959)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_main.c   2010-04-13 12:16:26 UTC (rev 
297960)
@@ -1477,7 +1477,7 @@
 }
 /* }}} */

-function_entry cgi_fcgi_sapi_functions[] = {
+static const zend_function_entry cgi_fcgi_sapi_functions[] = {
PHP_FE(fastcgi_finish_request,  NULL)
{NULL, NULL, NULL}
 };

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php