From nobody@FreeBSD.org  Fri Sep 23 23:24:17 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BA748106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 23 Sep 2011 23:24:17 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 91A468FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 23 Sep 2011 23:24:17 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p8NNOGcD024451
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 23 Sep 2011 23:24:16 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p8NNOGYx024431;
	Fri, 23 Sep 2011 23:24:16 GMT
	(envelope-from nobody)
Message-Id: <201109232324.p8NNOGYx024431@red.freebsd.org>
Date: Fri, 23 Sep 2011 23:24:16 GMT
From: Dmitry Fomin <fdn@okbire.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch]  /etc/rc.d/named
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         160960
>Category:       conf
>Synopsis:       [patch]  /etc/rc.d/named
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    dougb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 23 23:30:11 UTC 2011
>Closed-Date:    Wed Jan 25 02:54:26 UTC 2012
>Last-Modified:  Wed Jan 25 02:54:26 UTC 2012
>Originator:     Dmitry Fomin
>Release:        FreeBSD 8.2-RELEASE-p2
>Organization:
OKB IRE, Russia
>Environment:
FreeBSD f1.okbire.ru 8.2-RELEASE-p2 FreeBSD 8.2-RELEASE-p2 #0: Mon Sep 19 19:44:
44 UTC 2011     fnd@f1.okbire.ru:/usr/obj/usr/src/sys/F1  i386                  
>Description:
If in a random way to commit an error in /var/named/etc/namedb/named.conf,
at which 'named' doesn't start, or to commit an error                     
in named_wait_host="local" (/etc/rc.conf),                                
then /etc/rc.d/named will work infinitely, if named_wait="YES".           
                                                                          
The computer never to boot.                                               
To avoid such situation, I offer a patch.                                 
>How-To-Repeat:
cat /etc/rc.conf        
..                     
named_enable="YES"      
..                     
named_wait="YES"        
named_wait_host="local" 
..                     
                                              
# /etc/rc.d/named start                  
Starting named.                                
        Waiting for nameserver to resolve local
        Waiting for nameserver to resolve local
        Waiting for nameserver to resolve local
        Waiting for nameserver to resolve local
        Waiting for nameserver to resolve local
..
>Fix:


Patch attached with submission follows:

--- /usr/src/etc/rc.d/named	2010-12-21 17:09:25.000000000 +0000
+++ /usr/src/etc/rc.d/named	2011-09-23 22:01:39.000000000 +0000
@@ -100,9 +100,22 @@
 	make_symlinks
 
 	if checkyesno named_wait; then
-		until ${command%/sbin/named}/bin/host $named_wait_host >/dev/null 2>&1; do
-			echo "	Waiting for nameserver to resolve $named_wait_host"
+		if [ ! -n "${named_wait_timeout}" ]; then
+			named_wait_timeout="${named_wait_timeout-10}"
+		fi
+		local timeout="${named_wait_timeout}"
+		until ${command%/sbin/named}/bin/host -W 1 $named_wait_host >/dev/null 2>&1; do
+			if [ $timeout -eq $named_wait_timeout ]; then
+				echo "	Waiting for nameserver to resolve $named_wait_host"
+				echo ""
+			fi
 			sleep 1
+			timeout=$(($timeout - 1))
+			echo -e "\033[A	Remains to wait time - ${timeout} sec."
+			if [ $timeout -le 0 ]; then
+				echo  "	Wait time (${named_wait_timeout} sec.) has effused."
+				break
+			fi
 		done
 	fi
 }

--- /usr/src/etc/defaults/rc.conf	2010-12-21 17:09:25.000000000 +0000
+++ /usr/src/etc/defaults/rc.conf	2011-09-23 18:43:44.000000000 +0000
@@ -279,6 +279,7 @@
 named_symlink_enable="YES"	# Symlink the chrooted pid file
 named_wait="NO" 		# Wait for working name service before exiting
 named_wait_host="localhost" 	# Hostname to check if named_wait is enabled
+named_wait_timeout="10"		# Timeout in seconds if named_wait is enabled
 named_auto_forward="NO" 	# Set up forwarders from /etc/resolv.conf
 named_auto_forward_only="NO" 	# Do "forward only" instead of "forward first"
 


>Release-Note:
>Audit-Trail:

From: "Dmitry N Fomin" <fdn@okbire.ru>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: conf/160960: [patch]  /etc/rc.d/named
Date: Sat, 24 Sep 2011 13:38:51 +0400

 The annoying error is corrected.
 
 begin 644 patch_v2.txt
 M+2TM("]U<W(O<W)C+V5T8R]R8RYD+VYA;65D"3(P,3`M,3(M,C$@,3<Z,#DZ
 M,C4N,#`P,#`P,#`P("LP,#`P"BLK*R`O=7-R+W-R8R]E=&,O<F,N9"]N86UE
 M9`DR,#$Q+3`Y+3(T(#`X.C4U.C(W+C`P,#`P,#`P,"`K,#`P,`I`0"`M,3`P
 M+#D@*S$P,"PR,B!`0`H@"6UA:V5?<WEM;&EN:W,*(`H@"6EF(&-H96-K>65S
 M;F\@;F%M961?=V%I=#L@=&AE;@HM"0EU;G1I;"`D>V-O;6UA;F0E+W-B:6XO
 M;F%M961]+V)I;B]H;W-T("1N86UE9%]W86ET7VAO<W0@/B]D978O;G5L;"`R
 M/B8Q.R!D;PHM"0D)96-H;R`B"5=A:71I;F<@9F]R(&YA;65S97)V97(@=&\@
 M<F5S;VQV92`D;F%M961?=V%I=%]H;W-T(@HK"0EI9B!;("UZ("(D>VYA;65D
 M7W=A:71?=&EM96]U='TB(%T[('1H96X**PD)"6YA;65D7W=A:71?=&EM96]U
 M=#TB,3`B"BL)"69I"BL)"6QO8V%L('1I;65O=70](B1[;F%M961?=V%I=%]T
 M:6UE;W5T?2(**PD)=6YT:6P@)'MC;VUM86YD)2]S8FEN+VYA;65D?2]B:6XO
 M:&]S="`M5R`Q("1N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@5&EM96]U
 M="!I;B!S96-O;F1S(&EF(&YA;65D7W=A:70@:7,@96YA8FQE9`H@;F%M961?
 M875T;U]F;W)W87)D/2).3R(@"2,@4V5T('5P(&9O<G=A<F1E<G,@9G)O;2`O
 M971C+W)E<V]L=BYC;VYF"B!N86UE9%]A=71O7V9O<G=A<F1?;VYL>3TB3D\B
 M(`DC($1O(")F;W)W87)D(&]N;'DB(&EN<W1E860@;V8@(F9O<G=A<F0@9FER
 &<W0B"B`*
 `
 end
 
 

From: "Dmitry N Fomin" <fdn@okbire.ru>
To: FreeBSD-gnats-submit@freebsd.org, freebsd-bugs@freebsd.org
Cc:  
Subject: Re: conf/160960: [patch]  /etc/rc.d/named
Date: Fri, 23 Dec 2011 00:13:21 +0300

 Somebody can confirm this problem and try patch?
 Thanks.
 
 --- /usr/src/etc/rc.d/named	2010-12-21 17:09:25.000000000 +0000
 +++ /usr/src/etc/rc.d/named	2011-09-24 08:55:27.000000000 +0000
 @@ -100,9 +100,22 @@
  	make_symlinks
  
  	if checkyesno named_wait; then
 -		until ${command%/sbin/named}/bin/host $named_wait_host >/dev/null 2>&1; do
 -			echo "	Waiting for nameserver to resolve $named_wait_host"
 +		if [ -z "${named_wait_timeout}" ]; then
 +			named_wait_timeout="10"
 +		fi
 +		local timeout="${named_wait_timeout}"
 +		until ${command%/sbin/named}/bin/host -W 1 $named_wait_host >/dev/null 2>&1; do
 +			if [ $timeout -eq $named_wait_timeout ]; then
 +				echo "	Waiting for nameserver to resolve $named_wait_host"
 +				echo ""
 +			fi
  			sleep 1
 +			timeout=$(($timeout - 1))
 +			echo -e "\033[A	Remains to wait time - ${timeout} sec."
 +			if [ $timeout -le 0 ]; then
 +				echo "	Wait time (${named_wait_timeout} sec.) has effused."
 +				break
 +			fi
  		done
  	fi
  }
 
 --- /usr/src/etc/defaults/rc.conf	2010-12-21 17:09:25.000000000 +0000
 +++ /usr/src/etc/defaults/rc.conf	2011-09-23 18:43:44.000000000 +0000
 @@ -279,6 +279,7 @@
  named_symlink_enable="YES"	# Symlink the chrooted pid file
  named_wait="NO" 		# Wait for working name service before exiting
  named_wait_host="localhost" 	# Hostname to check if named_wait is enabled
 +named_wait_timeout="10"		# Timeout in seconds if named_wait is enabled
  named_auto_forward="NO" 	# Set up forwarders from /etc/resolv.conf
  named_auto_forward_only="NO" 	# Do "forward only" instead of "forward first"
  
 
 

From: Xin Li <delphij@delphij.net>
To: fdn@okbire.ru
Cc: FreeBSD-gnats-submit@freebsd.org, freebsd-bugs@freebsd.org, 
 d@delphij.net
Subject: Re: conf/160960: [patch]  /etc/rc.d/named
Date: Thu, 22 Dec 2011 13:32:10 -0800

 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 Hi,
 
 On 12/22/11 13:13, Dmitry N Fomin wrote:
 > Somebody can confirm this problem and try patch? Thanks.
 
 I'm not quite satisfied with this version of patch -- host command
 have its own timeout rules and it's less than optimal when a computer
 stays stall for a few minutes while it says only 9 seconds.
 
 By the way this loses one functionality -- the admin wants the system
 to boot until a name service query is available, what shall he/she do?
  My suggestion would be consider a negative number as "wait forever" here.
 
 
 > --- /usr/src/etc/rc.d/named	2010-12-21 17:09:25.000000000 +0000 +++
 > /usr/src/etc/rc.d/named	2011-09-24 08:55:27.000000000 +0000 @@
 > -100,9 +100,22 @@ make_symlinks
 > 
 > if checkyesno named_wait; then -		until
 > ${command%/sbin/named}/bin/host $named_wait_host >/dev/null 2>&1;
 > do -			echo "	Waiting for nameserver to resolve $named_wait_host" +
 > if [ -z "${named_wait_timeout}" ]; then +
 > named_wait_timeout="10" +		fi +		local
 > timeout="${named_wait_timeout}" +		until
 > ${command%/sbin/named}/bin/host -W 1 $named_wait_host >/dev/null
 > 2>&1; do +			if [ $timeout -eq $named_wait_timeout ]; then +
 > echo "	Waiting for nameserver to resolve $named_wait_host" +
 > echo "" +			fi sleep 1 +			timeout=$(($timeout - 1)) +			echo -e
 > "\033[A	Remains to wait time - ${timeout} sec." +			if [ $timeout
 > -le 0 ]; then +				echo "	Wait time (${named_wait_timeout} sec.)
 > has effused." +				break +			fi done fi }
 > 
 > --- /usr/src/etc/defaults/rc.conf	2010-12-21 17:09:25.000000000
 > +0000 +++ /usr/src/etc/defaults/rc.conf	2011-09-23
 > 18:43:44.000000000 +0000 @@ -279,6 +279,7 @@ 
 > named_symlink_enable="YES"	# Symlink the chrooted pid file 
 > named_wait="NO" 		# Wait for working name service before exiting 
 > named_wait_host="localhost" 	# Hostname to check if named_wait is
 > enabled +named_wait_timeout="10"		# Timeout in seconds if
 > named_wait is enabled named_auto_forward="NO" 	# Set up forwarders
 > from /etc/resolv.conf named_auto_forward_only="NO" 	# Do "forward
 > only" instead of "forward first"
 > 
 > 
 > 
 > _______________________________________________ 
 > freebsd-bugs@freebsd.org mailing list 
 > http://lists.freebsd.org/mailman/listinfo/freebsd-bugs To
 > unsubscribe, send any mail to
 > "freebsd-bugs-unsubscribe@freebsd.org"
 
 
 - -- 
 Xin LI <delphij@delphij.net>	https://www.delphij.net/
 FreeBSD - The Power to Serve!		Live free or die
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.18 (FreeBSD)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
 iEYEARECAAYFAk7zodkACgkQOfuToMruuMBoLACfdWlpIvkFhmfjHbBlOSbMg3Sv
 R/wAnispG8cqieBl842CK2kyvsbxfUXN
 =7PnV
 -----END PGP SIGNATURE-----
State-Changed-From-To: open->closed 
State-Changed-By: dougb 
State-Changed-When: Wed Jan 25 02:52:28 UTC 2012 
State-Changed-Why:  

The named_wait option is working as designed. If you don't 
want the behavior, don't enable the option. 


Responsible-Changed-From-To: freebsd-bugs->dougb 
Responsible-Changed-By: dougb 
Responsible-Changed-When: Wed Jan 25 02:52:28 UTC 2012 
Responsible-Changed-Why:  

This is an option that I added. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=160960 
>Unformatted:
