mirror of
https://github.com/openwrt/packages.git
synced 2025-12-26 11:16:31 +04:00
The present logic recreates what is already the default in bind [1], and writes the rndc key twice to two different files. In addition, the rndc key is regenerated every time bind is restarted. Simplify this by relying on the default behaviour instead. [1] https://bind9.readthedocs.io/en/latest/reference.html#controls-block-definition-and-usage Signed-off-by: David Härdeman <david@hardeman.nu>
69 lines
1.5 KiB
Bash
69 lines
1.5 KiB
Bash
#!/bin/sh /etc/rc.common
|
|
# Copyright (C) 2014 Noah Meyerhans <frodo@morgul.net>
|
|
# Licensed under the terms of the GNU General Public License version 2
|
|
# or (at your discretion) any later later version
|
|
|
|
USE_PROCD=1
|
|
|
|
START=22
|
|
|
|
config_file=/etc/bind/named.conf
|
|
config_dir=$(dirname $config_file)
|
|
pid_file=/var/run/named/named.pid
|
|
|
|
rundir=$(dirname $pid_file)
|
|
logdir=/var/log/named/
|
|
cachedir=/var/cache/bind
|
|
libdir=/var/lib/bind
|
|
dyndir=/tmp/bind
|
|
|
|
conf_local_file=$dyndir/named.conf.local
|
|
|
|
fix_perms() {
|
|
for dir in $rundir $libdir $logdir $cachedir $dyndir; do
|
|
test -e "$dir" || {
|
|
mkdir -p "$dir"
|
|
chgrp bind "$dir"
|
|
chmod g+w "$dir"
|
|
}
|
|
done
|
|
}
|
|
|
|
no_ipv6() {
|
|
[ -z "$(ip -6 -o route show default)" ]
|
|
}
|
|
|
|
reload_service() {
|
|
rndc -q reload
|
|
}
|
|
|
|
start_service() {
|
|
user_exists bind 57 || user_add bind 57
|
|
group_exists bind 57 || group_add bind 57
|
|
fix_perms
|
|
|
|
local runnamed=$(dirname $pid_file)
|
|
# with dropped privileges, we need this created for us
|
|
[ -d $runnamed ] || {
|
|
mkdir -m 0755 $runnamed
|
|
chown bind.bind $runnamed
|
|
}
|
|
|
|
if [ ! -s /etc/bind/rndc.key ] && [ ! -s /etc/bind/rndc.conf ]; then
|
|
rndc-confgen -a
|
|
fi
|
|
|
|
touch $conf_local_file
|
|
|
|
local args=
|
|
no_ipv6 && args="-4"
|
|
|
|
procd_open_instance
|
|
procd_set_param command /usr/sbin/named -u bind -f $args -c $config_file
|
|
procd_set_param file $config_file \
|
|
$conf_local_file \
|
|
$config_dir/db.*
|
|
procd_set_param respawn
|
|
procd_close_instance
|
|
}
|