From owner-svn-src-head@FreeBSD.ORG Fri Mar 18 12:23:21 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0415B106566B; Fri, 18 Mar 2011 12:23:21 +0000 (UTC) (envelope-from ume@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DC7478FC12; Fri, 18 Mar 2011 12:23:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2ICNKJp066579; Fri, 18 Mar 2011 12:23:20 GMT (envelope-from ume@svn.freebsd.org) Received: (from ume@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2ICNKkd066577; Fri, 18 Mar 2011 12:23:20 GMT (envelope-from ume@svn.freebsd.org) Message-Id: <201103181223.p2ICNKkd066577@svn.freebsd.org> From: Hajimu UMEMOTO Date: Fri, 18 Mar 2011 12:23:20 +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: r219739 - head/sbin/dhclient X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Mar 2011 12:23:21 -0000 Author: ume Date: Fri Mar 18 12:23:20 2011 New Revision: 219739 URL: http://svn.freebsd.org/changeset/base/219739 Log: Use resolvconf(8) to update /etc/resolv.conf. If you don't want to use resolvconf(8) to update /etc/resolv.conf, you can put resolvconf_enable="NO" into /etc/dhclient-enter-hooks. Modified: head/sbin/dhclient/dhclient-script Modified: head/sbin/dhclient/dhclient-script ============================================================================== --- head/sbin/dhclient/dhclient-script Fri Mar 18 12:18:52 2011 (r219738) +++ head/sbin/dhclient/dhclient-script Fri Mar 18 12:23:20 2011 (r219739) @@ -216,29 +216,40 @@ add_new_resolv_conf() { cat /etc/resolv.conf.tail >>$tmpres fi - # When resolv.conf is not changed actually, we don't - # need to update it. - # If /usr is not mounted yet, we cannot use cmp, then - # the following test fails. In such case, we simply - # ignore an error and do update resolv.conf. - if cmp -s $tmpres /etc/resolv.conf; then - rm -f $tmpres - return 0 - fi 2>/dev/null - - # In case (e.g. during OpenBSD installs) /etc/resolv.conf - # is a symbolic link, take care to preserve the link and write - # the new data in the correct location. + case $resolvconf_enable in + # "no", "false", "off", or "0" + [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) + # When resolv.conf is not changed actually, we don't + # need to update it. + # If /usr is not mounted yet, we cannot use cmp, then + # the following test fails. In such case, we simply + # ignore an error and do update resolv.conf. + if cmp -s $tmpres /etc/resolv.conf; then + rm -f $tmpres + return 0 + fi 2>/dev/null + + # In case (e.g. during OpenBSD installs) + # /etc/resolv.conf is a symbolic link, take + # care to preserve the link and write the new + # data in the correct location. - if [ -f /etc/resolv.conf ]; then - cat /etc/resolv.conf > /etc/resolv.conf.save - fi - cat $tmpres > /etc/resolv.conf - rm -f $tmpres + if [ -f /etc/resolv.conf ]; then + cat /etc/resolv.conf > /etc/resolv.conf.save + fi + cat $tmpres > /etc/resolv.conf + + # Try to ensure correct ownership and permissions. + chown -RL root:wheel /etc/resolv.conf + chmod -RL 644 /etc/resolv.conf + ;; - # Try to ensure correct ownership and permissions. - chown -RL root:wheel /etc/resolv.conf - chmod -RL 644 /etc/resolv.conf + *) + /sbin/resolvconf -a ${interface} < $tmpres + ;; + esac + + rm -f $tmpres return 0 fi @@ -296,6 +307,8 @@ if [ -f /etc/dhclient-enter-hooks ]; the fi fi +: ${resolvconf_enable="YES"} + case $reason in MEDIUM) eval "$IFCONFIG $interface $medium" @@ -349,9 +362,17 @@ EXPIRE|FAIL) # XXX Why add alias we just deleted above? add_new_alias if is_default_interface; then - if [ -f /etc/resolv.conf.save ]; then - cat /etc/resolv.conf.save > /etc/resolv.conf - fi + case $resolvconf_enable in + # "no", "false", "off", or "0" + [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) + if [ -f /etc/resolv.conf.save ]; then + cat /etc/resolv.conf.save > /etc/resolv.conf + fi + ;; + *) + /sbin/resolvconf -d ${interface} + ;; + esac fi ;;