mirror of
https://github.com/webmin/webmin.git
synced 2026-06-22 04:00:28 +01:00
Fix Postfix localhost destination after hostname domain change
- When the system hostname domain changes, update `localhost.<old-domain>` in Postfix `mydestination` to `localhost.<new-domain>`. - This sits alongside the existing hostname/FQDN updates for Postfix destinations. Previous behavior: `save_dns.cgi` only updated Postfix `mydestination` entries that exactly matched: - the old short hostname, like `host` - the old FQDN, like `host.old-domain.test` It did **not** update: - `localhost.old-domain.test` So if you changed: ```text host.old-domain.test ``` to: ```text host.new-domain.test ``` Postfix could become: ```text mydestination = host.new-domain.test, host, localhost.old-domain.test ``` After this hunk, it also updates that localhost domain entry: ```text localhost.old-domain.test ``` to: ```text localhost.new-domain.test ```
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user