On Sat, Sep 19, 2009 at 3:48 AM, Marcus Merz <mm...@gmx.de> wrote:

> Hi,
>
> i ran into a problem with mod_fcgid and i wonder whether anybody can
> replicate my problem.
>
> There is also a bug report in here:
>
> http://sourceforge.net/tracker/?func=detail&aid=2854396&group_id=174879&atid=870991
>
>
Any PHP experts out there?

The basic problem from your description is that PHP thinks the .jpg file is
the PHP script and tries to parse that (instead of modify.php).  I easily
duplicated that.

I then looked up the setting of cgi.fix_pathinfo.  My php.ini has a comment
that says it defaults to 1.  mod_fcgid has a setting that is supposed to
mirror that (PHP_Fix_Pathinfo_Enable).  So I set "PHP_Fix_Pathinfo_Enable 1"
in my mod_fcgid configuration, but still no change in failure.

I then edited php.ini, set cgi.fix_pathinfo=0, set "PHP_Fix_Pathinfo_Enable
0" (the default) in my mod_fcgid conf, and retested.

Now PHP is trying to run modify.php instead of interpreting a .jpg file
(good!).  It fails to open the file properly ("*Warning*:
getimagesize(./wtmrk./IMG_4418.jpg)") but that may be something about how I
attempted to set up modify.php.

So set "cgi.fix_pathinfo=0" in the proper* php.ini and try again.  (*You may
have a separate one for mod_php vs. "CGI"; set the latter one.)

BTW, here were the request environment settings sent over by mod_fcgid:

SCRIPT_FILENAME=/home/trawick/inst/22/htdocs/modify.php
REDIRECT_URL=/wtmrk/IMG_4418.jpg
REQUEST_URI=/wtmrk/IMG_4418.jpg
SCRIPT_NAME=/modify.php
PATH_INFO=/wtmrk/IMG_4418.jpg
PATH_TRANSLATED=/home/trawick/wtmrk/IMG_4418.jpg

Another way to look at it is to consider if mod_fcgid is doing the right
thing when PHP_Fix_Pathinfo_Enable is 1 (matching PHP's default).  I don't
know about that ;)

That logic (in mod_fcgid.c) is as follows:

        /* "DOCUMENT_ROOT"/"SCRIPT_NAME" -> "SCRIPT_NAME" */
        const char *doc_root = apr_table_get(e, "DOCUMENT_ROOT");
        const char *script_name = apr_table_get(e, "SCRIPT_NAME");

        if (doc_root && script_name
            && apr_filepath_merge(&merge_path, doc_root, script_name, 0,
                                  r->pool) == APR_SUCCESS) {
            apr_table_setn(e, "SCRIPT_NAME", merge_path);
        }

In our example, the Action for wtmrk is defined as "/modify.php", so
SCRIPT_NAME is "/modify.php" when we get here.  apr_filepath_merge() just
returns the 3rd parameter when it starts with "/", so our supposedly-merged
script name is unchanged.  That's not what I would have expected.  (Also, I
wonder what happens when SCRIPT_NAME is outside of DOCUMENT_ROOT.)

Recap: Try cgi.fix_pathinfo=0; maybe somebody else will chime in on the
PHP_Fix_Pathinfo_Enable processing.

Reply via email to