bind: use default rndc control channel
authorDavid Härdeman <[email protected]>
Sun, 27 Jul 2025 01:02:31 +0000 (03:02 +0200)
committerNoah Meyerhans <[email protected]>
Sat, 13 Sep 2025 20:36:41 +0000 (13:36 -0700)
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 <[email protected]>
net/bind/files/bind/named.conf
net/bind/files/named.init

index ca1e02d5ca7fbe2d465787a0246cee8f8b305670..93798ea83b16084ffba3d1e7752ac8ceaa3f252d 100644 (file)
@@ -4,8 +4,6 @@ options {
        directory "/var/cache/bind";
 };
 
-include "/etc/bind/named-rndc.conf";
-
 include "/tmp/bind/named.conf.local";
 
 // prime the server with knowledge of the root servers
index d26b18ace42c494b91b2370ce4d5e3d05539b3de..f8405076ba10c5fe21736fddc8d69c8875e3f815 100644 (file)
@@ -9,8 +9,6 @@ START=22
 
 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
 
 rundir=$(dirname $pid_file)
@@ -51,25 +49,9 @@ start_service() {
        chown bind.bind $runnamed
     }
 
-    local rndc_temp=$(mktemp /tmp/rndc-confgen.XXXXXX)
-
-    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
+    if [ ! -s /etc/bind/rndc.key ] && [ ! -s /etc/bind/rndc.conf ]; then
+        rndc-confgen -a
+    fi
 
     touch $conf_local_file
 
@@ -79,7 +61,6 @@ start_service() {
     procd_open_instance
     procd_set_param command /usr/sbin/named -u bind -f $args -c $config_file
     procd_set_param file $config_file \
-                        $named_options_file \
                         $conf_local_file \
                         $config_dir/db.*
     procd_set_param respawn