Compare commits
2 Commits
5a71d5efde
...
c9b1d097c1
Author | SHA1 | Date |
---|---|---|
tracer | c9b1d097c1 | |
tracer | 6b1329eb3c |
|
@ -21,7 +21,6 @@ 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)
|
||||
|
@ -35,7 +34,6 @@ 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';
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,10 +47,22 @@ class DomainController
|
|||
|
||||
$oFile = fopen(filename: $this->localZoneFile, mode: 'w');
|
||||
foreach ($domains as $domain) {
|
||||
if (!$this->isMasterZone(domain: $domain)) {
|
||||
fputs(stream: $oFile, data: 'include "' . $this->localZonesDir . $domain->getName() . '";' . PHP_EOL);
|
||||
}
|
||||
}
|
||||
fclose(stream: $oFile);
|
||||
|
||||
exec(command: '/usr/sbin/named-checkconf', output: $output, result_code: $resultCode);
|
||||
if ($resultCode != 0) {
|
||||
echo 'There was an error:' . PHP_EOL;
|
||||
foreach ($output as $line) {
|
||||
echo $line . PHP_EOL;
|
||||
}
|
||||
echo 'You need to fix the error before the configuration can be activated.' . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
exec(command: '/usr/sbin/rndc reload');
|
||||
}
|
||||
|
||||
|
@ -118,12 +128,11 @@ class DomainController
|
|||
if (in_array(needle: $name, haystack: $members)) {
|
||||
echo "\t✅ $name" . COLOR_DEFAULT . ' is in group ' . COLOR_YELLOW . 'bind' . PHP_EOL;
|
||||
} else {
|
||||
echo "\t❌$name needs to be in group $bindGroup!" . PHP_EOL;
|
||||
|
||||
echo "\t❌$name needs to be in group " . COLOR_YELLOW . 'bind' . COLOR_DEFAULT . '!' . PHP_EOL;
|
||||
}
|
||||
|
||||
echo COLOR_DEFAULT . 'Checking ' . COLOR_YELLOW . $this->localZoneFile . PHP_EOL;
|
||||
$localZoneFilePermissions = fileperms(filename: $this->localZoneFile);
|
||||
$localZoneFilePermissions = @fileperms(filename: $this->localZoneFile);
|
||||
if ($localZoneFilePermissions & 0x0010) {
|
||||
echo COLOR_DEFAULT . "\t✅ Group has write access." . PHP_EOL;
|
||||
} else {
|
||||
|
@ -142,7 +151,7 @@ class DomainController
|
|||
}
|
||||
|
||||
echo COLOR_DEFAULT . 'Checking directory: ' . COLOR_YELLOW . $this->localZonesDir . PHP_EOL;
|
||||
$localZoneDirPermissions = fileperms(filename: $this->localZonesDir);
|
||||
$localZoneDirPermissions = @fileperms(filename: $this->localZonesDir);
|
||||
if ($localZoneDirPermissions & 0x0010) {
|
||||
echo "\t✅ Group has write access." . PHP_EOL;
|
||||
} else {
|
||||
|
@ -199,9 +208,8 @@ class DomainController
|
|||
}
|
||||
|
||||
// check if we're a master zone
|
||||
$keyhelpConf = file_get_contents(filename: $this->keyhelpNamedCond);
|
||||
if (str_contains(haystack: $keyhelpConf, needle: $domain->getName())) {
|
||||
echo 'We a zone master for ' . $domain->getName() . PHP_EOL;
|
||||
if ($this->isMasterZone(domain: $domain)) {
|
||||
echo 'We are zone master for ' . $domain->getName() . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue