From owner-freebsd-bugs Fri Jul 5 11:50:13 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 549B237B400 for ; Fri, 5 Jul 2002 11:50:04 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8F1FC43E31 for ; Fri, 5 Jul 2002 11:50:04 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g65Io4JU072914 for ; Fri, 5 Jul 2002 11:50:04 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g65Io41K072910; Fri, 5 Jul 2002 11:50:04 -0700 (PDT) Date: Fri, 5 Jul 2002 11:50:04 -0700 (PDT) Message-Id: <200207051850.g65Io41K072910@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Jonathan Chen Subject: Re: bin/38778: dhclient infinite loop on ro /etc/resolv.conf Reply-To: Jonathan Chen Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR bin/38778; it has been noted by GNATS. From: Jonathan Chen To: Volker Stolz Cc: freebsd-gnats-submit@FreeBSD.org, cjm2@earthling.net Subject: Re: bin/38778: dhclient infinite loop on ro /etc/resolv.conf Date: Fri, 5 Jul 2002 14:40:57 -0400 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wed, Jun 12, 2002 at 10:24:13AM +0200, Volker Stolz wrote: > This is really fun! If you set resolv.conf immutable, > the dhclient-script will be *terminated* on issuing the > echo ... >/etc/resolv.conf, i.e. no further instructions > will be executed. The dhclient thinks the script failed > (well, it did), and tries another time :-/ > > It's also worth noting that setting 'schg' is NOT the > same as making /etc/resolv.conf ro; mounting /etc ro > should be yet another case. > > Here's how to reproduce this w/o using dhclient: > > 1) Create a small shell-script test.sh: > echo `date` >>foo > echo "done!" [snip] This is because /bin/sh likes to give up completely whenever an internal command redirection fails. I've been bitten by this more than once before. The error could easily be trapped by enclosing the offending commands in (), ie ( echo `date` >> foo ). This make /bin/sh fork a new instance and do the redirection there. This will also conveniently return a non-zero error code on failure. Please try the below patch and let me know if it works: (From -CURRENT, some manual merging may be necessary if you're running an older -STABLE) Index: dhclient-script =================================================================== RCS file: /export/ncvs/src/contrib/isc-dhcp/client/scripts/dhclient-script,v retrieving revision 1.20 diff -u -r1.20 dhclient-script - --- dhclient-script 19 Feb 2002 12:10:40 -0000 1.20 +++ dhclient-script 5 Jul 2002 18:05:06 -0000 @@ -10,10 +10,15 @@ make_resolv_conf() { if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then - - echo search $new_domain_name >/etc/resolv.conf - - for nameserver in $new_domain_name_servers; do - - echo nameserver $nameserver >>/etc/resolv.conf - - done + ( echo search $new_domain_name >/etc/resolv.conf ) + exit_status=$? + if [ $exit_status -ne 0 ]; then + $LOGGER "WARNING: Unable to update resolv.conf: Error $exit_status" + else + for nameserver in $new_domain_name_servers; do + ( echo nameserver $nameserver >>/etc/resolv.conf ) + done + fi fi } -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iEYEARECAAYFAj0l6DgACgkQwvyGqiU5Ros4iwCdFGxz/r4D3Cu1fG1NEYlo4edy 8YsAoPIygVftjfb2+barhe3cOzbRNO/R =q0mB -----END PGP SIGNATURE----- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message