473,698 Members | 2,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

php4-cgi doesn't read -c /path/to/config, php5-cgi does

Hi

I've got a really strange problem, and can't find out why it's not
working as intended.

in order to use php4 and 5 together on a webserver and the requirement
for running as different users, I use suexec and a wrapper script for
php files. to make it a bit clearer, i'll post the different snippets:

httpd.conf:
ScriptAlias /php-wrapper /home/httpd/phpwrapper/
AddType application/x-httpd-php-5 php
Action application/x-httpd-php-5 /php-wrapper/php5
AddType application/x-httpd-php-4 php3 php4
Action application/x-httpd-php-4 /php-wrapper/php4

resulting in using either /home/httpd/phpwrapper/php4 or
/home/httpd/phpwrapper/php5 for php files

the script for the wrappers (the checks only make sure the php.ini file
can't be modified by our customers, it should be owned by root and not
be writable):
#!/bin/sh
INI="${DOCUMENT _ROOT}/../etc/php.ini"
if [[ -s "$INI" ]] && [[ ! -w "$INI" ]] && [[ ! -G "$INI" ]] && [[ ! -O
"$INI" ]]
then
exec /usr/lib/php5/bin/php-cgi -c $INI ${PATH_TRANSLAT ED}
else
echo "Content-Type: text/plain"
echo -e "\n\n"
echo "Execution not allowed"
fi

the other wrapper is exactly the same exept it's executing the php4-cgi
binary.

suexec is already patched so it doesn't interfere with those scripts
belowing to root. (I had make some exceptions, ie for the frontpage
extensions which are now working perfectly)

now the problem itself: under php5 all works perfectly. I have a default
ini file (very restrictive) and the ini of the user (opening some
directories with open_basedir). same under php4, only that it doesn't
read the ini file at all. it just uses the default file, all extensions
but not the file specified by -c

paths and all are correct, and to make it even better: on the command
line the same line works perfectly (as user and as root). I tried the
same with -i for phpinfo() output.

maybe its the heat, but I can't explain why that happens. especially the
fact its working on command line is strange. the shellscript doesn't do
anything else and yet it doesn't work.

if anyone ever had a similar problem or maybe a hint about what to do to
solve that problem, it would be highly appreciated.

thanks alot and a nice day

Stefan
Jul 13 '06 #1
2 2584
Stefan Huber wrote:
Hi

I've got a really strange problem, and can't find out why it's not
working as intended.

in order to use php4 and 5 together on a webserver and the requirement
for running as different users, I use suexec and a wrapper script for
php files. to make it a bit clearer, i'll post the different snippets:

httpd.conf:
ScriptAlias /php-wrapper /home/httpd/phpwrapper/
AddType application/x-httpd-php-5 php
Action application/x-httpd-php-5 /php-wrapper/php5
AddType application/x-httpd-php-4 php3 php4
Action application/x-httpd-php-4 /php-wrapper/php4

resulting in using either /home/httpd/phpwrapper/php4 or
/home/httpd/phpwrapper/php5 for php files

the script for the wrappers (the checks only make sure the php.ini file
can't be modified by our customers, it should be owned by root and not
be writable):
#!/bin/sh
INI="${DOCUMENT _ROOT}/../etc/php.ini"
if [[ -s "$INI" ]] && [[ ! -w "$INI" ]] && [[ ! -G "$INI" ]] && [[ ! -O
"$INI" ]]
then
exec /usr/lib/php5/bin/php-cgi -c $INI ${PATH_TRANSLAT ED}
else
echo "Content-Type: text/plain"
echo -e "\n\n"
echo "Execution not allowed"
fi

the other wrapper is exactly the same exept it's executing the php4-cgi
binary.

suexec is already patched so it doesn't interfere with those scripts
belowing to root. (I had make some exceptions, ie for the frontpage
extensions which are now working perfectly)

now the problem itself: under php5 all works perfectly. I have a default
ini file (very restrictive) and the ini of the user (opening some
directories with open_basedir). same under php4, only that it doesn't
read the ini file at all. it just uses the default file, all extensions
but not the file specified by -c

paths and all are correct, and to make it even better: on the command
line the same line works perfectly (as user and as root). I tried the
same with -i for phpinfo() output.

maybe its the heat, but I can't explain why that happens. especially the
fact its working on command line is strange. the shellscript doesn't do
anything else and yet it doesn't work.

if anyone ever had a similar problem or maybe a hint about what to do to
solve that problem, it would be highly appreciated.

thanks alot and a nice day

Stefan
I found out a tiny little bit:
apache passes some env variables, 5 of them need to be unset, then it
works. but those 4 aren't useless, I think:
SCRIPT_FILENAME SERVER_NAME SERVER_SOFTWARE GATEWAY_INTERFA CE REQUEST_METHOD

as soon as I let them through, cgi-php4 won't parse it's command line
options (-c especially, but anything else too)

I'll keep searching, but hoping someone could have clue whats the
problem here..

Stefan
Jul 13 '06 #2
Stefan Huber wrote:
Stefan Huber wrote:
>Hi

I've got a really strange problem, and can't find out why it's not
working as intended.

in order to use php4 and 5 together on a webserver and the requirement
for running as different users, I use suexec and a wrapper script for
php files. to make it a bit clearer, i'll post the different snippets:

httpd.conf:
ScriptAlias /php-wrapper /home/httpd/phpwrapper/
AddType application/x-httpd-php-5 php
Action application/x-httpd-php-5 /php-wrapper/php5
AddType application/x-httpd-php-4 php3 php4
Action application/x-httpd-php-4 /php-wrapper/php4

resulting in using either /home/httpd/phpwrapper/php4 or
/home/httpd/phpwrapper/php5 for php files

the script for the wrappers (the checks only make sure the php.ini file
can't be modified by our customers, it should be owned by root and not
be writable):
#!/bin/sh
INI="${DOCUMEN T_ROOT}/../etc/php.ini"
if [[ -s "$INI" ]] && [[ ! -w "$INI" ]] && [[ ! -G "$INI" ]] && [[ ! -O
"$INI" ]]
then
exec /usr/lib/php5/bin/php-cgi -c $INI ${PATH_TRANSLAT ED}
else
echo "Content-Type: text/plain"
echo -e "\n\n"
echo "Execution not allowed"
fi

the other wrapper is exactly the same exept it's executing the php4-cgi
binary.

suexec is already patched so it doesn't interfere with those scripts
belowing to root. (I had make some exceptions, ie for the frontpage
extensions which are now working perfectly)

now the problem itself: under php5 all works perfectly. I have a default
ini file (very restrictive) and the ini of the user (opening some
directories with open_basedir). same under php4, only that it doesn't
read the ini file at all. it just uses the default file, all extensions
but not the file specified by -c

paths and all are correct, and to make it even better: on the command
line the same line works perfectly (as user and as root). I tried the
same with -i for phpinfo() output.

maybe its the heat, but I can't explain why that happens. especially the
fact its working on command line is strange. the shellscript doesn't do
anything else and yet it doesn't work.

if anyone ever had a similar problem or maybe a hint about what to do to
solve that problem, it would be highly appreciated.

thanks alot and a nice day

Stefan

I found out a tiny little bit:
apache passes some env variables, 5 of them need to be unset, then it
works. but those 4 aren't useless, I think:
SCRIPT_FILENAME SERVER_NAME SERVER_SOFTWARE GATEWAY_INTERFA CE REQUEST_METHOD

as soon as I let them through, cgi-php4 won't parse it's command line
options (-c especially, but anything else too)

I'll keep searching, but hoping someone could have clue whats the
problem here..

Stefan
ah, I found the solution. its quite simple:
the CGI version of php4 discards any command line options, using env
variables instead. for a new ini file it's the PHPRC variable, which has
to point to a directory rather then to a file (thats what I tested and
not worked).
php5 reads all command line args and also the variables.

the simpler the problem the harder to find a solution ;-)

Stefan
Jul 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2463
by: Nisha_tm | last post by:
Hello: I have a form in which I have checkboxes. Right now, I wrote the form's html and the php4 script. I use associative arrays in the form to capture the checkboxes that are checked. My html form puts the data in $info if the check box is checked. Part of my php4 script is as follows:
0
2039
by: Klaus Boehmer | last post by:
Hello, I'm trying to install gd2 with gif-support as an extension with php4. I compiled the patched version of gd2 - fine. I compiled php4 with gd=shared - fine. I installed it and restarted apache and I get: undefined symbol: gdImagePngCtx I recompiled php4 and included gd and everything works fine. But as soon as I compile gd2 as shared things mess up. I've searched 2 days for a solution, but didn't find anything. Please help me!
0
1696
by: Google Mike | last post by:
I found some strange kind of mild install bug when installing Ubuntu 5.04 php4-pgsql module (the module that connects PHP4 to PostgreSQL). You may encounter the error: Call to undefined function: pg_connect() No amount of using Synaptic Package Manager would fix this for me. The solution was all at command line under 'root' account: $ apt-get update
0
1348
by: Robert Oschler | last post by:
I am using XMLHttpRequest() from Javascript on the client side. XMLHttpRequest() expects a valid XML/XHTML document as a response. The target for the request is a PHP4 script running on my web server. This script queries an external web server, which returns an XML response to my PHP4 script. My PHP4 script uses the PEAR XML parser to parse the XML response into a PEAR XML tree object, which I modify and add to.
3
1611
by: masterx | last post by:
I developed and maintained a site for someone using Apache 1.3 and PHP 4.0.3 and used to be able to reference a page without explicitly specifying the .php extension. ie. http://www.url.com/adminpage would open adminpage.php. However since I've upgraded to Apache 2.0.55 and PHP 4.4.1 this no longer works. Is this something that can be configured in my httpd.conf or has this feature been removed from Apache 2? I'm running the Windows...
4
1801
by: Andy Baxter | last post by:
hello, I'm using the php4-mysql module with php4 under debian linux (sarge). I have a script, schedule.php, which runs fine when I invoke it from the command line, but fails with the error: Fatal error: Call to undefined function: mysql_connect() in /local/rivulet/interface/db.php on line 4 when I try to invoke it as a web page (using apache2). As far as I know,
3
2722
by: danish | last post by:
Hi, Can anyone tell me how to access oracle from php. Im using CentOS 4 with php4 already installed. From what I found after a bit of googling...php will have to be recompiled with oracle support. This seems to be a lot tedious. Anyone with an advic on how to use oracle with php. Im using CentOS4 php4 oracle10g
3
1695
by: CptDondo | last post by:
I have the following snippet I wrote that worked fine using a home-built ming library. Now it turns out it's not a part of PHP4, which is what I have: $f = new SWFFont("/lib/flashfonts/Bitstream Vera Sans.fdb"); $t = new SWFText(); $t->setFont($f); $t->moveTo(0, 0); $t->setColor(0xff, 0xff, 0xff); $t->setHeight($fontHeight);
3
2944
by: doctorhardik | last post by:
hai all i am try configure php4.3.9 on my FC-3 machine. and my mysql database version 5.0.1, in phpinfo file it show mysql but when i run php -v command it show error like
7
2128
by: jrefran | last post by:
Hi Everyone! Is there a need to compile my Apache 2.0.59 if I will use PHP4.4.5? How can I apply my Apache to PHP4.4.5 or I might ask how will I use my Apache properly with PHP4.4.5? This is my first time to use Apache with PHP. Please help me.
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4366
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2328
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.