diff options
author | rea <rea@FreeBSD.org> | 2011-10-28 06:03:38 +0000 |
---|---|---|
committer | rea <rea@FreeBSD.org> | 2011-10-28 06:03:38 +0000 |
commit | 16fb97459d6b793264dc66244bb0c411c00da89c (patch) | |
tree | d42b8d5ed9cc2bf88921902fbeab4692c7455c5a /etc | |
parent | 4650efb0c9b55940fd80ae60c58e16d0453fd96e (diff) | |
download | FreeBSD-src-16fb97459d6b793264dc66244bb0c411c00da89c.zip FreeBSD-src-16fb97459d6b793264dc66244bb0c411c00da89c.tar.gz |
Fix handling of rc_force in /etc/rc.d/dhclient
Variable 'rc_force' is accessible only at the time of rc_run_command,
so it can't be examined from the script's main code.
Spotted by: hrs
Reviewed by: hrs, des
Approved by: des
MFC after: 2 weeks
Diffstat (limited to 'etc')
-rwxr-xr-x | etc/rc.d/dhclient | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/etc/rc.d/dhclient b/etc/rc.d/dhclient index f842e12..adba369 100755 --- a/etc/rc.d/dhclient +++ b/etc/rc.d/dhclient @@ -15,9 +15,21 @@ name="dhclient" rcvar= pidfile="/var/run/${name}.${ifn}.pid" start_precmd="dhclient_prestart" +stop_precmd="dhclient_pre_check" + +# rc_force check can only be done at the run_rc_command +# time, so we're testing it in the pre* hooks. +dhclient_pre_check() +{ + if [ -z "${rc_force}" ] && ! dhcpif $ifn; then + err 1 "'$ifn' is not a DHCP-enabled interface" + fi +} dhclient_prestart() { + dhclient_pre_check + # Interface-specific flags (see rc.subr for $flags setting) specific=$(get_if_var $ifn dhclient_flags_IF) if [ -z "$flags" -a -n "$specific" ]; then @@ -38,11 +50,8 @@ load_rc_config network if [ -z $ifn ] ; then # only complain if a command was specified but no interface if [ -n "$1" ] ; then - echo 1>&2 "$0: no interface specified" - return 1 + err 1 "$0: no interface specified" fi -elif [ -z "${rc_force}" ] && ! dhcpif $ifn; then - return 1 fi run_rc_command "$1" |