From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 8D9991FF13F for ; Thu, 09 Apr 2026 15:26:55 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 34A3B5724; Thu, 9 Apr 2026 15:27:34 +0200 (CEST) From: Lukas Wagner To: pdm-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-mail-forward 4/5] forward mails on PDM installations as well Date: Thu, 9 Apr 2026 15:27:20 +0200 Message-ID: <20260409132721.272178-5-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260409132721.272178-1-l.wagner@proxmox.com> References: <20260409132721.272178-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1775741180663 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.053 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [main.rs] Message-ID-Hash: NEH6UEDOQQQB62EEATICTCVCPKFAVKI6 X-Message-ID-Hash: NEH6UEDOQQQB62EEATICTCVCPKFAVKI6 X-MailFrom: l.wagner@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 Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Use the same approach as for PBS installations, namely by storing the notification in a spool directory which is then later handled by a worker in the PDM proxy process. Signed-off-by: Lukas Wagner --- src/main.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main.rs b/src/main.rs index 0509cc4..92a2804 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,6 +30,10 @@ const PBS_UNPRIV_USER: &str = "backup"; const PBS_CFG_PATH: &str = "/etc/proxmox-backup"; const PBS_SPOOL_DIR: &str = "/var/lib/proxmox-backup/notifications/queue"; +const PDM_UNPRIV_USER: &str = "www-data"; +const PDM_CFG_PATH: &str = "/etc/proxmox-datacenter-manager"; +const PDM_SPOOL_DIR: &str = "/var/lib/proxmox-datacenter-manager/notifications/queue"; + /// Wrapper around `proxmox_sys::fs::file_read_optional_string` which also returns `None` upon error /// after logging it. fn attempt_file_read>(path: P) -> Option { @@ -81,6 +85,16 @@ fn forward_for_pbs(mail: &[u8]) -> Result<(), Error> { forward_via_spooldir(Path::new(PBS_SPOOL_DIR), opts, mail) } +/// Forward a mail to PDM's notification system +fn forward_for_pdm(mail: &[u8]) -> Result<(), Error> { + let unpriv_user = lookup_user(PDM_UNPRIV_USER)?; + let opts = CreateOptions::new() + .owner(unpriv_user.uid) + .group(unpriv_user.gid); + + forward_via_spooldir(Path::new(PDM_SPOOL_DIR), opts, mail) +} + /// Forward the email by queuing it in a spool directory. /// /// In the product, there is a worker that periodically handles enqueued notifications stored @@ -136,6 +150,13 @@ fn main() { error!("could not forward mail for Proxmox Backup Server: {err:#}"); } } + + // Assume a PDM installation if /etc/proxmox-datacenter-manager exists + if Path::new(PDM_CFG_PATH).exists() { + if let Err(err) = forward_for_pdm(&mail) { + error!("could not forward mail for Proxmox Datacenter Manager: {err:#}"); + } + } } Err(err) => { error!("could not read mail from STDIN: {err:#}") -- 2.47.3