Bug 29631

Summary: portmap not automatically enabled in /etc/rc
Product: Base System Reporter: t-ogawa <t-ogawa>
Component: confAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.4-PRERELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description t-ogawa 2001-08-11 19:50:00 UTC
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".

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:
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.
Comment 1 dd freebsd_committer freebsd_triage 2001-08-14 06:51:11 UTC
State Changed
From-To: open->closed

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.