Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Sep 2008 10:18:26 +0400 (MSD)
From:      Eygene Ryabinkin <rea-fbsd@codelabs.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/127418: [patch] www/apache22: initialize environment in rc.d script a bit later
Message-ID:  <20080916061826.5048CF183F@phoenix.codelabs.ru>
Resent-Message-ID: <200809160630.m8G6U1Hh028798@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         127418
>Category:       ports
>Synopsis:       [patch] www/apache22: initialize environment in rc.d script a bit later
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 16 06:30:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Eygene Ryabinkin
>Release:        FreeBSD 7.1-PRERELEASE i386
>Organization:
Code Labs
>Environment:

System: FreeBSD XXX 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #9: Thu Sep 4 20:00:48 MSD 2008 root@XXX:/usr/src/sys/i386/compile/XXX i386

>Description:

Apache 2.x rc.d script initializes Apache environment at the time of
configuration check.  Sometimes it is too early, because environment
tuners from ${PREFIX}/etc/apache22/envvars.d/ can greatly modify the
script environment.  For example, my script heavily mangle with PATH, so
after running environment cleaners the 'sysctl' command is not available
and it produces slightly worrying warning.

>How-To-Repeat:

Use the following contents of, for example,
${PREFIX}/etc/apache22/envvars.d/010.path.env
-----
export PATH=/bin:/usr/bin:/usr/sbin:/usr/local/bin
-----
and try restarting Apache.  If will complain about unavailability
of sysctl binary (for the modern versions of www/apache22, with
files/apache22.sh.in version 1.6 or later).

>Fix:

The following patch cures the situation for me.  It just makes
configuration file checking to be spawned in the separate shell and the
real environment correction is made late in the prestart phase.  It also
adds the function 'apache22_source_envvars' to avoid code duplication.

--- apache22.sh.in.dont-disrupt-environment begins here ---
--- files/apache22.sh.in.orig	2008-09-16 09:46:52.000000000 +0400
+++ files/apache22.sh.in	2008-09-16 09:57:33.000000000 +0400
@@ -138,13 +138,24 @@
 	fi
 }
 
-apache22_checkconfig()
+apache22_source_envvars()
 {
 	if test -f %%PREFIX%%/sbin/envvars
 	then
 		. %%PREFIX%%/sbin/envvars
 	fi
+}
 
+# Just invoking real checkconfig procedure in a subshell to avoid
+# disrupting environment.
+apache22_checkconfig()
+{
+	(apache22_checkconfig_real)
+}
+
+apache22_checkconfig_real()
+{
+	apache22_source_envvars
 	echo "Performing sanity check on apache22 configuration:"
 	eval ${command} ${apache22_flags} -t
 }
@@ -191,6 +202,9 @@
 apache22_prestart() {
 	apache22_precmd
 	apache22_checkfib
+# Should be the last step: environment tuners can greatly modify
+# script environment (PATH, LD_LIBRARY_PATH, etc).
+	apache22_source_envvars
 }
 
 extra_commands="reload graceful gracefulstop configtest"
--- apache22.sh.in.dont-disrupt-environment ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080916061826.5048CF183F>