bind: add support for the 'rndc' utility 14184/head
authorPhilip Prindeville <philipp@redfish-solutions.com>
Wed, 9 Dec 2020 19:26:42 +0000 (12:26 -0700)
committerPhilip Prindeville <philipp@redfish-solutions.com>
Sun, 13 Dec 2020 20:31:13 +0000 (13:31 -0700)
Enable the control port on named that rncd uses to talk to it. Use
rndc to allow for lightweight reloads of some (per-zone) or all of
the database without an interruption of service.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
net/bind/Makefile
net/bind/files/bind/named.conf.example
net/bind/files/named.init

index 7470fcb6e9141390fa475e28b929a84c090a5e46..31d66be380f8c8367336804a4b69e0aa953fe402 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=bind
 PKG_VERSION:=9.16.8
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 USERID:=bind=57:bind=57
 
 PKG_MAINTAINER:=Noah Meyerhans <frodo@morgul.net>
index 162454955244c699e94d2690b6ab63c035e92bfa..0f26269197faf2e17fc959f9b5ebf5000e34dd12 100644 (file)
@@ -15,6 +15,8 @@ options {
        auth-nxdomain no;    # conform to RFC1035
 };
 
+include "/etc/bind/named-rndc.conf";
+
 // prime the server with knowledge of the root servers
 zone "." {
        type hint;
index b7876d9e1d8c9bb74583b2d61df01bb05e499dfb..db505e31c67482c7b054af8138e8c3a09752b379 100644 (file)
@@ -8,7 +8,11 @@ USE_PROCD=1
 START=50
 
 config_file=/etc/bind/named.conf
+config_dir=$(dirname $config_file)
+named_options_file=/etc/bind/named-rndc.conf
+rndc_conf_file=/etc/bind/rndc.conf
 pid_file=/var/run/named/named.pid
+rndc_temp=$(mktemp /tmp/rndc-confgen.XXXXXX)
 
 logdir=/var/log/named/
 cachedir=/var/cache/bind
@@ -24,12 +28,39 @@ fix_perms() {
     done
 }
 
+reload_service() {
+    rndc reload
+}
+
 start_service() {
     user_exists bind 57 || user_add bind 57
     group_exists bind 57 || group_add bind 57
     fix_perms
+
+    rndc-confgen > $rndc_temp
+
+    sed -r -n \
+       -e '/^# options \{$/,/^\};$/{ s/^/# / }' \
+       -e p \
+       -e '/^# End of rndc\.conf$/q' \
+       < $rndc_temp > $rndc_conf_file
+
+    sed -r -n \
+       -e '1,/^# End of rndc\.conf$/ { b done }' \
+       -e '/^# Use with the following in named.conf/ { p ; b done }' \
+       -e '/^# End of named\.conf$/ { p ; b done }' \
+       -e '/^# key /,$ { s/^# // ; p }' \
+       -e ': done' \
+       < $rndc_temp > $named_options_file
+
+    rm -f $rndc_temp
+
     procd_open_instance
     procd_set_param command /usr/sbin/named -u bind -f -c $config_file
+    procd_set_param file $config_file \
+                        $config_dir/bind.keys \
+                        $named_options_file \
+                        $config_dir/db.*
     procd_set_param respawn
     procd_close_instance
 }