public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH pve-manager v2] api: nodes: dns: restart postfix after changing name servers
@ 2026-11-10  9:31 Jonas Theisen
  0 siblings, 0 replies; only message in thread
From: Jonas Theisen @ 2026-11-10  9:31 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.

Use try-restart on postfix.service after writing the new settings, so
postfix is only restarted if it is running.
A failed restart only warns, since the DNS settings were already
written.

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

changes since v1:
* use postfix.service instead of postfix@-
* use try-restart instead of an is-active check plus restart
* replaced run_command with PVE::Cmd::run

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

diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index df0b2c2d..1e2a96f1 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -1671,6 +1671,10 @@ __PACKAGE__->register_method({
 
         PVE::INotify::update_file('resolvconf', $param);
 
+        # postfix copies resolv.conf into its chroot only on start; a reload does not refresh it
+        eval { PVE::Cmd::run(['systemctl', 'try-restart', 'postfix.service']) };
+        warn "failed to restart postfix - $@" if $@;
+
         return;
     },
 });
-- 
2.47.3





^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-10  9:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-10  9:31 [PATCH pve-manager v2] api: nodes: dns: restart postfix after changing name servers Jonas Theisen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal