Date: Fri, 5 Jul 2002 11:50:04 -0700 (PDT) From: Jonathan Chen <jon@FreeBSD.org> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/38778: dhclient infinite loop on ro /etc/resolv.conf Message-ID: <200207051850.g65Io41K072910@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/38778; it has been noted by GNATS.
From: Jonathan Chen <jon@FreeBSD.org>
To: Volker Stolz <stolz@i2.informatik.rwth-aachen.de>
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200207051850.g65Io41K072910>
