Subject: Re: rc local [UPDATE]
To: None <tech-userlevel@NetBSD.org>
From: None <tlaronde@polynum.com>
List: tech-userlevel
Date: 03/19/2007 21:25:04
--tThc/1wpZn/ma/RB
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit

I have updated the proposal according to concerns raised:
	- by Greg Troxel for the lack of consistency: no pkgsrc
	  handling;
	- by Joerg Sonnenberger for the handling of two services sharing
	  the same basename.

Hence I have extended the logic to add:
	/etc/rc.d.pkgsrc/
	/etc/rc.defaults.pkgsrc

and have added a check in /etc/security for identical basenames (since,
if files in /etc/rc.d/* are left alone mtree(8) will not protest, but
with a single variable set in /etc/rc.conf several scripts can be run
(this may be a security concern; this may be also an administration
decision---this is an option that may be sensible in some cases).

I "reply" to my previous post so that people can read only the diff.

As usual, this is only FWIW. But the paragraph on a possible pkgsrc
policy can be, IMHO, of some interest to others as well as the Security
added one (perhaps not everybody knows about the `nostart' keyword).


On Sun, Mar 18, 2007 at 03:08:14PM +0100, tlaronde@polynum.com wrote:
> Hello,
> 
> Here is a set of patches to modify slightly rc framework local
> additions.
> 
> Rationale
> ---------
> 
> The rc(8) framework offers several facilities, two important ones being
> to launch services in topological order (via rcorder(8)), and to shut
> down properly these services in reverse order when shutdown(8) is
> invoked.
> 
> At the moment, the comments in /etc/rc.local do not emphasize the fact
> that local daemons launched via this file will be launched when
> /etc/rc.d/local is called with the start action, that is not mandatorily
> at the better time for these daemons.
> Furthermore, the sibling script /etc/rc.shutdown.local is not
> advertised, while this is the script invoked when /etc/rc.d/local is
> called with the stop action (i.e., for example, by shutdown(8)). It is
> hence the natural place to put clean stopping actions for services
> launched in /etc/rc.local. But a better practice for daemons is to have
> rc.d compliant scripts.
> 
> One of the strength of the actual NetBSD etc/ organization is that it
> insulates NetBSD provided stuff from local overwrites and additions.
> /etc/rc.conf shall lists only the specific for this very site, the diff
> from the defaults set in /etc/defaults/rc.conf.
> 
> If one wants to modify the behavior of a NetBSD provided service (i.e. a
> script put in /etc/rc.d/), the /etc/rc.conf.d/ is provided.
> 
> Hence putting additional services in /etc/rc.d/ is perhaps not the best
> maintenance option:
> 	1) postinstall(8) may suppress scripts in /etc/rc.d/ or an upgrade
> 	may add scripts there. What if a local addition happens to provide
> 	such a named script?
> 	2) the actual framework provides a great maintenance principle: the
> 	"coup d'oeil": in one glance, looking at dedicated places, one
> 	easily knows what are the very specifics of this site, the diffs from
> 	a default install. Putting local additions in /etc/rc.d/ makes it
> 	hard to find, after some time, what is a default provided by NetBSD
> 	and a local addition. It does not scale.
> 
> Hence putting local added daemons in a dedicated directory is cleaner,
> and actually straightforward: a one line diff to rc(8).

Allowing too the pkgsrc framework to have a dedicated dir in /etc to
store the provided service files, and an uniq file to document the
settings for the added packages,  la /etc/defaults/rc.conf, would ease 
the administration provided that:
	- pkgsrc is the only one to handle the /etc/rc.defaults.pkgsrc and
	/etc/rc.d.pkgsrc/: local overwrites and local decisions take place
	in the local dedicated places
	- by default, all the pkgsrc installed files have the:
	# KEYWORD: nostart
	hence rcorder(8) as called by rc(8) will skip these files (with the
	`nostart' keyword files are parsed by rcorder(8) but not returned so
	no further action is done on these)
	- furthermore, the default settings for the service is: service=NO

	to enable a pkgsrc service, the administrator has to:
		- alternatively, remove the `nostart' keyword from the
		/etc/rc.d.pkgsrc/, or copy it in /etc/rc.d.local (read, and
		adjust removing the `nostart' keyword
		- set service=YES in /etc/rc.conf

> 
> Putting the maintenance reflexion a little further, one sees that if the
> NetBSD provided services defaults are clearly documented in
> /etc/defaults/rc.conf, local additions will not have that, or these
> defaults will end in /etc/rc.conf, putting a lot of verbosity and
> masking the real, raw diffs: if one needs to start grepping all around
> to find what is launched and what is not, we loose the "coup d'oeil"
> facility.
> 
> Furthermore, say in a network (in a domain), an administrator may have
> configuration habits. It would be simpler to have in /etc/rc.conf only
> what makes this very node different from:
> 	a) the default NetBSD;
> 	b) the default domain configuration.

	c) for documentation only, pkgsrc adds the relevant information for
	an added service in /etc/rc.defaults.pkgsrc

> 
> Hence the introduction of /etc/rc.defaults.local that shall document, 
> la /etc/defaults/rc.conf, the setting of local added services in
> /etc/rc.d.local/, and provide a domain wide default configuration.

and the introduction of /etc/rc.defaults.pkgsrc and /etc/rc.d.pkgsrc/
for pkgsrc framework (the addition of a package by pkgsrc shall be a
`platonic' decision: no further action is done by default, and the
administrator is the only one to decide, finally, to enable or not the
added service).

> 
> Tree and namespace principles
> -----------------------------
> 
> Joerg Sonnenberger and Thor Lancelot Simon have rightfully reacted
> against some of my early naming scheme proposals (I do not claim that
> they have voiced for or against this proposal; I just give them the
> credit that they did not find the naming scheme correct).
> 
> So here are the principles adopted:
> 
> 1) All local "hooks" are visible at the /etc/ root, whether files or
> directories;
> 
> 2) All names are built appending ".local" to them, since the emphasis


2) All names are built appending ".local" or ".pkgsrc" to them, 
since the emphasis

> must be put not on the nature of a link (a file or a directory '.d') but
> on the fact that these are local versions of standard facilities.
> 	There is also prior art since the script sourced by /etc/rc.d/local
> 	stop is called "/etc/rc.shutdown.local"
> 
> Added files and directories
> ---------------------------
> 
  /etc/rc.d.pkgsrc        # directory for pkgsrc added services
  /etc/rc.defaults.pkgsrc # documentation of the settings for the added
						  # services, the default being NO.

> /etc/rc.d.local         # directory for local added services
> /etc/rc.defaults.local  # domain wide variables setting  la
>                         # /etc/defaults/rc.conf. Sourced, if readable,
> 						# in /etc/rc.conf.
> /etc/rc.shutdown.local  # missing template for script sourced when
>                         # /etc/rc.d/local stop
> 

Security
--------

rcorder(8) is invoked by rc(8) with the skip `nostart' keyword files
argument. Hence, if all the files found in the directories are
processed, the `nostart' are not returned---this speed up a bit, or at
least does not slow down even more the processing time for added pkgsrc
scripts.

Since the files/scripts are returned by their pathnames, a single
variable representing the basename of a service can be used to run
several scripts (several pathnames).
This may be or not a security concern (an administrator can decide that
no pkgsrc default script will ever be run, and that he puts all the
scripts (customized copies) in /etc/rc.d.local/, using the original
service name (example: /etc/rc.d.pkgsrc/pgsql has the nostart keyword;
a /etc/rc.d.local.pgsql exists and /etc/rc.conf has pgsql=YES).

But since there may be a problem, /etc/security has been modified to
deliver the information about duplicate basenames of _runnable_ services
(skip the nostart ones).

> Caveats
> -------
> 
> I have diffed against 3.1. This should not cause problem except
> for rc.conf(5) that has, obviously, changed in head. But should applies
> nonetheless.
> 
> I am not an english native speaker so, assuming that my proposal makes
> some sense, the comments in the scripts and the man pages modifications
> should be reviewed and enhanced.
> 
> Thanks for your time.
> -- 
> Thierry Laronde (Alceste) <tlaronde +AT+ polynum +dot+ com>
>                  http://www.kergis.com/
> Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C

> diff -ru /usr/src/distrib/sets/lists/base/mi ./distrib/sets/lists/base/mi
> --- /usr/src/distrib/sets/lists/base/mi	2006-11-27 15:25:18.000000000 +0100
> +++ ./distrib/sets/lists/base/mi	2007-03-18 13:21:34.000000000 +0100
> @@ -89,6 +89,7 @@
>  ./etc/release					etc-sys-etc
>  ./etc/rc.conf.d					base-sys-root
>  ./etc/rc.d					base-sys-root
> +./etc/rc.d.local					base-sys-root
>  ./etc/skel					base-sys-root
>  ./etc/sliphome					base-slip-root
>  ./etc/ssh					base-sys-root
> diff -ru /usr/src/etc/changelist ./etc/changelist
> --- /usr/src/etc/changelist	2001-10-13 16:22:11.000000000 +0200
> +++ ./etc/changelist	2007-03-18 13:19:30.000000000 +0100
> @@ -10,4 +10,5 @@
>  #	/etc/raid*.conf
>  #	/etc/rc.d/*
>  #	/etc/rc.conf.d/*
> +#	/etc/rc.d.local/*
>  #
> diff -ru /usr/src/etc/mtree/NetBSD.dist ./etc/mtree/NetBSD.dist
> --- /usr/src/etc/mtree/NetBSD.dist	2006-05-26 14:17:03.000000000 +0200
> +++ ./etc/mtree/NetBSD.dist	2007-03-18 13:20:24.000000000 +0100
> @@ -42,6 +42,7 @@
>  ./etc/racoon
>  ./etc/rc.conf.d
>  ./etc/rc.d
> +./etc/rc.d.local
>  ./etc/skel
>  ./etc/sliphome
>  ./etc/ssh
> diff -ru /usr/src/etc/rc ./etc/rc
> --- /usr/src/etc/rc	2003-01-04 16:27:43.000000000 +0100
> +++ ./etc/rc	2007-03-17 20:25:33.000000000 +0100
> @@ -37,7 +37,8 @@
>  
>  date
>  
> -files=$(rcorder -s nostart ${rc_rcorder_flags} /etc/rc.d/*)
> +files=$(rcorder -s nostart ${rc_rcorder_flags} /etc/rc.d/* \
> +	/etc/rc.d.local/*)
>  
>  for _rc_elem in $files; do
>  	run_rc_script $_rc_elem start
> diff -ru /usr/src/etc/rc.conf ./etc/rc.conf
> --- /usr/src/etc/rc.conf	2000-10-14 19:01:29.000000000 +0200
> +++ ./etc/rc.conf	2007-03-18 12:24:45.000000000 +0100
> @@ -13,9 +13,17 @@
>  	. /etc/defaults/rc.conf
>  fi
>  
> +# Load local domain wide defaults in from /etc/rc.defaults.local (if 
> +# it's readable).
> +# These can be overridden too below.
> +#
> +if [ -r /etc/rc.defaults.local ]; then
> +	. /etc/rc.defaults.local
> +fi
> +
>  # If this is not set to YES, the system will drop into single-user mode.
>  #
>  rc_configured=NO
>  
> -# Add local overrides below
> +# Add site specific overrides below
>  #
> diff -ru /usr/src/etc/rc.local ./etc/rc.local
> --- /usr/src/etc/rc.local	2002-07-23 12:48:01.000000000 +0200
> +++ ./etc/rc.local	2007-03-18 12:20:10.000000000 +0100
> @@ -1,22 +1,43 @@
> -#	$NetBSD: rc.local,v 1.30 2002/07/23 10:48:01 wennmach Exp $
> +#	$Id$
>  #	originally from: @(#)rc.local	8.3 (Berkeley) 4/28/94
>  #
> -# This file is (nearly) the last thing invoked by /etc/rc during a
> -# normal boot, via /etc/rc.d/local.
> +# This file is what is invoked by /etc/rc.d/local when given the start
> +# action.
>  #
> -# It is intended to be edited locally to add site-specific boot-time
> -# actions, such as starting locally installed daemons.
> +# So actions declared here will take place in the boot process at the 
> +# place assigned by rcorder(8) to /etc/rc.d/local, that is relatively 
> +# late in the booting process.
>  #
> -# An alternative option is to create site-specific /etc/rc.d scripts.
> +# It is intended to be edited locally to add site-specific user
> +# interface tuning, such as audio output etc. but is not limited to
> +# that.
> +#
> +# While you can add local daemons here, it is better practice to use
> +# the rc framework since, as mentioned above, this file will be treated
> +# at a time matching /etc/rc.d/local requisites, and this order may or 
> +# may not match your daemons requisites.
> +# Furthermore, by placing rc compliant scripts in /etc/rc.d.local/,
> +# local services will be cleanly and in the correct order stopped by
> +# the rc framework when shutdown(8) is used.
> +#
> +# The sibling file /etc/rc.shutdown.local is what is invoked by
> +# etc/rc.d/local when given the stop action (this is the case when
> +# shutdown(8) is used). So if you have decided to launch specific 
> +# services here, you might be interested in stopping them cleanly by 
> +# adding the required actions in this file.
>  #
>  
> -echo -n 'Starting local daemons:'
> +echo -n 'Starting site specific user interface tuning:'
>  
> -# Add your local daemons here.
> +# Add your tuning here
>  #
>  
> -#if [ -f /usr/pkg/etc/rc.d/apache ]; then
> -#	/usr/pkg/etc/rc.d/apache start
> -#fi
> +# audio stuff
> +#audioctl -d /dev/sound0 -w play=44100,2,16,slinear_le
> +#mixerctl -w outputs.master=191,191
> +
> +# set font to vt220iso8x16 (latin1)
> +#for device in /dev/ttyE1 /dev/ttyE2 /dev/ttyE3 /dev/ttyE4; do
> +#	wsconsctl -f $device -dw font=vt220iso8x16
> +#done
>  
> -echo '.'
> diff -ru /usr/src/etc/security ./etc/security
> --- /usr/src/etc/security	2006-11-27 15:25:25.000000000 +0100
> +++ ./etc/security	2007-03-18 13:18:35.000000000 +0100
> @@ -901,11 +901,13 @@
>  		#	/etc/raid*.conf
>  		#	/etc/rc.d/*
>  		#	/etc/rc.conf.d/*
> +		#	/etc/rc.d.local/*
>  		#
>  		echo "/etc/ifconfig.*"
>  		echo "/etc/raid*.conf"
>  		echo "/etc/rc.d/*"
>  		echo "/etc/rc.conf.d/*"
> +		echo "/etc/rc.d.local/*"
>  
>  		# Add /etc/changelist
>  		#
> diff -ru /usr/src/share/man/man5/rc.conf.5 ./share/man/man5/rc.conf.5
> --- /usr/src/share/man/man5/rc.conf.5	2006-11-27 15:29:56.000000000 +0100
> +++ ./share/man/man5/rc.conf.5	2007-03-18 14:08:48.000000000 +0100
> @@ -32,7 +32,7 @@
>  .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  .\" SUCH DAMAGE.
>  .\"
> -.Dd March 27, 2006
> +.Dd March 18, 2007
>  .Dt RC.CONF 5
>  .Os
>  .Sh NAME
> @@ -61,7 +61,7 @@
>  variables that may be set, the values to which each may be set,
>  a brief description of what each variable does, and a reference to
>  relevant manual pages.
> -Third party packages may test for additional variables.
> +Third party packages may test for additional variables. 
>  .Pp
>  Most variables are one of two types: enabling variables or flags
>  variables.
> @@ -87,9 +87,19 @@
>  reads
>  .Pa /etc/defaults/rc.conf
>  (if it is readable)
> -to obtain default values for various variables, and the end-user
> +to obtain default values for various variables and 
> +.Pa /etc/rc.defaults.local
> +(if it is readable)
> +for domain wide local various variables (including, probably, the ones
> +used for services put in
> +.Pa /etc/rc.d.local/
> +) and the end-user
>  may override these by appending appropriate entries to the end of
>  .Nm .
> +Variables set in
> +.Pa /etc/rc.defaults.local
> +shall respect the overall rc framework, but only the standard 
> +configuration is discussed below.
>  .Pp
>  .Xr rc.d 8
>  scripts that use
> diff -ru /usr/src/share/man/man8/rc.8 ./share/man/man8/rc.8
> --- /usr/src/share/man/man8/rc.8	2004-01-06 15:46:11.000000000 +0100
> +++ ./share/man/man8/rc.8	2007-03-18 14:14:45.000000000 +0100
> @@ -34,18 +34,20 @@
>  .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
>  .\" POSSIBILITY OF SUCH DAMAGE.
>  .\"
> -.Dd January 6, 2004
> +.Dd March 18, 2006
>  .Dt RC 8
>  .Os
>  .Sh NAME
>  .Nm rc ,
>  .Nm rc.shutdown ,
> -.Nm rc.d/
> +.Nm rc.d/,
> +.Nm rc.d.local/
>  .Nd startup and shutdown scripts
>  .Sh SYNOPSIS
>  .Nm rc
>  .Nm rc.shutdown
>  .Nm rc.d/
> +.Nm rc.d.local/
>  .Sh DESCRIPTION
>  .Nm
>  is the command script which controls the startup of various services,
> @@ -68,8 +70,13 @@
>  .Nm rc.d/
>  is the directory which contains various
>  .Xr sh 1
> -scripts, one for each service,
> -which are called by
> +scripts, one for each standard provided service,
> +and
> +.Nm rc.d.local/
> +is the directory which contains various
> +.Xr sh 1
> +scripts for local added services,
> +which are all called by
>  .Nm
>  at startup,
>  .Nm rc.shutdown
> @@ -91,6 +98,8 @@
>  .Sy ( rc_fast=yes ) ,
>  which prevents the
>  .Nm rc.d
> +or
> +.Nm rc.d.local
>  scripts from performing the check for already running processes
>  (thus speeding up the boot process).
>  This
> @@ -103,6 +112,9 @@
>  .Xr rcorder 8
>  to order the files in
>  .Pa /etc/rc.d/
> +and
> +.Pa /etc/rc.d.local/
> +
>  that do not have a
>  .Dq nostart
>  keyword (refer to
> @@ -135,6 +147,8 @@
>  .Xr rcorder 8
>  to order the files in
>  .Pa /etc/rc.d/
> +and
> +.Pa /etc/rc.d.local/
>  that have a
>  .Dq shutdown
>  keyword (refer to
> @@ -231,6 +245,9 @@
>  Note that this should be used extremely sparingly!
>  .El
>  .Pp
> +The following description applies as well to scripts put in
> +.Pa /etc/rc.d.local/ .
> +.Pp
>  Each script should contain
>  .Xr rcorder 8
>  keywords, especially an appropriate
> @@ -307,7 +324,9 @@
>  Startup script called by
>  .Xr init 8 .
>  .It Pa /etc/rc.d/
> -Directory containing control scripts for each service.
> +Directory containing control scripts for each standard service.
> +.It Pa /etc/rc.d.local/
> +Directory containing control scripts for each locally added service.
>  .It Pa /etc/rc.shutdown
>  Shutdown script called by
>  .Xr shutdown 8 .
> --- /usr/src/etc/rc.shutdown.local	1970-01-01 01:00:00.000000000 +0100
> +++ etc/rc.shutdown.local	2007-03-18 12:22:30.000000000 +0100
> @@ -0,0 +1,9 @@
> +#	$Id$
> +#
> +# This file is what is invoked by /etc/rc.d/local when given the stop
> +# action. This is automatically the case when shutdown(8) is used.
> +#
> +# So you can place here whatever action you may see fit when shutting
> +# down and specifically, if you have launched some services in
> +# /etc/rc.local, you can add here actions to stop them cleanly.
> +#


-- 
Thierry Laronde (Alceste) <tlaronde +AT+ polynum +dot+ com>
                 http://www.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C

--tThc/1wpZn/ma/RB
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff

diff -ur /usr/src/distrib/sets/lists/base/mi ./distrib/sets/lists/base/mi
--- /usr/src/distrib/sets/lists/base/mi	2006-11-27 15:25:18.000000000 +0100
+++ ./distrib/sets/lists/base/mi	2007-03-19 20:49:09.000000000 +0100
@@ -89,6 +89,8 @@
 ./etc/release					etc-sys-etc
 ./etc/rc.conf.d					base-sys-root
 ./etc/rc.d					base-sys-root
+./etc/rc.d.pkgsrc					base-sys-root
+./etc/rc.d.local					base-sys-root
 ./etc/skel					base-sys-root
 ./etc/sliphome					base-slip-root
 ./etc/ssh					base-sys-root
diff -ur /usr/src/etc/changelist ./etc/changelist
--- /usr/src/etc/changelist	2001-10-13 16:22:11.000000000 +0200
+++ ./etc/changelist	2007-03-19 13:23:29.000000000 +0100
@@ -10,4 +10,6 @@
 #	/etc/raid*.conf
 #	/etc/rc.d/*
 #	/etc/rc.conf.d/*
+#	/etc/rc.d.pkgsrc/*
+#	/etc/rc.d.local/*
 #
diff -ur /usr/src/etc/mtree/NetBSD.dist ./etc/mtree/NetBSD.dist
--- /usr/src/etc/mtree/NetBSD.dist	2006-05-26 14:17:03.000000000 +0200
+++ ./etc/mtree/NetBSD.dist	2007-03-19 13:20:31.000000000 +0100
@@ -42,6 +42,8 @@
 ./etc/racoon
 ./etc/rc.conf.d
 ./etc/rc.d
+./etc/rc.d.local
+./etc/rc.d.pkgsrc
 ./etc/skel
 ./etc/sliphome
 ./etc/ssh
diff -ur /usr/src/etc/rc ./etc/rc
--- /usr/src/etc/rc	2003-01-04 16:27:43.000000000 +0100
+++ ./etc/rc	2007-03-19 19:39:55.000000000 +0100
@@ -37,7 +37,9 @@
 
 date
 
-files=$(rcorder -s nostart ${rc_rcorder_flags} /etc/rc.d/*)
+files=$(rcorder -s nostart ${rc_rcorder_flags} /etc/rc.d/* \
+	/etc/rc.d.pkgsrc/* \
+	/etc/rc.d.local/*)
 
 for _rc_elem in $files; do
 	run_rc_script $_rc_elem start
diff -ur /usr/src/etc/rc.conf ./etc/rc.conf
--- /usr/src/etc/rc.conf	2000-10-14 19:01:29.000000000 +0200
+++ ./etc/rc.conf	2007-03-19 13:21:50.000000000 +0100
@@ -13,9 +13,25 @@
 	. /etc/defaults/rc.conf
 fi
 
+# Load the defaults in from /etc/rc.defaults.pkgsrc (if it's readable).
+# These can be overridden below and by default all pkgsrc services are
+# set to NO.
+#
+if [ -r /etc/rc.defaults.pkgsrc ]; then
+	. /etc/rc.defaults.pkgsrc
+fi
+
+# Load local domain wide defaults in from /etc/rc.defaults.local (if 
+# it's readable).
+# These can be overridden too below.
+#
+if [ -r /etc/rc.defaults.local ]; then
+	. /etc/rc.defaults.local
+fi
+
 # If this is not set to YES, the system will drop into single-user mode.
 #
 rc_configured=NO
 
-# Add local overrides below
+# Add site specific overrides below
 #
diff -ur /usr/src/etc/rc.local ./etc/rc.local
--- /usr/src/etc/rc.local	2002-07-23 12:48:01.000000000 +0200
+++ ./etc/rc.local	2007-03-19 20:44:10.000000000 +0100
@@ -1,22 +1,47 @@
-#	$NetBSD: rc.local,v 1.30 2002/07/23 10:48:01 wennmach Exp $
+#	$Id: rc.local,v 1.2 2007/03/19 19:44:10 tlaronde Exp $
 #	originally from: @(#)rc.local	8.3 (Berkeley) 4/28/94
 #
-# This file is (nearly) the last thing invoked by /etc/rc during a
-# normal boot, via /etc/rc.d/local.
+# This file is what is invoked by /etc/rc.d/local when given the start
+# action.
 #
-# It is intended to be edited locally to add site-specific boot-time
-# actions, such as starting locally installed daemons.
+# So actions declared here will take place in the boot process at the 
+# place assigned by rcorder(8) to /etc/rc.d/local, that is relatively 
+# late in the booting process.
 #
-# An alternative option is to create site-specific /etc/rc.d scripts.
+# It is intended to be edited locally to add site-specific user
+# interface tuning, such as audio output etc. but is not limited to
+# that.
+#
+# While you can add local daemons here, it is better practice to use
+# the rc framework since, as mentioned above, this file will be treated
+# at a time matching /etc/rc.d/local requisites, and this order may or 
+# may not match your daemons requisites.
+# Furthermore, by placing rc compliant scripts in /etc/rc.d.local/,
+# local services will be cleanly and in the correct order stopped by
+# the rc framework when shutdown(8) is used.
+#
+# The sibling file /etc/rc.shutdown.local is what is invoked by
+# etc/rc.d/local when given the stop action (this is the case when
+# shutdown(8) is used). So if you have decided to launch specific 
+# services here, you might be interested in stopping them cleanly by 
+# adding the required actions in this file.
+#
+# See rc(8) and rcorder(8) for more information.
 #
 
-echo -n 'Starting local daemons:'
+echo -n 'Starting site specific user interface tuning:'
 
-# Add your local daemons here.
+# Add your tuning here
 #
 
-#if [ -f /usr/pkg/etc/rc.d/apache ]; then
-#	/usr/pkg/etc/rc.d/apache start
-#fi
+# audio stuff
+#
+#audioctl -d /dev/sound0 -w play=44100,2,16,slinear_le
+#mixerctl -w outputs.master=191,191
+
+# set font to vt220iso8x16 (latin1)
+#
+#for device in /dev/ttyE1 /dev/ttyE2 /dev/ttyE3 /dev/ttyE4; do
+#	wsconsctl -f $device -dw font=vt220iso8x16
+#done
 
-echo '.'
diff -ur /usr/src/etc/security ./etc/security
--- /usr/src/etc/security	2006-11-27 15:25:25.000000000 +0100
+++ ./etc/security	2007-03-19 20:32:07.000000000 +0100
@@ -60,6 +60,9 @@
 PKGS=pkgs.$$
 CHANGEFILES=changefiles.$$
 SPECIALSPEC=specialspec.$$
+RC0=rc.d.$$
+RC1=rc.d.pkgsrc.$$
+RC2=rc.d.local.$$
 
 
 # migrate_file old new
@@ -901,11 +904,15 @@
 		#	/etc/raid*.conf
 		#	/etc/rc.d/*
 		#	/etc/rc.conf.d/*
+		#	/etc/rc.d.pkgsrc/*
+		#	/etc/rc.d.local/*
 		#
 		echo "/etc/ifconfig.*"
 		echo "/etc/raid*.conf"
 		echo "/etc/rc.d/*"
 		echo "/etc/rc.conf.d/*"
+		echo "/etc/rc.d.pkgsrc/*"
+		echo "/etc/rc.d.local/*"
 
 		# Add /etc/changelist
 		#
@@ -931,6 +938,35 @@
 		esac
 	done >> $CHANGEFILES
 	CHANGELIST="$CHANGEFILES $CHANGELIST"
+
+	# Since there are three directories holding rc scripts, the same
+	# basename for a service can be found in more than one directory.
+	# This may be a security concern---this can be an administration
+	# decision too. At least give the information.
+	#
+	# We do consider only services returned by rcorder(8) called with
+	# the skip `nostart' argument---as done by rc(8).
+	#
+	# rcorder(8) should not fail since it would mean that the system 
+	# will not execute any rc script on next boot. But...
+	#
+	rcorder -s nostart /etc/rc.d/* \
+		/etc/rc.d.pkgsrc/* \
+		/etc/rc.d.local/* >$OUTPUT || exit 1
+	cat $OUTPUT | sed 's,^\(.*\)/\([^/]*\)$,\2 \1,' \
+		| sort -k 1 \
+		| sed -n -e '\; /etc/rc\.d$;'w$RC0 \
+			-e '\; /etc/rc\.d\.pkgsrc$;'w$RC1 \
+			-e '\; /etc/rc\.d\.local$;'w$RC2 
+	
+	# then join by pair
+	join $RC0 $RC1 >$OUTPUT
+	join $RC0 $RC2 >>$OUTPUT
+	join $RC1 $RC2 >>$OUTPUT
+	if [ -s $OUTPUT ] ; then
+		printf "\nChecking identical service names in /etc/rc.d*:\n"
+		cat $OUTPUT | sort -k 1
+	fi
 fi
 
 # Special case backups, including the master password file and
diff -ur /usr/src/share/man/man5/rc.conf.5 ./share/man/man5/rc.conf.5
--- /usr/src/share/man/man5/rc.conf.5	2006-11-27 15:29:56.000000000 +0100
+++ ./share/man/man5/rc.conf.5	2007-03-19 13:31:02.000000000 +0100
@@ -32,7 +32,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd March 27, 2006
+.Dd March 18, 2007
 .Dt RC.CONF 5
 .Os
 .Sh NAME
@@ -61,7 +61,7 @@
 variables that may be set, the values to which each may be set,
 a brief description of what each variable does, and a reference to
 relevant manual pages.
-Third party packages may test for additional variables.
+Third party packages may test for additional variables. 
 .Pp
 Most variables are one of two types: enabling variables or flags
 variables.
@@ -87,9 +87,24 @@
 reads
 .Pa /etc/defaults/rc.conf
 (if it is readable)
-to obtain default values for various variables, and the end-user
+to obtain default values for various variables, 
+.Pa /etc/rc.defaults.pkgsrc
+(if it is readable)
+for pkgsrc added services variables and
+.Pa /etc/rc.defaults.local
+(if it is readable)
+for domain wide local various variables (including, probably, the ones
+used for services put in
+.Pa /etc/rc.d.local/
+) and the end-user
 may override these by appending appropriate entries to the end of
 .Nm .
+Variables set in
+.Pa /etc/rc.defaults.pkgsrc
+and
+.Pa /etc/rc.defaults.local
+shall respect the overall rc framework, but only the standard 
+configuration is discussed below.
 .Pp
 .Xr rc.d 8
 scripts that use
diff -ur /usr/src/share/man/man8/rc.8 ./share/man/man8/rc.8
--- /usr/src/share/man/man8/rc.8	2004-01-06 15:46:11.000000000 +0100
+++ ./share/man/man8/rc.8	2007-03-19 13:28:23.000000000 +0100
@@ -34,18 +34,22 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 6, 2004
+.Dd March 18, 2006
 .Dt RC 8
 .Os
 .Sh NAME
 .Nm rc ,
 .Nm rc.shutdown ,
-.Nm rc.d/
+.Nm rc.d/,
+.Nm rc.d.pkgsrc/,
+.Nm rc.d.local/
 .Nd startup and shutdown scripts
 .Sh SYNOPSIS
 .Nm rc
 .Nm rc.shutdown
 .Nm rc.d/
+.Nm rc.d.pkgsrc/
+.Nm rc.d.local/
 .Sh DESCRIPTION
 .Nm
 is the command script which controls the startup of various services,
@@ -68,8 +72,17 @@
 .Nm rc.d/
 is the directory which contains various
 .Xr sh 1
-scripts, one for each service,
-which are called by
+scripts, one for each standard provided service,
+.Nm rc.d.pkgsrc/
+is the directory which contains various
+.Xr sh 1
+scripts for pkgsrc added services,
+and
+.Nm rc.d.local/
+is the directory which contains various
+.Xr sh 1
+scripts for local added services,
+which are all called by
 .Nm
 at startup,
 .Nm rc.shutdown
@@ -90,7 +103,10 @@
 and enable a flag
 .Sy ( rc_fast=yes ) ,
 which prevents the
-.Nm rc.d
+.Nm rc.d,
+.Nm rc.d.pkgsrc
+or
+.Nm rc.d.local
 scripts from performing the check for already running processes
 (thus speeding up the boot process).
 This
@@ -102,7 +118,11 @@
 Invoke
 .Xr rcorder 8
 to order the files in
-.Pa /etc/rc.d/
+.Pa /etc/rc.d/ ,
+.Pa /etc/rc.d.pkgsrc/
+and
+.Pa /etc/rc.d.local/
+
 that do not have a
 .Dq nostart
 keyword (refer to
@@ -134,7 +154,10 @@
 Invoke
 .Xr rcorder 8
 to order the files in
-.Pa /etc/rc.d/
+.Pa /etc/rc.d/ ,
+.Pa /etc/rc.d.pkgsrc/
+and
+.Pa /etc/rc.d.local/
 that have a
 .Dq shutdown
 keyword (refer to
@@ -231,6 +254,11 @@
 Note that this should be used extremely sparingly!
 .El
 .Pp
+The following description applies as well to scripts put in
+.Pa /etc/rc.d.pkgsrc/ 
+and
+.Pa /etc/rc.d.local/ .
+.Pp
 Each script should contain
 .Xr rcorder 8
 keywords, especially an appropriate
@@ -307,7 +335,11 @@
 Startup script called by
 .Xr init 8 .
 .It Pa /etc/rc.d/
-Directory containing control scripts for each service.
+Directory containing control scripts for each standard service.
+.It Pa /etc/rc.d.pkgsrc/
+Directory containing control scripts for each pkgsrc added service.
+.It Pa /etc/rc.d.local/
+Directory containing control scripts for each locally added service.
 .It Pa /etc/rc.shutdown
 Shutdown script called by
 .Xr shutdown 8 .
--- /usr/src/etc/rc.shutdown.local	1970-01-01 01:00:00.000000000 +0100
+++ etc/rc.shutdown.local	2007-03-19 20:44:06.000000000 +0100
@@ -0,0 +1,11 @@
+#	$Id: rc.shutdown.local,v 1.2 2007/03/19 19:44:06 tlaronde Exp $
+#
+# This file is what is invoked by /etc/rc.d/local when given the stop
+# action. This is automatically the case when shutdown(8) is used.
+#
+# So you can place here whatever action you may see fit when shutting
+# down and specifically, if you have launched some services in
+# /etc/rc.local, you can add here actions to stop them cleanly.
+#
+# See rc(8) and rcorder(8) for more information.
+#
--- /usr/src/etc/rc.defaults.pkgsrc	1970-01-01 01:00:00.000000000 +0100
+++ etc/rc.defaults.pkgsrc	2007-03-19 20:44:02.000000000 +0100
@@ -0,0 +1,14 @@
+#	$Id: rc.defaults.pkgsrc,v 1.1 2007/03/19 19:44:02 tlaronde Exp $
+#
+# /etc/rc.defaults.pkgsrc --
+#	description of variables settings for pkgsrc added services.
+#	This file is under the responsability of the sole pkgsrc framework.
+#
+# The services shall default to NO (being explicitely launched by
+# setting them to YES in /etc/rc.conf.
+#
+# Since this file is sourced in /etc/rc.conf, a pkg_delete(8) should
+# suppress the chunk describing the settings for the deleted package.
+#
+# see rc.conf(5) for more information.
+#
--- /usr/src/etc/rc.defaults.local	1970-01-01 01:00:00.000000000 +0100
+++ etc/rc.defaults.local	2007-03-18 20:29:06.000000000 +0100
@@ -0,0 +1,12 @@
+#	$Id: rc.defaults.local,v 1.1 2007/03/18 19:29:06 tlaronde Exp $
+#
+# /etc/rc.defaults.local --
+#	default configuration for local (domain) nodes, setting variables
+#	belonging to NetBSD provided services, pkgsrc selected services
+#	and local added services placed in /etc/rc.d.local/
+#
+# This file is intended for setting a domain wide configuration, the
+# site specificities being set in /etc/rc.conf.
+#
+# see rc.conf(5) for more information.
+#

--tThc/1wpZn/ma/RB--