From bfcba42375adb29b7fcfb3635396d745e1b9914a Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Tue, 10 Dec 2024 00:41:17 +0100 Subject: [PATCH] watchdog dnsmanagerd to powerdns: do not update invalid zones. --- deployment/primary-dnsmanagerd-to-powerdns.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/deployment/primary-dnsmanagerd-to-powerdns.sh b/deployment/primary-dnsmanagerd-to-powerdns.sh index f16aa42..cfbe7ba 100755 --- a/deployment/primary-dnsmanagerd-to-powerdns.sh +++ b/deployment/primary-dnsmanagerd-to-powerdns.sh @@ -4,6 +4,11 @@ export PATH=/bin:/sbin:/usr/bin:/usr/sbin # Copying files from the dnsmanagerd bind9 directory to the powerdns directory. PDNSDIR="/var/powerdns/" DNSMANDIR="/tmp/DATA-dnsmanagerd/bind9-zones/" +LOGFILE="/tmp/invalid-domains" + +test_domain_validity() { + named-checkzone $1 $DNSMANDIR/$1 1>/dev/null 2>/dev/null +} local_update() { echo "update domain $1" @@ -20,7 +25,12 @@ action() { echo $event | grep "MOVED_TO" >/dev/null if [ $? -eq 0 ]; then - local_update $file + test_domain_validity $file + if [ $? -eq 0 ]; then + local_update $file + else + echo "invalid domain: $file" >> $LOGFILE + fi fi echo $event | grep "DELETE" >/dev/null