]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Do not run unwritable dump-file check as root
authorMichal Nowak <mnowak@isc.org>
Thu, 9 Oct 2025 16:43:25 +0000 (18:43 +0200)
committerMichal Nowak <mnowak@isc.org>
Thu, 15 Jan 2026 13:30:37 +0000 (14:30 +0100)
When run as root, the "chmod -w" command is not an effective guard
against rndc dumping the DB to file.

bin/tests/system/rndc/tests.sh

index 9ce0cb03da41a3c10c36ea98527fb2d1988910a5..0fc13eb73087a9c9870cc56b70c5f0a9282e24c9 100644 (file)
@@ -326,13 +326,17 @@ status=$((status + ret))
 
 n=$((n + 1))
 echo_i "test 'rndc dumpdb' with an unwritable dump-file ($n)"
-ret=0
-touch ns2/named_dump.db
-chmod -w ns2/named_dump.db
-rndc_dumpdb ns2 2>/dev/null && ret=1
-grep -F "failed: permission denied" "rndc.out.test$n" >/dev/null || ret=1
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=$((status + ret))
+if [ "$(id -u)" -ne 0 ]; then
+  ret=0
+  touch ns2/named_dump.db
+  chmod -w ns2/named_dump.db
+  rndc_dumpdb ns2 2>/dev/null && ret=1
+  grep -F "failed: permission denied" "rndc.out.test$n" >/dev/null || ret=1
+  if [ $ret != 0 ]; then echo_i "failed"; fi
+  status=$((status + ret))
+else
+  echo_i "skipped, running as root"
+fi
 
 n=$((n + 1))
 echo_i "test 'rndc dumpdb' on a empty cache ($n)"