all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH pve-manager] api: nodes: dns: restart postfix after changing name servers
@ 2026-11-09 10:51 Jonas Theisen
  2026-11-10  8:31 ` Dominik Csapak
  2026-11-10  9:32 ` Jonas Theisen
  0 siblings, 2 replies; 4+ messages in thread
From: Jonas Theisen @ 2026-11-09 10:51 UTC (permalink / raw)
  To: pve-devel

Postfix runs its SMTP client in a chroot and copies /etc/resolv.conf
into it only when the instance starts. A running postfix therefore
keeps using the old name servers after a DNS settings change,
which can make mail delivery fail until the next restart.

Restart the postfix service after writing the new settings, but only
if it is currently active.
A failed restart only warns, since the DNS settings were already
written.

Came up in: https://forum.proxmox.com/threads/187442

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 PVE/API2/Nodes.pm | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index df0b2c2d..35078d3b 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -1671,6 +1671,17 @@ __PACKAGE__->register_method({
 
         PVE::INotify::update_file('resolvconf', $param);
 
+        # postfix copies resolv.conf into its chroot only on start, so a running instance needs a
+        # restart to use the new name servers
+        eval {
+            my $active = PVE::Tools::run_command(
+                ['systemctl', 'is-active', '--quiet', 'postfix@-'],
+                noerr => 1,
+            );
+            PVE::Tools::run_command(['systemctl', 'restart', 'postfix@-']) if $active == 0;
+        };
+        warn "failed to restart postfix - $@" if $@;
+
         return;
     },
 });
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-10  9:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-09 10:51 [PATCH pve-manager] api: nodes: dns: restart postfix after changing name servers Jonas Theisen
2026-11-10  8:31 ` Dominik Csapak
2026-11-10  9:28   ` Jonas Theisen
2026-11-10  9:32 ` Jonas Theisen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal