From owner-freebsd-ports-bugs@FreeBSD.ORG Tue Sep 16 06:30:02 2008 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E8552106566C; Tue, 16 Sep 2008 06:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id C40778FC26; Tue, 16 Sep 2008 06:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m8G6U1BU028799; Tue, 16 Sep 2008 06:30:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m8G6U1Hh028798; Tue, 16 Sep 2008 06:30:01 GMT (envelope-from gnats) Resent-Date: Tue, 16 Sep 2008 06:30:01 GMT Resent-Message-Id: <200809160630.m8G6U1Hh028798@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Cc: clement@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Eygene Ryabinkin Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0EA611065671 for ; Tue, 16 Sep 2008 06:20:47 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from 0.mx.codelabs.ru (0.mx.codelabs.ru [144.206.177.45]) by mx1.freebsd.org (Postfix) with ESMTP id A562A8FC1C for ; Tue, 16 Sep 2008 06:20:46 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from phoenix.codelabs.ru (ppp85-141-67-29.pppoe.mtu-net.ru [85.141.67.29]) by 0.mx.codelabs.ru with esmtps (TLSv1:CAMELLIA256-SHA:256) id 1KfTvX-000OOx-DG for FreeBSD-gnats-submit@freebsd.org; Tue, 16 Sep 2008 10:20:43 +0400 Message-Id: <20080916061826.5048CF183F@phoenix.codelabs.ru> Date: Tue, 16 Sep 2008 10:18:26 +0400 (MSD) From: Eygene Ryabinkin To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 X-GNATS-Notify: clement@FreeBSD.org Cc: Subject: ports/127418: [patch] www/apache22: initialize environment in rc.d script a bit later X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Eygene Ryabinkin List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Sep 2008 06:30:02 -0000 >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: