From owner-svn-src-all@FreeBSD.ORG Fri Oct 28 06:03:39 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0268D106564A; Fri, 28 Oct 2011 06:03:39 +0000 (UTC) (envelope-from rea@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E6CDF8FC0A; Fri, 28 Oct 2011 06:03:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p9S63cK7045253; Fri, 28 Oct 2011 06:03:38 GMT (envelope-from rea@svn.freebsd.org) Received: (from rea@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p9S63cVj045250; Fri, 28 Oct 2011 06:03:38 GMT (envelope-from rea@svn.freebsd.org) Message-Id: <201110280603.p9S63cVj045250@svn.freebsd.org> From: Eygene Ryabinkin Date: Fri, 28 Oct 2011 06:03:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226879 - head/etc/rc.d X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Oct 2011 06:03:39 -0000 Author: rea (ports committer) Date: Fri Oct 28 06:03:38 2011 New Revision: 226879 URL: http://svn.freebsd.org/changeset/base/226879 Log: 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 Modified: head/etc/rc.d/dhclient Modified: head/etc/rc.d/dhclient ============================================================================== --- head/etc/rc.d/dhclient Fri Oct 28 04:04:21 2011 (r226878) +++ head/etc/rc.d/dhclient Fri Oct 28 06:03:38 2011 (r226879) @@ -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"