1. Determine the location of the rndc* binaries relative to $command

so that when using named from the ports (or elsewhere) the proper rndc*
commands will be run.

2. Rework the stop routine using ideas from brooks and delphij.
Specifically I am duplicating a lot of code from rc.subr's stop routine
so that this one will behave more like the one in rc.subr, but use rndc
to kill the daemon (or regular kill if that fails). This also avoids
the problems related to using killall if rndc fails, which is bad if
you're running more than one named on the same box.

3. Take a concept from gshapiro and allow the rndc.key file to be
owned by root OR the named_uid user.

Although I used different solutions, this commit handles issues raised in:
PR:	conf/73929
PR:	conf/103976
PR:	conf/109409
This commit is contained in:
Doug Barton 2007-10-22 09:38:44 +00:00
parent 11bfc2922d
commit 3c9471138e

View File

@ -82,20 +82,28 @@ make_symlinks()
named_reload()
{
rndc reload
${command%/named}/rndc reload
}
named_stop()
{
echo -n "Stopping named"
if rndc stop 2>/dev/null; then
echo .
else
echo -n ": rndc failed, trying killall: "
if killall named; then
echo .
fi
# This duplicates an undesirably large amount of code from the stop
# routine in rc.subr in order to use rndc to shut down the process,
# and to give it a second chance in case rndc fails.
rc_pid=$(check_pidfile $pidfile $command)
if [ -z "$rc_pid" ]; then
[ -n "$rc_fast" ] && return 0
_run_rc_notrunning
return 1
fi
echo 'Stopping named.'
if ${command%/named}/rndc stop 2>/dev/null; then
wait_for_pids $rc_pid
else
echo -n 'rndc failed, trying kill: '
kill -TERM $rc_pid
wait_for_pids $rc_pid
fi
}
named_poststop()
@ -121,13 +129,13 @@ named_precmd()
if [ -s "${named_chrootdir}/etc/namedb/rndc.conf" ]; then
return 0
fi
confgen_command="rndc-confgen -a -b256 -u $named_uid \
confgen_command="${command%/named}/rndc-confgen -a -b256 -u $named_uid \
-c ${named_chrootdir}/etc/namedb/rndc.key"
if [ -s "${named_chrootdir}/etc/namedb/rndc.key" ]; then
if [ ! `stat -f%Su ${named_chrootdir}/etc/namedb/rndc.key` = \
"$named_uid" ]; then
$confgen_command
fi
case `stat -f%Su ${named_chrootdir}/etc/namedb/rndc.key` in
root|$named_uid) ;;
*) $confgen_command ;;
esac
else
$confgen_command
fi