From 7980b8d14d47e82309d9ca8991a553578eb0bc92 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Wed, 24 Jan 2024 08:38:32 +0100 Subject: [PATCH] create empty dns-server config if no (dns-enabled) domain is determined; fixes #1230 Signed-off-by: Michael Kaufmann --- lib/Froxlor/Cron/Dns/Bind.php | 21 ++++++++++----------- lib/Froxlor/Cron/Dns/PowerDNS.php | 18 ++++++++---------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/lib/Froxlor/Cron/Dns/Bind.php b/lib/Froxlor/Cron/Dns/Bind.php index 882b3d99..9001b65e 100644 --- a/lib/Froxlor/Cron/Dns/Bind.php +++ b/lib/Froxlor/Cron/Dns/Bind.php @@ -55,18 +55,17 @@ class Bind extends DnsBase $domains = $this->getDomainList(); if (empty($domains)) { - $this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, 'No domains found for nameserver-config, skipping...'); - return; - } - - $this->bindconf_file = '# ' . Settings::Get('system.bindconf_directory') . 'froxlor_bind.conf' . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n\n"; - - foreach ($domains as $domain) { - if ($domain['is_child']) { - // domains that are subdomains to other main domains are handled by recursion within walkDomainList() - continue; + $this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, 'No domains found for nameserver-config, not creating any zones...'); + $this->bindconf_file = ''; + } else { + $this->bindconf_file = '# ' . Settings::Get('system.bindconf_directory') . 'froxlor_bind.conf' . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n\n"; + foreach ($domains as $domain) { + if ($domain['is_child']) { + // domains that are subdomains to other main domains are handled by recursion within walkDomainList() + continue; + } + $this->walkDomainList($domain, $domains); } - $this->walkDomainList($domain, $domains); } $bindconf_file_handler = fopen(FileDir::makeCorrectFile(Settings::Get('system.bindconf_directory') . '/froxlor_bind.conf'), 'w'); diff --git a/lib/Froxlor/Cron/Dns/PowerDNS.php b/lib/Froxlor/Cron/Dns/PowerDNS.php index 65fb25ca..3562b603 100644 --- a/lib/Froxlor/Cron/Dns/PowerDNS.php +++ b/lib/Froxlor/Cron/Dns/PowerDNS.php @@ -45,18 +45,16 @@ class PowerDNS extends DnsBase $this->clearZoneTables($domains); if (empty($domains)) { - $this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, 'No domains found for nameserver-config, skipping...'); - return; - } - - foreach ($domains as $domain) { - if ($domain['is_child']) { - // domains that are subdomains to other main domains are handled by recursion within walkDomainList() - continue; + $this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, 'No domains found for nameserver-config, not creating any zones...'); + } else { + foreach ($domains as $domain) { + if ($domain['is_child']) { + // domains that are subdomains to other main domains are handled by recursion within walkDomainList() + continue; + } + $this->walkDomainList($domain, $domains); } - $this->walkDomainList($domain, $domains); } - $this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, 'PowerDNS database updated'); $this->reloadDaemon(); $this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, 'Task4 finished');