Hi. In response to a complaing in the #gentoo-server channel, I've discovered that the method used to ascertain the value of the "pid-file" setting in named.conf fails under certain circumstances. In this particular case, the line was as follows (preceded by a tab): pid-file "/var/run/named/named.pid"; // location of pid file This resulted in start-stop-daemon being executed a follows: start-stop-daemon --start --quiet --pidfile /var/run/named/named.pid // location of pid file --exec /usr/sbin/named -- -u named -n 1 The method used to determine the correct value is difficult to comprehend and very hacky IMHO. Might I propose the following instead: PIDFILE=$(grep -Eo -m1 "^[^#\"]*pid\-file +\".+\" *;" ${CHROOT}/etc/bind/named.conf | cut -d\" -f2) This solves the problem as well as being cleaner and easier to understand. Perhaps the init.d scripts could benefit from improved validation/sanity checks also? Please view the excerpt from the IRC conversation I had for more information which I will attach to this bug. Thanks.
Created attachment 69577 [details] #gentoo-server_bind-issue.log An excerpt from the conversation I had with the person who experienced the problem. Some additional points are raised which may be worth considering within the context of this bug.
Created attachment 69578 [details] #gentoo-server-bind-issue.log Oops, 2 lines were missing in the previous attachment.
fixed in 9.3.1-r5 and 9.2.5-r7 thanks, Kerin
Sorry Konstantin, this is a harder problem at first than it appears and the method I suggested wasn't quite yet up to scratch. The main issue is that it penalises lines that have the # and " chars used in what could be a potentially legitimate context. For example, consider a line as thus: someoption="#foo#"; pid-file="bar"; // Comment Also it appeared to be flaky when no indentation was used. Now I've just tested an alternative with various permutations and I'm quite sure that I've nailed it this time! I tried hard to get it all into one grep expression but in this case I think that splitting it into two makes more sense (where the first pass deals with commented lines): egrep -v "^([[:cntrl:] ]+#|#)" /etc/bind/named.conf \ | egrep -o -m1 "pid\-file +\".+\" *;" \ | cut -d\" -f2 The [[:cntrl:]] class is used to workaround the fact that we can't use \t to match tabs and is quite acceptable in this case I think. So first we filter out lines that begin with a hash, allowing for any amount of preceding whitespace. Then we just grab a `pid-file "foo";` type statement from the first matching line but this time without caring whereabouts in the line it occurs (seeing as commented lines have already been filtered out). It does allow for valid whitespace within that statement though. Please confirm as working and apply :)
Obviously, I forgot to prepend ${CHROOT} to the file path as well in my previous comment ;)
/me sighs and remembers that named.conf supports no less than 3 comment styles (/* */, //, #). Fixed: egrep -v "^([[:cntrl:] ]+(#|//|/\*)|(#|//|/\*))" ${CHROOT}/etc/bind/named.conf | egrep -o -m1 "pid\-file +\".+\" *;" \ | cut -d\" -f2 It won't deal with lines in the following format: foo="bar"; // pid-file="baz"; To address that would take some serious voodoo and I don't think it's worth it. So the above is my final proposition.
uhh, yet another bump.. :-) fixed in 9.3.1-r6 and 9.2.5-r8 thanks again, Kerin
I've installed net-dns/bind-9.3.1-r6 (using chroot) and i have problemes when stopping/reloading. I have changed /etc/init.d/named to get it work: line 48: start-stop-daemon --stop --quiet --pidfile ${CHROOT:+$CHROOT/}$PIDFILE \ line 55: if [ ! -f ${CHROOT:+$CHROOT/}$PIDFILE ]
is it reproducible after first stop and/or restart?
Yes, it is reproducable. On another server I use net-dns/bind-9.2.5-r6 and chroot works perfectly. The init.d-file of this version contains line 32: PIDFILE="${CHROOT}$PIDFILE" It is missing in the version of bind-9.3.1-r6. Adding this line this init-file fix the problem for me.
Bug #110847 is about that. But there is also another problem: if pid-file is not specified in named.conf (or if it's specified in another file, like an included one...), the init script doesn't work.
9.2.5-r6 fixed it this way: <snip> stop() { ebegin "Stopping ${CHROOT:+chrooted }named" checkconfig || return 2 start-stop-daemon --stop --quiet --pidfile ${CHROOT}$PIDFILE \ --exec /usr/sbin/named -- stop eend $? } </snip>
*** Bug 110847 has been marked as a duplicate of this bug. ***
*** Bug 111120 has been marked as a duplicate of this bug. ***
Reopening, there are another two bugs on broken init script, still does not work correctly.
I can confirm this... With bind-9.3.1-r6 the /etc/init.d/named does not contain the fix as stated in "Additional Comment #12 From Andreas Aronsson", so it didnt work for me (the stop() function). After adding the {$CHROOT} before $PIDFILE it is working as it should.
I guess I just don't understand what kind of voodoo you guys are trying to do here. Why so complicated? this init script has served me perfectly from previous versions, and I simply save it and reinstall it every bind update and I never ever have a problem. And it is simplicity in itself. Why change it? Unless there are issues I am not aware of, I live by 'if it ain't broke don't fix it'. # $Header: /var/cvsroot/gentoo-x86/net-dns/bind/files/named.rc,v 1.1 2005/08/03 16:54:38 voxus Exp $
(In reply to comment #17) > I guess I just don't understand what kind of voodoo you guys are trying to do > here. Why so complicated? I guess we'd like to install a *working* init script, that's all. So no voodoo. ;p
Then why not just go back to a previous version of the script that worked fine? Like I said I don't know the reasons why attempted changes from a seemingly working script were started, but.. if it was just to 'improve it' then I vote for going backward:) if there was a problem that only showed under certain circumstances then.... im all wet :) I only know the version of the init i have been using has worked perfectly for me.
What about allowing /etc/conf.d/named to specify PIDFILE? If the $PIDFILE is not set there, try some heuristics (e.g. various proposed greps here). If these fails (i.e. the output is not correct), use "/var/run/named/named.pid" as default. Or maybe just drop the heuristics completely and use /etc/conf.d/named + default value?
(In reply to comment #20) > > Or maybe just drop the heuristics completely and use /etc/conf.d/named + default > value? This has been the traditional way since forever. Below is a working init script from the past that has served me very well with never an error of any kind whether I specify a pid in named.conf or don't. Mostly everyone I have ever dealt with in any kind of support or tech capacity do not specify a pid in named.conf but use the default and in the past 3 years I have never run across anyone attempting to define it differently. #!/sbin/runscript # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/net-dns/bind/files/named.rc,v 1.1 2005/08/03 16:54:38 voxus Exp $ opts="start stop reload restart" depend() { need net use logger provide dns } checkconfig() { if [ ! -f ${CHROOT}/etc/bind/named.conf ] ; then eerror "No ${CHROOT}/etc/bind/named.conf file exists!" fi # In case someone doesn't have $CPU set from /etc/conf.d/named if [ ! ${CPU} ] ; then CPU="1" fi # As with the named.conf test, above, there's no need # for chroot and non-chroot cases here PIDFILE=$(grep "pid-file" ${CHROOT}/etc/bind/named.conf | \ egrep -v ".*[#,//].*pid-file" | \ head -n 1 | \ sed -ne 's:.*pid-file\(.*\)\"\(.*\)\";:\2:p') [ -n "$PIDFILE" ] || PIDFILE=/var/run/named.pid PIDFILE="${CHROOT}$PIDFILE" KEY="${CHROOT}/etc/bind/rndc.key" } start() { ebegin "Starting ${CHROOT:+chrooted }named" checkconfig || return 1 start-stop-daemon --start --quiet --pidfile ${PIDFILE} \ --exec /usr/sbin/named \ -- -u named -n ${CPU} ${OPTIONS} ${CHROOT:+-t $CHROOT} eend $? } stop() { ebegin "Stopping ${CHROOT:+chrooted }named" checkconfig || return 2 start-stop-daemon --stop --quiet --pidfile $PIDFILE \ --exec /usr/sbin/named -- stop eend $? } reload() { checkconfig || return 3 if [ ! -f $PIDFILE ] ; then /etc/init.d/named start &>/dev/null exit fi if [ -f $KEY ] ; then ebegin "Reloading named.conf and zone files" rndc -k $KEY reload &>/dev/null eend $? else /etc/init.d/named restart &>/dev/null fi } # restart() is taken care of by runscript. I used to use one from early 2004/late 2003 but lost it in a drive death so this is the earliest one I have that works well.
fixed (by introducing PIDFILE in /etc/conf.d/named) in 9.2.5-r9, 9.3.1-r7, 9.3. 2_beta2
*** Bug 117196 has been marked as a duplicate of this bug. ***
*** Bug 117478 has been marked as a duplicate of this bug. ***