diff --git a/net/save_dns.cgi b/net/save_dns.cgi index 876bb50be..29207db54 100755 --- a/net/save_dns.cgi +++ b/net/save_dns.cgi @@ -124,6 +124,19 @@ if (&foreign_installed("postfix") && $in{'hostname'} ne $old_hostname) { &postfix::set_current_value("mydestination", join(", ", @mydests)); } + $old_domain = $old_hostname =~ /^[^\.]+\.(.*)$/ ? $1 : + $old_fqdn =~ /^[^\.]+\.(.*)$/ ? $1 : undef; + $new_domain = $in{'hostname'} =~ /^[^\.]+\.(.*)$/ ? $1 : + $new_fqdn =~ /^[^\.]+\.(.*)$/ ? $1 : undef; + if ($old_domain && $new_domain && + lc($old_domain) ne lc($new_domain)) { + $idx = &indexoflc("localhost.$old_domain", @mydests); + if ($idx >= 0) { + $mydests[$idx] = "localhost.$new_domain"; + &postfix::set_current_value("mydestination", + join(", ", @mydests)); + } + } # Update postfix myorigin $myorigin = &postfix::get_current_value("myorigin");