rc.conf.d support for local_startup directories?

Doug Barton dougb at FreeBSD.org
Mon Feb 6 21:30:10 PST 2006


Howdy,

A post on -ports recently, and some other stuff I've been working on got me
thinking. Is there any reason not to offer rc.conf.d support in the
local_startup directories? I think that this would simplify a lot of issues,
port authors could install the file with appropriate defaults, then
deinstall it when they are done. No more messy stuff left over after a port
is deinstalled.

The only disadvantage I can see to this is that because of how the conf
sourcing code is written, the variables in a file in an rc.conf.d directory
will always override those in /etc/rc.conf[.local]. This could lead to two
problems, one would be a potential POLA violation, the other is that there
is a convenience factor now in just putting port_enable=yes in
/etc/rc.conf.local, and having it still be there after you install the port.
If rc.conf.d support became more widespread for ports, then users would have
to either re-enable that port at every install, or (more likely) port
authors would start enabling their port by default. One could make the
argument that this is reasonable behavior, so I'm not sure this is a problem
per se, just something to consider.

There is at least one way around this problem that I can see off hand, but I
thought I'd throw it open for discussion first and see what people think.
I've attached the simplest implementation I could think of to start the
discussion.

Doug

-- 

    This .signature sanitized for your protection

-------------- next part --------------
Index: rc.subr
===================================================================
RCS file: /usr/local/ncvs/src/etc/rc.subr,v
retrieving revision 1.47
diff -u -r1.47 rc.subr
--- rc.subr	10 Dec 2005 20:19:08 -0000	1.47
+++ rc.subr	7 Feb 2006 03:50:33 -0000
@@ -876,10 +876,12 @@
 		fi
 		_rc_conf_loaded=true
 	fi
-	if [ -f /etc/rc.conf.d/"$_command" ]; then
-		debug "Sourcing /etc/rc.conf.d/${_command}"
-		. /etc/rc.conf.d/"$_command"
-	fi
+	for dir in /etc $local_startup; do
+		if [ -r "${dir%/rc.d}/rc.conf.d/$_command" ]; then
+			debug "Sourcing ${dir%/rc.d}/rc.conf.d/${_command}"
+			. "${dir%/rc.d}/rc.conf.d/$_command"
+		fi
+	done
 
 	# XXX - Deprecated variable name support
 	#


More information about the freebsd-rc mailing list