diff options
author | sheldonh <sheldonh@FreeBSD.org> | 2000-04-27 08:43:49 +0000 |
---|---|---|
committer | sheldonh <sheldonh@FreeBSD.org> | 2000-04-27 08:43:49 +0000 |
commit | e9b12780388b49c05ad5f15144bbbfc94168dc89 (patch) | |
tree | 7abb09b02c45f55b7bfe0939c7836dd33fea232f | |
parent | 4ff5ca59a75f537882934263881113c1ce6f4ab6 (diff) | |
download | FreeBSD-src-e9b12780388b49c05ad5f15144bbbfc94168dc89.zip FreeBSD-src-e9b12780388b49c05ad5f15144bbbfc94168dc89.tar.gz |
Add to defaults/rc.conf a new function source_rc_confs which rc
scripts may use to source safely overrides in ${rc_conf_files}
files.
This protects users who insist on the bad practice of copying
/etc/defaults/rc.conf to /etc/rc.conf from a recursive loop
that exhausts available file descriptors.
Several people have expressed interest in breaking this function
out into its own shell script. Anyone who wants to embark on
such an undertaking would do well to study the attributed PR.
PR: 17595
Reported by: adrian
Submitted by: Doug Barton <Doug@gorean.org>
-rw-r--r-- | etc/defaults/rc.conf | 35 | ||||
-rwxr-xr-x | etc/netstart | 1 | ||||
-rwxr-xr-x | etc/pccard_ether | 1 | ||||
-rw-r--r-- | etc/rc | 4 | ||||
-rw-r--r-- | etc/rc.d/diskless | 1 | ||||
-rw-r--r-- | etc/rc.d/resolv | 1 | ||||
-rw-r--r-- | etc/rc.d/tmp | 1 | ||||
-rw-r--r-- | etc/rc.d/var | 1 | ||||
-rw-r--r-- | etc/rc.devfs | 1 | ||||
-rw-r--r-- | etc/rc.diskless2 | 1 | ||||
-rw-r--r-- | etc/rc.firewall | 1 |
11 files changed, 36 insertions, 12 deletions
diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf index dd8a03b..9ce5d1d 100644 --- a/etc/defaults/rc.conf +++ b/etc/defaults/rc.conf @@ -7,10 +7,9 @@ # instead and you will be able to update these defaults later without # spamming your local configuration information. # -# A common mistake is to copy the contents of this file into one of the -# ${rc_conf_files} files (e.g. /etc/rc.conf). That does not work, because -# this file ends up recursing on itself. The ${rc_conf_files} files should -# only contain values which override values set in this file. +# The ${rc_conf_files} files should only contain values which override +# values set in this file. This eases the upgrade path when defaults +# are changed and new features are added. # # All arguments must be in double or single quotes. # @@ -289,14 +288,26 @@ update_motd="YES" # update version info in /etc/motd (or NO) start_vinum="" # set to YES to start vinum ############################################################## -### Allow local configuration override at the very end here ## +### Define source_rc_confs, the mechanism used by /etc/rc.* ## +### scripts to source rc_conf_files overrides safely. ## ############################################################## -# -# -for i in ${rc_conf_files}; do - if [ -f $i ]; then - . $i - fi -done +if [ -z "${source_rc_confs_defined}" ]; then + source_rc_confs_defined=yes + source_rc_confs ( ) { + local i sourced_files + for i in ${rc_conf_files}; do + case ${sourced_files} in + *:$i:*) + ;; + *) + sourced_files="${sourced_files}:$i:" + if [ -r $i ]; then + . $i + fi + ;; + esac + done + } +fi diff --git a/etc/netstart b/etc/netstart index 21e67ed..041f1fe 100755 --- a/etc/netstart +++ b/etc/netstart @@ -12,6 +12,7 @@ # If there is a global system configuration file, suck it in. if [ -f /etc/defaults/rc.conf ]; then . /etc/defaults/rc.conf + source_rc_confs elif [ -f /etc/rc.conf ]; then . /etc/rc.conf fi diff --git a/etc/pccard_ether b/etc/pccard_ether index dafbc23..f725d61 100755 --- a/etc/pccard_ether +++ b/etc/pccard_ether @@ -11,6 +11,7 @@ # if [ -r /etc/defaults/rc.conf ]; then . /etc/defaults/rc.conf + source_rc_confs elif [ -r /etc/rc.conf ]; then . /etc/rc.conf fi @@ -38,6 +38,7 @@ fi # if [ -r /etc/defaults/rc.conf ]; then . /etc/defaults/rc.conf + source_rc_confs elif [ -r /etc/rc.conf ]; then . /etc/rc.conf fi @@ -500,6 +501,9 @@ fi # ---- rc.local ---- # if [ -r /etc/defaults/rc.conf ]; then # . /etc/defaults/rc.conf +# source_rc_confs +# elif [ -r /etc/rc.conf ]; then +# . /etc/rc.conf # fi # # ... additional startup conditionals ... diff --git a/etc/rc.d/diskless b/etc/rc.d/diskless index 9ccdfa8..091ed13 100644 --- a/etc/rc.d/diskless +++ b/etc/rc.d/diskless @@ -7,6 +7,7 @@ bpi="-i $4" fi /sbin/mdconfig -a -t malloc -s $1 -u $3 + /sbin/disklabel -r -w md$3 auto /sbin/newfs $bpi /dev/md$3c /sbin/mount /dev/md$3c $2 } diff --git a/etc/rc.d/resolv b/etc/rc.d/resolv index 9ccdfa8..091ed13 100644 --- a/etc/rc.d/resolv +++ b/etc/rc.d/resolv @@ -7,6 +7,7 @@ bpi="-i $4" fi /sbin/mdconfig -a -t malloc -s $1 -u $3 + /sbin/disklabel -r -w md$3 auto /sbin/newfs $bpi /dev/md$3c /sbin/mount /dev/md$3c $2 } diff --git a/etc/rc.d/tmp b/etc/rc.d/tmp index 9ccdfa8..091ed13 100644 --- a/etc/rc.d/tmp +++ b/etc/rc.d/tmp @@ -7,6 +7,7 @@ bpi="-i $4" fi /sbin/mdconfig -a -t malloc -s $1 -u $3 + /sbin/disklabel -r -w md$3 auto /sbin/newfs $bpi /dev/md$3c /sbin/mount /dev/md$3c $2 } diff --git a/etc/rc.d/var b/etc/rc.d/var index 9ccdfa8..091ed13 100644 --- a/etc/rc.d/var +++ b/etc/rc.d/var @@ -7,6 +7,7 @@ bpi="-i $4" fi /sbin/mdconfig -a -t malloc -s $1 -u $3 + /sbin/disklabel -r -w md$3 auto /sbin/newfs $bpi /dev/md$3c /sbin/mount /dev/md$3c $2 } diff --git a/etc/rc.devfs b/etc/rc.devfs index d8bb748..ffb6780 100644 --- a/etc/rc.devfs +++ b/etc/rc.devfs @@ -5,6 +5,7 @@ # if [ -r /etc/defaults/rc.conf ]; then . /etc/defaults/rc.conf + source_rc_confs elif [ -r /etc/rc.conf ]; then . /etc/rc.conf fi diff --git a/etc/rc.diskless2 b/etc/rc.diskless2 index 17b0bcb..c3069fa 100644 --- a/etc/rc.diskless2 +++ b/etc/rc.diskless2 @@ -7,6 +7,7 @@ # if [ -r /etc/defaults/rc.conf ]; then . /etc/defaults/rc.conf + source_rc_confs elif [ -r /etc/rc.conf ]; then . /etc/rc.conf fi diff --git a/etc/rc.firewall b/etc/rc.firewall index 3742880..a56cdf6 100644 --- a/etc/rc.firewall +++ b/etc/rc.firewall @@ -5,6 +5,7 @@ # 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 fi |