From:             [EMAIL PROTECTED]
Operating system: Linux
PHP version:      4.3.0
PHP Bug Type:     Apache related
Bug description:  enviroment/cgi binary

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
[EMAIL PROTECTED]
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
[EMAIL PROTECTED]
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?)



-- 
Edit bug report at http://bugs.php.net/?id=21781&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=21781&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=21781&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=21781&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=21781&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=21781&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=21781&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=21781&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=21781&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=21781&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=21781&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21781&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=21781&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=21781&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=21781&r=gnused

Reply via email to