The apache2 init script clobbers the environment, running it with an empty environment except for a custom PATH variable. This is a problem when running some third-party apache modules that require environment variables to be set. The apache foundation's own axis-c module is an example of this, as it requires AXISCPP_DEPLOY=/some/path to be set to funcion correctly. A workaround (specific for axis-c) is to modify the apache init script so that the line: APACHE2="env -i PATH=${PATH} /usr/sbin/apache2${MY_MPM}" reads: APACHE2="env -i PATH=${PATH} AXISCPP_DEPLOY=/some/path /usr/sbin/apache2${MY_MPM}" This works, but is not the most graceful way of doing this. Subsequent updates to apache that change the init script could wipe out these modifications if not merged carefully. I propose that a better way would be to add a variable APACHE2_ENV to /etc/conf.d/apache2, and modifying the line to read: APACHE2="env -i PATH=${PATH} ${APACHE2_ENV} /usr/sbin/apache2${MY_MPM}" Then I could add: APACHE2_ENV="AXISCPP_DEPLOY=/some/path" to /etc/conf.d/apache2 and not worry about future updates to apache wiping this out.
The 'cleansing' of the environment is intentional, and there has been a few open bugs about this before. I really do not want to change this, or start creating white lists, either .. However, I can't think think of any one way that'd suit both camps .. Does anyone have any adverse feelings to having a white-list variable in /etc/conf.d/apache2 as Simon explained ? Would be easy to implement, as well (could also go in at the same time we kill the 'graceful-restart-by-default' behaviour in the init script </muse> ..)
Could this one help? This lets the user decide what to keep from the env, and I have to use it on a customer site due to PHP/Oracle and NLS conflicts. Basically the user needs to maintain the var KEEPENV in /etc/conf.d/apache2 and it would default to PATH only. --- /etc/init.d/apache2 2005-07-04 15:06:05.000000000 +0200 +++ tmp/apache2 2005-07-04 15:05:33.000000000 +0200 @@ -37,6 +37,13 @@ eerror "Did you etc-update /etc/conf.d/apache2?" return 1 fi + + if [ ! -z "${KEEPENV}" ]; then + for n in ${KEEPENV}; do + OLDENV="${OLDENV} ${n}=`printenv ${n}`"; + done + fi + /usr/sbin/apache2 -t ${APACHE2_OPTS} 1>/dev/null 2>&1 ret=$? if [ $ret -ne 0 ]; then @@ -54,10 +61,13 @@ start() { checkconfig || return 1 + if [ ! -z "${OLDENV}" ]; then + einfo " Keeping old env: ${KEEPENV}" + fi ebegin "Starting apache2" [ -f /var/log/apache2/ssl_scache ] && rm /var/log/apache2/ssl_scache [ -f /usr/lib/apache2/build/envvars ] && . /usr/lib/apache2/build/envvars - env -i PATH=$PATH /sbin/start-stop-daemon --quiet \ + env -i $OLDENV /sbin/start-stop-daemon --quiet \ --start --startas /usr/sbin/apache2 \ --pidfile ${PIDFILE} -- -k start ${APACHE2_OPTS} eend $?
*** Bug 79027 has been marked as a duplicate of this bug. ***
I've added a fix for this to SVN. It will appear the next time a configuration tarball is rolled.
New tarball rolled. Fixed in CVS. Resolving.