mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-01 08:27:59 +00:00
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:
parent
e7fd6f003e
commit
f66e7afa28
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=59674
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
4
etc/rc
@ -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 ...
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user