PHP, thttpd, & SCRIPT_FILENAME

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert

    PHP, thttpd, & SCRIPT_FILENAME

    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",na me,0);
    }
    -------------------------------------------------------------------------------

    -----------------------------environment variables-----------------------------
    PATH=/usr/local/bin:/usr/ucb:/bin:/usr/bin
    SERVER_SOFTWARE =thttpd/2.25b 29dec2003
    SERVER_NAME=myd omain.com
    GATEWAY_INTERFA CE=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=ap plication/x-www-form-urlencoded
    HTTP_HOST=mydom ain.com
    CONTENT_LENGTH= 90
    CGI_PATTERN=**/cgi-bin/**|**.cgi|**.ph p
    REDIRECT_STATUS =200
    /mydomain.com/robert/archives/personal/script.php3
    -------------------------------------------------------------------------------

  • 9xhgial02@sneakemail.com

    #2
    Re: PHP, thttpd, &amp; SCRIPT_FILENAME

    I haven't solved the problem yet, but I'm pretty sure that the problem is
    that thttpd doesn't always set PATH_INFO nor PATH_TRANSLATED . (php3 seems
    to require these for various reasons.) I guess I'd have to convince
    thttpd to always set these. This could be a long haul.

    Comment

    • Robert

      #3
      Re: PHP, thttpd, &amp; SCRIPT_FILENAME

      I found out that only PATH_TRANSLATED is needed -- PATH_INFO seems
      superfluous unless SCRIPT_FILENAME is set (which, in its default
      configuration, thttpd does not set).

      Comment

      Working...