Skip to content

Commit 68effae

Browse files
author
Till Brehm
committed
Fixed #5167 DKIM public key for subdomain not saved in dns
1 parent 1543ba7 commit 68effae

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

interface/web/mail/mail_domain_edit.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,11 @@ function onAfterInsert() {
312312

313313
//* create dns-record with dkim-values if the zone exists
314314
if ( $this->dataRecord['active'] == 'y' && $this->dataRecord['dkim'] == 'y' ) {
315-
$soa = $app->db->queryOneRecord("SELECT id AS zone, sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, server_id, ttl, serial FROM dns_soa WHERE active = 'Y' AND origin = ?", $this->dataRecord['domain'].'.');
315+
$soaDomain = $this->dataRecord['domain'].'.';
316+
while ((!isset($soa) && (substr_count($soaDomain,'.') > 1))) {
317+
$soa = $app->db->queryOneRecord("SELECT id AS zone, sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, server_id, ttl, serial FROM dns_soa WHERE active = 'Y' AND origin = ?", $soaDomain);
318+
$soaDomain = preg_replace("/^\w+\./","",$soaDomain);
319+
}
316320
if ( isset($soa) && !empty($soa) ) $this->update_dns($this->dataRecord, $soa);
317321
}
318322

@@ -437,7 +441,10 @@ function onAfterUpdate() {
437441
$selector = @($this->dataRecord['dkim_selector'] != $this->oldDataRecord['dkim_selector']) ? true : false;
438442
$dkim_private = @($this->dataRecord['dkim_private'] != $this->oldDataRecord['dkim_private']) ? true : false;
439443

440-
$soa = $app->db->queryOneRecord("SELECT id AS zone, sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, server_id, ttl, serial FROM dns_soa WHERE active = 'Y' AND origin = ?", $this->dataRecord['domain'].'.');
444+
while ((!isset($soa) && (substr_count($soaDomain,'.') > 1))) {
445+
$soa = $app->db->queryOneRecord("SELECT id AS zone, sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, server_id, ttl, serial FROM dns_soa WHERE active = 'Y' AND origin = ?", $soaDomain);
446+
$soaDomain = preg_replace("/^\w+\./","",$soaDomain);
447+
}
441448

442449
if ( ($selector || $dkim_private || $dkim_active) && $dkim_active )
443450
//* create a new record only if the dns-zone exists

0 commit comments

Comments
 (0)