Calling "php -f [file]" from within Perl seems broken

From: Mike Bobbitt (Junk_at_Army.ca)
Date: 01/03/04


Date: 3 Jan 2004 14:42:37 -0800

I've recently decided to switch from compiled Apache/PHP to RPM's of
both and I'm having a problem I can't seem to solve. I have a Perl
script called php_include.cgi that parses a PHP file for inclusion. It
does this by running "php -f [php include file]" but unfortunately it
no longer works with the RPM:

----------

Security Alert! The PHP CGI cannot be accessed directly.
This PHP CGI binary was compiled with force-cgi-redirect enabled. This
means that a page will only be served up if the REDIRECT_STATUS CGI
variable is set, e.g. via an Apache Action directive.

For more information as to why this behaviour exists, see the manual
page for CGI security.

For more information about changing this behaviour or re-enabling this
webserver, consult the installation file that came with this
distribution, or visit the manual page.

----------

The RPM for PHP obviously compiles with --enable-force-cgi-redirect.
If I either set cgi.force_redirect = 0 in php.ini or set
$ENV{REDIRECT_STATUS}="200"; in my Perl script, this error goes away,
as expected.

The weird part is that I do something like this in my Perl:

print `/usr/bin/php -f /var/www/html/includes/footer.php`;

Which you would expect to parse and output footer.php. Oddly, it
prints the contents of php_include.cgi (the calling Perl script)
instead! If I run the exact same command in a shell (even as my apache
user) it works correctly. When called from the web, it displays the
Perl script, not the php.

I've confirmed this a bunch of different ways.

Yes, I know I could blame this on the RPM, but I'd like to move to a
"standardized" load if possible... Makes updates easier... Also, this
one's got my curiosity...

Any help or insight would be appreciated.

Thanks
Mike



Relevant Pages

  • Re: HELP: send binary replies back and forth ???
    ... > My php application needs to do the following: ... > My PHP script loops through all records and sends each of them ONE BY ONE. ... > other than to be able to communicate with apache. ... All communication is binary because the connection used is pricy and ...
    (comp.lang.php)
  • Re: from elsewhere, an assembler
    ... PHP is a treat. ... The only problem I have with Perl at the moment, ... play with Perl I play inside a command prompt ... an annoyance I guess for using apache on windows... ...
    (alt.lang.asm)
  • Re: How (best) to use web-from entry of an OTP/OPIE password to control a PF-firewall?
    ... A perl script witch uses Auth::opie cpan. ... PHP talks to the perl executable. ... I understand how to set up OpenVPN passthrough from a remote client ...
    (Security-Basics)
  • Re: redirect / new website how to redirect old (google) links to new site ?
    ... we have a discussion forum written in Perl. ... We have other packages written in PHP. ... It may not be as good as Apache, but it still is a perfectly good webserver. ... People have been working on them, but they're still not ready for a serious server. ...
    (comp.lang.php)
  • Re: preventing a user to start a process
    ... You can use some perl to split the lines to find out how long the processes ... >> located in file systems that allow execution. ... >> are running for a certain period of time and are not the apache. ... Does anyone know a usable script for that ...
    (freebsd-isp)