From: Lukas Wagner <l.wagner@proxmox.com>
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 [thread overview]
Message-ID: <20260409132721.272178-5-l.wagner@proxmox.com> (raw)
In-Reply-To: <20260409132721.272178-1-l.wagner@proxmox.com>
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 <l.wagner@proxmox.com>
---
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<P: AsRef<Path>>(path: P) -> Option<String> {
@@ -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
next prev parent reply other threads:[~2026-04-09 13:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 13:27 [PATCH proxmox{-backup,-mail-forward} 0/5] forward mails through notification worker; PDM compatibility Lukas Wagner
2026-04-09 13:27 ` [PATCH proxmox-backup 1/5] notifications: move spool directory to /var/lib/proxmox-backup/notifications/queue Lukas Wagner
2026-04-09 14:52 ` Arthur Bied-Charreton
2026-04-09 13:27 ` [PATCH proxmox-backup 2/5] pull in 'mail-forwarder' feature for proxmox-notify Lukas Wagner
2026-04-09 14:54 ` Arthur Bied-Charreton
2026-04-09 13:27 ` [PATCH proxmox-mail-forward 3/5] forward using PBS' notification worker Lukas Wagner
2026-04-09 15:03 ` Arthur Bied-Charreton
2026-04-09 13:27 ` Lukas Wagner [this message]
2026-04-09 15:06 ` [PATCH proxmox-mail-forward 4/5] forward mails on PDM installations as well Arthur Bied-Charreton
2026-04-09 13:27 ` [PATCH proxmox-mail-forward 5/5] only ever forward for one product, favoring PVE over PBS over PDM Lukas Wagner
2026-04-09 15:15 ` Arthur Bied-Charreton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260409132721.272178-5-l.wagner@proxmox.com \
--to=l.wagner@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox