Redo the initial rc_ng check to avoid rc.conf pollution occuring too early,

initdiskless may retarget /etc and various rc.conf files.  The initial check
is now done in a subshell.
Reviewed by:	Mike Makonnen <mtm@identd.net>
This commit is contained in:
Matthew Dillon 2002-12-23 07:09:44 +00:00
parent 981ab0c21b
commit cc1dfa653e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=108200

46
etc/rc
View File

@ -50,23 +50,43 @@ HOME=/
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export HOME PATH
# If there is a global system configuration file, suck it in.
# XXX - The only purpose of duplicating it here is to catch rc_ng="YES"
# check_rcng() is run in a subshell solely to determine the
# RCNG mode. We do not want to pollute our variable space
# too soon so the procedure must be run in a subshell. An
# exit code of 3 indicates RCNG is enabled.
#
if [ -r /etc/defaults/rc.conf ]; then
. /etc/defaults/rc.conf
source_rc_confs
elif [ -r /etc/rc.conf ]; then
. /etc/rc.conf
check_rcng()
{
if [ -r /etc/defaults/rc.conf ]; then
. /etc/defaults/rc.conf
source_rc_confs
elif [ -r /etc/rc.conf ]; then
. /etc/rc.conf
fi
# Diskless setups have to depend on a different mechanism since
# their config files haven't been retargeted yet.
#
[ -e /.rcng_yes ] && rc_ng="YES"
case ${rc_ng} in
[Yy][Ee][Ss])
exit 3
;;
*)
exit 0
;;
esac
}
( check_rcng )
if [ $? = 3 ]; then
rc_ng=YES
else
rc_ng=NO
fi
# Diskless setups have to depend on a different mechanism since
# their config files haven't been retargeted yet.
#
[ -e /.rcng_yes ] && rc_ng="YES"
case ${rc_ng} in
[Yy][Ee][Ss])
YES)
. /etc/rc.subr
# Note: the system configuration files are loaded as part of