Reply to PHP, thttpd, & SCRIPT_FILENAME

Your name:

Reply:


Posted by Robert on 04/28/06 16:29

I'm getting the dreaded "No input file specified" when I try to invoke PHP
from thttpd (nochroot).

I wrote a C program to dump environment variables before trying to invoke
PHP. I've included the dumped environment variables below.

As you notice in the C program, I've tried both "argv[0]" (i.e., I'm using
a hard link to the program from "script.php" to "phpexec") and the
SCRIPT_FILENAME variable. The version below is with SCRIPT_FILENAME. The
file name in question does exist and if I execute

$ /cgi-bin/php3 /mydomain.com/robert/archives/personal/script.php3

it works. (Note that /mydomain.com is a symbolic link to
/var/www/mydomain.com . I imagine that this doesn't matter since I'm
running thttpd with nochroot.)

I believe that execl() is supposed to pass the environment to the chained
program (php3 in this case).

Does anyone have any ideas how to fix this problem? I'm using PHP version
3.0.18 on a Sarge Debian GNU/Linux system.

Thanks.

----------------------------------phpexec.c------------------------------------
#include <stdio.h>

extern char **environ;

main(int argc, char** argv)
{
int i=0;
FILE* fp;
char name[BUFSIZ];
char *p;

fp = fopen("/tmp/phpenv","w");
while (environ[i]) {
fprintf(fp,"%s\n", environ[i++]);
}
// strcpy(name, argv[0]);
strcpy(name, getenv("SCRIPT_FILENAME"));
if ((p = strrchr(name, '.'))) {
strcpy(p, ".php3");
} else {
strcat(name, "3");
}
fprintf(fp, "%s\n", name);
fclose(fp);
execl("/cgi-bin/php3","php3",name,0);
}
-------------------------------------------------------------------------------

-----------------------------environment variables-----------------------------
PATH=/usr/local/bin:/usr/ucb:/bin:/usr/bin
SERVER_SOFTWARE=thttpd/2.25b 29dec2003
SERVER_NAME=mydomain.com
GATEWAY_INTERFACE=CGI/1.1
SERVER_PROTOCOL=HTTP/1.1
SERVER_PORT=80
REQUEST_METHOD=POST
SCRIPT_FILENAME=/mydomain.com/robert/archives/personal/script.php
SCRIPT_NAME=/robert/archives/personal/script.php
REMOTE_ADDR=195.225.176.158
HTTP_USER_AGENT=Mozilla 4.0 IE6.0+ SRV1.1
HTTP_ACCEPT=*/*
CONTENT_TYPE=application/x-www-form-urlencoded
HTTP_HOST=mydomain.com
CONTENT_LENGTH=90
CGI_PATTERN=**/cgi-bin/**|**.cgi|**.php
REDIRECT_STATUS=200
/mydomain.com/robert/archives/personal/script.php3
-------------------------------------------------------------------------------

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация