From 627e22a2e6acc3c7228568f3b8ae874b7908f603 Mon Sep 17 00:00:00 2001 From: Daniel Reichelt Date: Sun, 7 Feb 2016 23:15:31 +0100 Subject: [PATCH 1/2] cron_tasks/bind: fix conditions for writing www records The bind cronjob awlays creates www A/AAAA records, regardless of a domain's iswildcarddomain or wwwserveralias settings. With this patch www records only get created if "www alias" is selected for a domain, i.e. iswildcarddomain is disabled and wwwserveralias is enabled. --- scripts/jobs/cron_tasks.inc.dns.10.bind.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/jobs/cron_tasks.inc.dns.10.bind.php b/scripts/jobs/cron_tasks.inc.dns.10.bind.php index 2a96e86c..93aaf601 100644 --- a/scripts/jobs/cron_tasks.inc.dns.10.bind.php +++ b/scripts/jobs/cron_tasks.inc.dns.10.bind.php @@ -333,10 +333,11 @@ class bind { } $records[] = '@'; - $records[] = 'www'; if ($domain['iswildcarddomain'] == '1') { $records[] = '*'; + } else if ($domain['wwwserveralias'] == '1') { + $records[] = 'www'; } if (!$froxlorhost) { From 427b7492dcbdecf2da987c7eea98afedbeff3b44 Mon Sep 17 00:00:00 2001 From: Daniel Reichelt Date: Mon, 8 Feb 2016 00:19:23 +0100 Subject: [PATCH 2/2] cron_tasks/bind: fix conditions for mail-related records This patch adds isemaildomain==1 as an additional condition for the creation of mx/imap/smtp/pop3/spf-txt records for a domain. For the hostname entry, this depends on the system setting dns_createmailentry. --- scripts/jobs/cron_tasks.inc.dns.10.bind.php | 60 +++++++++++---------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/scripts/jobs/cron_tasks.inc.dns.10.bind.php b/scripts/jobs/cron_tasks.inc.dns.10.bind.php index 93aaf601..4dca6537 100644 --- a/scripts/jobs/cron_tasks.inc.dns.10.bind.php +++ b/scripts/jobs/cron_tasks.inc.dns.10.bind.php @@ -76,9 +76,12 @@ class bind { $this->_known_filenames = array(); - $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"; + $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"; $result_domains_stmt = Database::query(" - SELECT `d`.`id`, `d`.`domain`, `d`.`iswildcarddomain`, `d`.`wwwserveralias`, `d`.`customerid`, `d`.`zonefile`, `d`.`bindserial`, `d`.`dkim`, `d`.`dkim_id`, `d`.`dkim_pubkey`, `c`.`loginname`, `c`.`guid` + SELECT `d`.`id`, `d`.`domain`, `d`.`isemaildomain`, `d`.`iswildcarddomain`, `d`.`wwwserveralias`, `d`.`customerid`, + `d`.`zonefile`, `d`.`bindserial`, `d`.`dkim`, `d`.`dkim_id`, `d`.`dkim_pubkey`, `c`.`loginname`, `c`.`guid` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) WHERE `d`.`isbinddomain` = '1' ORDER BY `d`.`domain` ASC "); @@ -93,6 +96,7 @@ class bind { $hostname_arr = array( 'id' => 'none', 'domain' => Settings::Get('system.hostname'), + 'isemaildomain' => Settings::Get('system.dns_createmailentry'), 'customerid' => 'none', 'loginname' => 'froxlor.panel', 'bindserial' => date('Ymd').'00', @@ -268,38 +272,40 @@ class bind { } } - if (count($this->mxservers) == 0) { - $zonefile.= '@ IN MX 10 mail' . "\n"; - $records[] = 'mail'; - if ($domain['iswildcarddomain'] != '1') { - $records[] = 'imap'; - $records[] = 'smtp'; - $records[] = 'pop3'; - } - } else { - foreach ($this->mxservers as $mxserver) { - $zonefile.= '@ IN MX ' . trim($mxserver) . "\n"; - } - - if (Settings::Get('system.dns_createmailentry') == '1') { + if ($domain['isemaildomain'] === '1') { + if (count($this->mxservers) == 0) { + $zonefile.= '@ IN MX 10 mail' . "\n"; $records[] = 'mail'; if ($domain['iswildcarddomain'] != '1') { $records[] = 'imap'; $records[] = 'smtp'; $records[] = 'pop3'; } - } - } + } else { + foreach ($this->mxservers as $mxserver) { + $zonefile.= '@ IN MX ' . trim($mxserver) . "\n"; + } - /* - * @TODO domain-based spf-settings - */ - if (Settings::Get('spf.use_spf') == '1' - /*&& $domain['spf'] == '1' */ - ) { - $zonefile.= Settings::Get('spf.spf_entry') . "\n"; - if (in_array('mail', $records)) { - $zonefile.= str_replace('@', 'mail', Settings::Get('spf.spf_entry')) . "\n"; + if (Settings::Get('system.dns_createmailentry') == '1') { + $records[] = 'mail'; + if ($domain['iswildcarddomain'] != '1') { + $records[] = 'imap'; + $records[] = 'smtp'; + $records[] = 'pop3'; + } + } + } + + /* + * @TODO domain-based spf-settings + */ + if (Settings::Get('spf.use_spf') == '1' + /*&& $domain['spf'] == '1' */ + ) { + $zonefile.= Settings::Get('spf.spf_entry') . "\n"; + if (in_array('mail', $records)) { + $zonefile.= str_replace('@', 'mail', Settings::Get('spf.spf_entry')) . "\n"; + } } }