php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5181 'No input file specified' error in CGI mode / location of bugs in code
Submitted: 2000-06-21 23:09 UTC Modified: 2001-01-12 11:18 UTC
From: pdoyle at cncx dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: 4.0 Release Candidate 2 OS: Solaris 2.5.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
14 + 17 = ?
Subscribe to this entry?

 
 [2000-06-21 23:09 UTC] pdoyle at cncx dot com
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. :) 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-06-28 05:06 UTC] stas at cvs dot php dot net
Please chekc the latest version - does it work now?
 [2000-08-01 22:59 UTC] waldschrott@php.net
no feedback, closed
 [2000-08-02 12:13 UTC] hholzgra@php.net
please wait, none of the suggested changes
seem to be applied ... lets just suspend it for now
 [2001-01-12 11:18 UTC] sniper@php.net
This should be fixed now. Please try PHP 4.0.4pl1.

--Jani
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 19:01:32 2024 UTC