summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Jagielski <jimjag@php.net>2011-03-09 18:27:30 +0000
committerJim Jagielski <jimjag@php.net>2011-03-09 18:27:30 +0000
commit39d814a205749acd929f3e0f5a8012012e3dd8f6 (patch)
treef4867cba5f8df59601e80298df46e8354fb44018
parent5009770d65754f64d3de7bff46539ef1523fe768 (diff)
downloadphp-git-39d814a205749acd929f3e0f5a8012012e3dd8f6.tar.gz
Close [PHP-BUG] Req #54152...
Apache 2.3.12 (and later) will now work correctly with PHP's fcgi impl with this patch.
-rw-r--r--sapi/fpm/fpm/fpm_main.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c
index 2f814089ba..13d21ecc3b 100644
--- a/sapi/fpm/fpm/fpm_main.c
+++ b/sapi/fpm/fpm/fpm_main.c
@@ -1085,6 +1085,7 @@ static void init_request_info(TSRMLS_D)
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
@@ -1130,6 +1131,30 @@ static void init_request_info(TSRMLS_D)
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;
@@ -1201,11 +1226,21 @@ static void init_request_info(TSRMLS_D)
* 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;