From nobody@FreeBSD.org  Sat Aug 11 11:47:13 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id EE23237B401
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 11 Aug 2001 11:47:12 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.4/8.11.4) id f7BIlCx51285;
	Sat, 11 Aug 2001 11:47:12 -0700 (PDT)
	(envelope-from nobody)
Message-Id: <200108111847.f7BIlCx51285@freefall.freebsd.org>
Date: Sat, 11 Aug 2001 11:47:12 -0700 (PDT)
From: OGAWA Takaya <t-ogawa@triaez.kaisei.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: portmap not automatically enabled in /etc/rc
X-Send-Pr-Version: www-1.0

>Number:         29631
>Category:       conf
>Synopsis:       portmap not automatically enabled in /etc/rc
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Aug 11 11:50:00 PDT 2001
>Closed-Date:    Mon Aug 13 22:51:11 PDT 2001
>Last-Modified:  Mon Aug 13 22:51:17 PDT 2001
>Originator:     OGAWA Takaya
>Release:        FreeBSD 4.4-PRERELEASE
>Organization:
>Environment:
FreeBSD gandalf.middle.earth 4.4-PRERELEASE FreeBSD 4.4-PRERELEASE #5: Thu Aug  9 00:50:08 JST 2001     root@gandalf.middle.earth:/usr/obj/usr/src/sys/GANDALF  i386

>Description:
In /etc/rc, special care is taken so that portmap will be automatically
enabled if either amd, nfs or nis enabled:

	chkdepend amd amd_enable        portmap portmap_enable
	chkdepend NFS nfs_server_enable portmap portmap_enable
	chkdepend NIS nis_server_enable portmap portmap_enable
	chkdepend NIS nis_client_enable portmap portmap_enable

Thanks to these lines, variable ${portmap_enable} will be set to "YES"
if needed.

However, /etc/rc later loads /etc/rc.firewall, which unconditionally
reloads /etc/defaults/rc.conf (and /etc/rc.conf, if exists):

        if [ -r /etc/defaults/rc.conf ]; then
                . /etc/defaults/rc.conf
                source_rc_confs
        elif [ -r /etc/rc.conf ]; then
                . /etc/rc.conf
        fi

Thus, unless user specifically set ${portmap_enable} to "YES" in /etc/rc.conf,
${portmap_enable} will be reset to "NO" in /etc/defaults/rc.conf.

Later on, /etc/rc invokes network_pass2() (which defined in /etc/rc.network)
but portmap won't be run because ${portmap_enable} has been reset to "NO".

>How-To-Repeat:
Create /etc/rc.conf as follows:
nfs_server_enable="YES"

And reboot the system. During bootup, rc shows:

	DEPENDENCY NOTE: portmap_enable will be enabled to support NFS

However,

	% ps ax | grep portmap

produces nothing.

>Fix:
In /etc/rc.firewall, don't reload /etc/rc.conf nor /etc/defaults/rc.conf
if they are already loaded.

/etc/rc.firewall6 already cares this so the same approach can be applied to
/etc/rc.firewall as well. Patch is as follows:

--- etc/rc.firewall.orig        Sun Aug 12 03:13:37 2001
+++ etc/rc.firewall     Sun Aug 12 03:17:58 2001
@@ -30,11 +30,13 @@
 #
 
 # Suck in the configuration variables.
-if [ -r /etc/defaults/rc.conf ]; then
-       . /etc/defaults/rc.conf
-       source_rc_confs
-elif [ -r /etc/rc.conf ]; then
-       . /etc/rc.conf
+if [ -z "${source_rc_confs_defined}" ]; then
+       if [ -r /etc/defaults/rc.conf ]; then
+               . /etc/defaults/rc.conf
+               source_rc_confs
+       elif [ -r /etc/rc.conf ]; then
+               . /etc/rc.conf
+       fi
 fi
 
 ############

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: dd 
State-Changed-When: Mon Aug 13 22:51:11 PDT 2001 
State-Changed-Why:  
Thanks for your excellent analysis of the problem!  I've applied the 
patch to -current, and barring any problems, I'll try to get it MFC'd 
for 4.4. 


http://www.FreeBSD.org/cgi/query-pr.cgi?pr=29631 
>Unformatted:
