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>
This commit is contained in:
Sheldon Hearn 2000-04-27 08:43:49 +00:00
parent e7fd6f003e
commit f66e7afa28
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=59674
11 changed files with 36 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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

4
etc/rc
View File

@ -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 ...

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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