From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id CD07E1FF0B4 for ; Tue, 10 Nov 2026 10:32:20 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 332FC214BE; Tue, 10 Nov 2026 10:32:17 +0100 (CET) From: Jonas Theisen To: pve-devel@lists.proxmox.com Subject: [PATCH pve-manager v2] api: nodes: dns: restart postfix after changing name servers Date: Tue, 10 Nov 2026 10:31:57 +0100 Message-ID: <20261110093204.101150-1-j.theisen@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794303130937 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.096 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: M7NH22WI3NOQHGPP2B2AVIIFYC66BZPY X-Message-ID-Hash: M7NH22WI3NOQHGPP2B2AVIIFYC66BZPY X-MailFrom: j.theisen@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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