PHP 4.0 Bug #5181: 'No input file specified' error in CGI mode / location of bugs in code
| From: | pdoyle at cncx dot com | Date: | Wed, 21 Jun 2000 21:09:29 +0000 |
| Subject: | PHP 4.0 Bug #5181: 'No input file specified' error in CGI mode / location of bugs in code | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-22154@lists.php.net to get a copy of this message | ||
From: pdoyle@cncx.com
Operating system: Solaris 2.5.1
PHP version: 4.0 Release Candidate 2
PHP Bug Type: Installation problem
Bug description: 'No input file specified' error in CGI mode / location of bugs in code
As others have reported, setting --enable-discard-path does not allow PHP to run properly in CGI
mode. This simple script will fail when hit through a Web server:
#!/usr/local/bin/php
<?php echo "Hello, world."; ?>
producing a "No input file specified" error.
There seem to be three bugs in the file sapi/cgi/cgi_main.c that cause this. (At least, when I
fixed these things, it worked). I'll now reveal what is probably my ignorance of the code by
pointing them out.
The problems are all in the init_request_info() function. Specifically,
1. ~Line 252. script_filename is set to getenv("SCRIPT_FILENAME") rather than
getenv("SCRIPT_NAME"). Maybe SCRIPT_FILENAME is a newer variant I haven't heard of,
but our servers have always used SCRIPT_NAME.
2. ~Line 278. If DISCARD_PATH is set and script_filename is available,
SG(request_info).path_translated should be set to the concatenation of
getenv("DOCUMENT_ROOT") and script_filename, not just script_filename. Otherwise, when
php_fopen_primary_script() tries to open it it will bomb, because it doesn't have the full
path.
3. ~Line 290. For some reason, irrespective of the previous DISCARD_PATH section,
SG(request_info).path_translated is set to NULL. This will clobber the script name when discard
path is enabled. As far as I can tell this line should simply be removed.
Hope that's useful to someone. :)