summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authordougb <dougb@FreeBSD.org>2007-10-22 09:38:44 +0000
committerdougb <dougb@FreeBSD.org>2007-10-22 09:38:44 +0000
commita6a61c0d6a35a7fba7afd403d6c6dec6f097a22f (patch)
tree0598a6b5eea0d2ad8d11a02833287a264069f3f1 /etc
parentbd7bf123dce8d55fa23eabd59755bd736f8ede21 (diff)
downloadFreeBSD-src-a6a61c0d6a35a7fba7afd403d6c6dec6f097a22f.zip
FreeBSD-src-a6a61c0d6a35a7fba7afd403d6c6dec6f097a22f.tar.gz
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
Diffstat (limited to 'etc')
-rwxr-xr-xetc/rc.d/named36
1 files changed, 22 insertions, 14 deletions
diff --git a/etc/rc.d/named b/etc/rc.d/named
index bcfdd71..7466739 100755
--- a/etc/rc.d/named
+++ b/etc/rc.d/named
@@ -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
OpenPOWER on IntegriCloud