named: don't leak mktemp files on reload
authorPhilip Prindeville <redacted>
Tue, 15 Mar 2022 01:52:18 +0000 (19:52 -0600)
committerRosen Penev <redacted>
Tue, 15 Mar 2022 22:20:15 +0000 (15:20 -0700)
Unless we're using "mktemp -u ..." (not recommended), it will
create the temp file as part of its safety checking.  Thus you
should only create the name (file) if you're going to use it,
and always remove it if you have created it.

Signed-off-by: Philip Prindeville <redacted>
net/bind/files/named.init

index bb13c5f5f5261482094d376db25f762eafc5a544..7c61b5e2a89f60cbf1039e56866e90d6974ffbd1 100644 (file)
@@ -12,7 +12,6 @@ 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
@@ -47,6 +46,8 @@ start_service() {
        chown bind.bind $runnamed
     }
 
+    local rndc_temp=$(mktemp /tmp/rndc-confgen.XXXXXX)
+
     rndc-confgen > $rndc_temp
 
     sed -r -n \
git clone https://git.99rst.org/PROJECT