[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#252627: passing environment to apache : solution ?



Matthew Wilcox wrote:

Erm, does it actually work?  I don't see why it should.  I would have
thought you'd have to add stuff to the env line.


I thought so as well. But the script does not use $APACHECTL but $DAEMON (it's on a woody). Look :

(http://192.168.0.75/info.php is a simple phpinfo() )

wanadoo-abv:/# mv /etc/default/apache /etc/default/apache.bak
wanadoo-abv:/# /etc/init.d/apache restart
Reloading apache modules.
wanadoo-abv:/# lynx -dump http://192.168.0.75/info.php | grep ORACLE
               Compile-time ORACLE_HOME /home/oracle/OraHome1
wanadoo-abv:/#

(no ORACLE_HOME in apache env)

wanadoo-abv:/# mv /etc/default/apache.bak /etc/default/apache
wanadoo-abv:/# /etc/init.d/apache restart
Reloading apache modules.
wanadoo-abv:/# lynx -dump http://192.168.0.75/info.php | grep ORACLE
               Compile-time ORACLE_HOME /home/oracle/OraHome1
                     ORACLE_HOME /home/oracle/OraHome1
                 _ENV["ORACLE_HOME"] /home/oracle/OraHome1
wanadoo-abv:/#

(well... it IS there, isn't it ?)

On sid (and probably sarge), you would use the attached patch and exemple.

This is intended as a "clean" way, to prevent users from removing the "ENV" variable from init script just to make php-oci8 or anything with similar needs working, and loosing the "env -i" protection.

Best regards,

--
Clément 'nodens' Hermann <clement.hermann@free.fr>
- L'air pur ? c'est pas en RL, ça ? c'est pas hors charte ?
-- Jean in "l'Histoire des Pingouins" - http://tnemeth.free.fr/fmbl/linuxsf
--- /etc/init.d/apache.orig	2004-08-13 16:50:35.000000000 +0200
+++ /etc/init.d/apache	2004-08-13 16:51:26.000000000 +0200
@@ -12,7 +12,10 @@
 APACHECTL=/usr/sbin/${NAME}ctl
 # note: SSD is required only at startup of the daemon.
 SSD=`which start-stop-daemon`
-ENV="env -i LANG=C PATH=/bin:/usr/bin:/usr/local/bin"
+
+# import the wanted environment variable (and only these)
+[ -f /etc/default/apache ] && . /etc/default/apache
+ENV="env -i LANG=C PATH=/bin:/usr/bin:/sbin:/usr/sbin $EXTRAENV"
 
 trap "" 1
 
# /etc/default/apache
# This file is intended as a way to pass environment variables
# to apache. Use the EXTRAENV variable below.

# WARNING : you should be *very* cautious when adding
# new environment variable. This could lead to an 
# important information leak.

# Passing ORACLE_HOME to apache is required to 
# use php-oci8 bindings with php as an apache module.
# We also need FOO for a internal php admin script.
EXTRAENV="ORACLE_HOME=/home/oracle/OraHome1 FOO=BAR"

Reply to: