From 2a7562b5ca0bc70bc5d856f4769bbbe881dbd2af Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Thu, 27 Oct 2011 20:46:30 -0700 Subject: [PATCH] https://www.virtualmin.com/node/19999 Update postfix hostname if hostname changed --- net/CHANGELOG | 2 ++ net/save_dns.cgi | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/net/CHANGELOG b/net/CHANGELOG index b666d583c..5adc2b635 100644 --- a/net/CHANGELOG +++ b/net/CHANGELOG @@ -60,3 +60,5 @@ Static IPv6 addresses and default routes on Redhat, CentOS, Fedora, Debian and U ---- Changes since 1.550 ---- The speed, link status and duplex of active ethernet interfaces is now shown on the active interfaces page. On Debian, Ubuntu, Redhat, CentOS and Fedora systems boot-time network interfaces with no IP address can now be created. You can also create network bridges that are connected to ethernet interfaces with no address, for use by virtual machines such as KVM. +---- Changes since 1.570 ---- +If Postfix is installed when the hostname is changed, the mydestination (local hostname) configuration parameter is updated too. diff --git a/net/save_dns.cgi b/net/save_dns.cgi index 1504f2d05..4718628b1 100755 --- a/net/save_dns.cgi +++ b/net/save_dns.cgi @@ -81,6 +81,20 @@ if ($in{'hosts'} && $in{'hostname'} ne $old_hostname) { } } +if (&foreign_installed("postfix") && $in{'hostname'} ne $old_hostname) { + # Update postfix mydestination too + &foreign_require("postfix"); + $mydest = &postfix::get_current_value("mydestination"); + if ($mydest eq $old_hostname) { + &postfix::lock_postfix_files(); + &postfix::set_current_value("mydestination", $in{'hostname'}); + &postfix::unlock_postfix_files(); + if (&postfix::is_postfix_running()) { + &postfix::reload_postfix(); + } + } + } + &webmin_log("dns", undef, undef, \%in); &redirect("");