php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21781 enviroment/cgi binary
Submitted: 2003-01-20 14:43 UTC Modified: 2003-01-20 17:31 UTC
From: phpbugs at sannes dot org Assigned:
Status: Not a bug Package: Apache related
PHP Version: 4.3.0 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: phpbugs at sannes dot org
New email:
PHP Version: OS:

 

 [2003-01-20 14:43 UTC] phpbugs at sannes dot org
My webserver has two ways of executing the php cgi binary, one way through suexec (cgi with #!) and another through suphp.

Running the php-code:
echo $_SERVER['SCRIPT_NAME'] . " -- " . $SCRIPT_NAME . " -- " . getenv('SCRIPT_NAME');

Works as expected under suexec, under suphp however SCRIPT_NAME isn't available (turns up blank). First I tought that this was an suphp issue, so I made a really simple C program that logs the arguments and the environment on execution and replaced the php-cgi binary with this (for debugging purposes).

I got two fairly similar logs, and I can't for the life of me figure out what is wrong.

Running with suexec: http://www.sannes.org/cgi/phpinfo.cgi
Running with suphp: http://www.sannes.org/test/phpinfo.suphp
(Where is SCRIPT_NAME?)

Before I paste the logs and the C program, let's sum this up. suexec cgi is working suphp cgi isn't working.

The suexec arg/env log:
argv[0] = /usr/bin/php-cgi
argv[1] = test.cgi
argv[2] = test.cgi
PATH=/bin:/usr/bin
DOCUMENT_ROOT=/home/ace/public_html
HTTP_ACCEPT=text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1
HTTP_ACCEPT_CHARSET=ISO-8859-1, utf-8;q=0.66, *;q=0.66
HTTP_ACCEPT_ENCODING=gzip, deflate, compress;q=0.9
HTTP_ACCEPT_LANGUAGE=en-us, en;q=0.66, no;q=0.33
HTTP_CONNECTION=keep-alive
HTTP_HOST=www.sannes.org
HTTP_KEEP_ALIVE=300
HTTP_USER_AGENT=Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030105
REMOTE_ADDR=80.202.167.189
REMOTE_PORT=59148
SCRIPT_FILENAME=/home/ace/public_html/cgi/test.cgi
SERVER_ADDR=10.0.18.1
SERVER_ADMIN=hostmaster@login.sannes.org
SERVER_NAME=www.sannes.org
SERVER_PORT=80
SERVER_SOFTWARE=Apache/1.3.27 (Unix)  (Gentoo/Linux) mod_ssl/2.8.12 OpenSSL/0.9.6g PHP/4.3.0
UNIQUE_ID=PiwgDAoAEgEAABhIFPs
GATEWAY_INTERFACE=CGI/1.1
SERVER_PROTOCOL=HTTP/1.1
REQUEST_METHOD=GET
QUERY_STRING=
REQUEST_URI=/cgi/test.cgi
SCRIPT_NAME=/cgi/test.cgi

The suphp args/env log:
argv[0] = php
argv[1] = -c
argv[2] =
DOCUMENT_ROOT=/home/ace/public_html
HTTP_ACCEPT=text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1
HTTP_ACCEPT_CHARSET=ISO-8859-1, utf-8;q=0.66, *;q=0.66
HTTP_ACCEPT_ENCODING=gzip, deflate, compress;q=0.9
HTTP_ACCEPT_LANGUAGE=en-us, en;q=0.66, no;q=0.33
HTTP_CONNECTION=keep-alive
HTTP_HOST=www.sannes.org
HTTP_KEEP_ALIVE=300
HTTP_USER_AGENT=Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030105
PATH=/bin:/usr/bin
REMOTE_ADDR=80.202.167.189
REMOTE_PORT=59143
SCRIPT_FILENAME=/home/ace/public_html/test/test.suphp
SERVER_ADDR=10.0.18.1
SERVER_ADMIN=hostmaster@login.sannes.org
SERVER_NAME=www.sannes.org
SERVER_PORT=80
SERVER_SIGNATURE=<ADDRESS>Apache/1.3.27 Server at www.sannes.org Port 80</ADDRESS>

SERVER_SOFTWARE=Apache/1.3.27 (Unix)  (Gentoo/Linux) mod_ssl/2.8.12 OpenSSL/0.9.6g PHP/4.3.0
UNIQUE_ID=Piwf6AoAEgEAABFnCaY
GATEWAY_INTERFACE=CGI/1.1
SERVER_PROTOCOL=HTTP/1.1
REQUEST_METHOD=GET
QUERY_STRING=
REQUEST_URI=/test/test.suphp
SCRIPT_NAME=/test/test.suphp
SCRIPT_URL=/test/test.suphp
PATH_TRANSLATED=/home/ace/public_html/test/test.suphp
PATH_INFO=/test/test.suphp
REDIRECT_SCRIPT_URL=/test/test.suphp
REDIRECT_STATUS=200
REDIRECT_URL=/test/test.suphp


The simple c program:
#include <unistd.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
    extern char **environ;
    int i;
    FILE *fh;

    fh = fopen("/tmp/any-php.log", "a");

    for (i = 0; i<argc; ++i)
            fprintf(fh, "argv[%d] = %s\n", i, argv[i]);

    for (i = 0; environ[i]; ++i)
            fprintf(fh, "%s\n", environ[i]);

    fclose(fh);
}

For more details just ask, currently running Linux 2.4.18, newest apache with mod_ssl. (This is enough details isn't it?)



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-20 15:39 UTC] sniper@php.net
Both of those envs show that SCRIPT_NAME is available.
And we don't support suPHP, you need to mail your bug reports to them.

 [2003-01-20 16:33 UTC] phpbugs at sannes dot org
That is my point, there isn't anything wrong with suPHP as far as I can tell, the enviroment is correct, it's just php cgi binary that don't work correctly (not doing what should be doing).

So if the enviroment is correct, why doesn't PHP show it correctly.
 [2003-01-20 16:38 UTC] sniper@php.net
If it works with suexec, then it can't be PHP that has the bug..

 [2003-01-20 17:31 UTC] phpbugs at sannes dot org
I've tried to find documentation on how to execute the cgi php binary and how the enviroment affects it, but have unable to do this. Various sources says that it works on other versions of php, just not 4.3.0. (I'm unable to test this right now, but will do so ASAP).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 17 12:01:31 2024 UTC