Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Jul 2006 14:42:08 -0400 (EDT)
From:      Mike Andrews <mandrews@bit0.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/100350: www/apache20 profiles not working at system startup/shutdown time due to unexpected $0 value
Message-ID:  <20060715184208.B2D58730003@mindcrime.bit0.com>
Resent-Message-ID: <200607151850.k6FIoDXw052319@freefall.freebsd.org>

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

>Number:         100350
>Category:       ports
>Synopsis:       www/apache20 profiles not working at system startup/shutdown time due to unexpected $0 value
>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:   Sat Jul 15 18:50:13 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Mike Andrews
>Release:        FreeBSD 6.1-STABLE amd64
>Organization:
Fark.com LLC
>Environment:
System: FreeBSD mindcrime.bit0.com 6.1-STABLE FreeBSD 6.1-STABLE #1: Fri Jul 14 18:53:37 EDT 2006 mandrews@mindcrime.bit0.com:/usr/obj/usr/src/sys/MINDCRIME amd64

Also happens on 6.1-RELEASE-p2 i386 GENERIC or SMP

>Description:

When using the latest apache20 port (from July 14 2006 portsnap) and the profiles
feature to run multiple httpd's on one system (or even just a single profile),
such as the following in /etc/rc.conf:

	apache2_enable="YES"
	apache2_profiles="0DEV"
	apache2_0DEV_flags="-DServer0DEV"
	apache2_0DEV_configfile="/usr/local/etc/apache2/httpd2-test.conf"

Manually using "/usr/local/etc/rc.d/apache2.sh start 0DEV" (or stop or reload
or restart) works fine.

Manually using "/usr/local/etc/rc.d/apache2.sh start" (or stop or reload but
NOT restart) works fine.  restart not working may be related to ports/86402
but that's not that this PR is about :)

At system boot time though, it fails to start Apache with the following error:

	===> apache2 profile: 0DEV
	/usr/local/etc/rc.d/apache2.sh: /etc/rc: Permission denied

On line 73 of /usr/local/etc/rc.d/apache2.sh is a line "$0 $1 $profile" that's
used to re-run apache2.sh for each individual profile.  If I put $0 into the
"echo" line above it, it says $0 is "/etc/rc.d" so it fails when it tries to
re-run the wrong script.  The upshot is I have to manually restart Apache after
a reboot.

At system shutdown $0 gets mangled into "/etc/rc.shutdown" instead of
"/usr/local/etc/rc.d/apache2.sh" the same way.

If I create a simple /usr/local/etc/rc.d/test.sh script containing just

#!/bin/sh
echo Hello, I seem to be $0

then it prints /usr/local/etc/rc.d/test.sh as expected.  Putting that as
the first line in /usr/local/etc/rc.d/apache.2.sh prints /etc/rc at startup,
/etc/rc.shutdown at shutdown and /usr/local/etc/rc.d/apache2.sh when run
manually.  'm not sure why that one is different.  It does run earlier than
some of the others.

With no profiles enabled everything works fine because it never needs to
reference $0 in that case.


>How-To-Repeat:

Install www/apache20 on a system (or jail), add the above variables to
/etc/rc.conf, and restart the system (or jail); if a jail then check
/var/log/console.log for the above error messages.


>Fix:

Using $_file instead of $0 works for system boot but breaks the manual case.
Perhaps using $_file if it exists and $0 when it doesn't?

There is the possibility that I've done something stupid to my /etc/rc.conf,
(like not using the apache20 profile variables correctly) or that I have another
port whose rc.d script is trashing $0 somehow, or that I just plain don't understand
the rc system.  :)


>Release-Note:
>Audit-Trail:
>Unformatted:



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