svn: /php/php-src/trunk/sapi/fpm/fpm/ fpm_main.c
| From: | Jim Jagielski | Date: | Wed, 09 Mar 2011 18:53:22 +0000 |
| Subject: | svn: /php/php-src/trunk/sapi/fpm/fpm/ fpm_main.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-64656@lists.php.net to get a copy of this message | ||
jimjag Wed, 09 Mar 2011 18:53:22 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=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;