Re: [cgiwrap-users] CreateInterpreterARGV Broken?
Brought to you by:
nneul
From: <ms...@fr...> - 2004-10-06 17:26:23
|
On Oct 4, 2004, at 4:15 AM, Michael Middleton wrote: > On 1 Oct 2004 at 19:36, ms...@fr... wrote: > >> When running PHPs using CGIWrap, I keep seeing: >> >> Output of script follows: >> ===================================================== >> Could not open input file: /day.php. >> >> It seems CreateInterpreterARGV is yielding /day.php, instead of >> day.php: >> >> temp[1] = StripPathComponents( CountSubDirs(scrStr), scrStr ); >> >> For a couple days, I thought I was the problem, but on inspection, I >> think StripPathComponents will always yield a leading /. >> >> My principle reason for trying CGIWrap was to run PHPs with users' >> permissions, so this is a bummer. >> >> Say, does interpreter support work for anyone else? > > Hello Jack, > > I have been using CGIwrap with PHP for some time. > > Normally the users acces PHP from public_html in safe mode. I have also > allowed a CGI-mode that runs the script with the user's permissions. > > I had a lot of trouble with CGIwrap and PHP until Nathan included Piotr > Klaban's patch in the standard distribution (somewhere around version > 4.6.5). > > I compiled CGIwrap with > --with-php --with-php-interpreter --with-php-noexec-only > and PHP with > --disable-force-cgi-redirect --enable-discard-path > > You do not say how you called your PHP-script. I assume it was with a > shell start like > #!/usr/local/bin/php > > Have you tried calling the interprter directly, ie without this line? > > You did not say, what OS you are using. My servers run under Solaris 9, > which is proving to be more and more difficult. Perhaps the trouble ist > with your OS. Thanks very much for your help, Michael! I had been using Debian Linux, unstable. Taking your advice, I tried another machine - running SunOS 5.9 - & It worked! Unfortunately, it wasn't obvious why. I wrote this patch for CGIWrap to include information about the execution call & argument array CGIWrap makes: http://www.sfu.ca/~jdbates/cgiwrap/patch I also wrote a little test, which uses this patch & CreateInterpreterARGV to examine how the interpreter is called: http://www.sfu.ca/~jdbates/cgiwrap/test.c Turns out the problem was that the Debian CGIWrap package uses the PHP4 CLI instead of the PHP4 CGI (presumably to keep interpreters out of the webroot). I guess the CGI uses environment variables to locate scripts, so is unaffected by the argument array. However, if CreateInterpreterARGV (or StripPathComponents) could be fixed to produce a sensible argument array, CGIWrap could work with the CLI. The PHP4 CLI doesn't like this leading /: --- jablko@wum:~$ SCRIPT_PATH=foo/bar/day.php EXEC_PATH=/usr/bin/php ./test | head Executing: '/usr/bin/php' Arguments: '' '/day.php' Could not open input file: /day.php. --- But this works: --- jablko@wum:~$ SCRIPT_PATH=day.php EXEC_PATH=/usr/bin/php ./test | head Executing: '/usr/bin/php' Arguments: '' 'day.php' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html;charset=UTF-8"> --- I think CreateInterpreterARGV is meant produce an argument array containing the last element of the interpreter's path & the last element of the script's path - sans /s - in all cases: --- jablko@wum:~$ SCRIPT_PATH=day.php EXEC_PATH=php ./test | head Executing: 'php' Arguments: 'php' 'day.php' --- Thanks! Jack |