From 016b2e2a7885e56ee648a981938bc6ee874fa4e4 Mon Sep 17 00:00:00 2001 From: tracer Date: Mon, 21 Feb 2022 20:22:48 +0100 Subject: [PATCH] added output if not bind group member Signed-off-by: tracer --- src/Controller/DomainController.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Controller/DomainController.php b/src/Controller/DomainController.php index f0a0f33..99f07aa 100644 --- a/src/Controller/DomainController.php +++ b/src/Controller/DomainController.php @@ -21,6 +21,8 @@ class DomainController private string $localZonesDir; private string $namedConfLocalFile; private string $zoneCachePath; + private string $keyhelpNamedCond; + public function __construct(private NameserverRepository $nameserverRepository, private ApiController $checkController, private DomainRepository $domainRepository, private PanelRepository $panelRepository, private array $config, private Logger $log) { @@ -33,6 +35,7 @@ class DomainController $this->localZonesDir = '/etc/bind/zones/'; $this->namedConfLocalFile = '/etc/bind/named.conf.local'; $this->zoneCachePath = '/var/cache/bind/'; + $this-> keyhelpNamedCond = '/etc/bind/named.conf.keyhelp'; } @@ -115,6 +118,9 @@ class DomainController $members = $bindGroup['members']; if (in_array(needle: $name, haystack: $members)) { echo "\t✅ is in group 'bind" . PHP_EOL; + } else { + echo "\t❌$name needs to be in group $bindGroup!" . PHP_EOL; + } echo 'Checking file: ' . $this->localZoneFile . PHP_EOL; @@ -203,6 +209,13 @@ class DomainController $this->log->debug(message: "createZoneFile($domainName)"); } + // check if we're a master zone + $keyhelpConf = file_get_contents(filename: $this->keyhelpNamedCond); + if (str_contains($keyhelpConf, $domain->getName())) { + echo 'We a zone master for ' . $domain->getName() . PHP_EOL; + exit(1); + } + if ($zonefile = fopen(filename: $this->localZonesDir . $domain->getName(), mode: 'w')) { // TODO fixme soon $content = json_decode(json: $domain->getContent());