From: Lukas Wagner <l.wagner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 many 00/11] notifications: feed system mails into proxmox_notify
Date: Mon, 2 Oct 2023 10:06:13 +0200 [thread overview]
Message-ID: <20231002080624.198759-1-l.wagner@proxmox.com> (raw)
The aim of this patch series is to adapt `proxmox-mail-forward`
so that it forwards emails that were sent to the local root user
through the `proxmox_notify` crate.
A short summary of the status quo:
Any mail that is sent to the local `root` user is forwarded by
postfix to the `proxmox-mail-forward` binary, which receives the
mail via STDIN. `proxmox-mail-forward` looks up the email address
configured for the `root@pam` user in /etc/{proxmox-backup,pve}/user.cfg
and then forwards the mail to this address by calling `sendmail`
This patch series modifies `proxmox-mail-forward` in the following way:
`proxmox-mail-forward` instantiates the configuration for `proxmox_notify`
by reading `/etc/{proxmox-backup,pve}/notifications.cfg. Also, it looks
up the policy for system mail (target/if to forward at all) in
`node.cfg/datacenter.cfg`. Following that, the mail is passed to
`proxmox_notify`, which sends it to the specified target(s).
If no target is configured/configuration files do not exist, then
the mail is forwarded using the `mail-to-root` target, which always exists.
In this way the changes should be 100% backwards compatible.
One small change in behavior can occur if PBS is co-installed on a PVE host.
Here it could happen that a mail is forwarded twice: Once for for
notification configuration for PVE, and once for the config for PBS.
Unfortunately there is no easy way to perform any useful 'deduplication'
there (by target name does not really work, since they could have different
configuration/recipients; by 'mail-address' would work for mail-based targets,
however this involves some pretty invasive changes and still does not work for
targets that are not mail-based).
Personally I feel that we should just add a section about this behavior
in the docs (once proxmox_notify is fully integrated in PBS),
instructing the user to set `system-mail` to `never` in `node.cfg`
(don't forward mails). Alternatively we could try to detect co-installations
and only forward for the target of one of both products.
However, I prefer the first option.
`proxmox-notify` now depends on a new crate `mail-parser` to parse
email headers (something I *really* don't want to implement myself
from scratch). The new dependency is not packaged yet, the necessary
debcargo-conf changes are included in the first patch.
@TESTERS: I can provide a pre-built deb for `mail-parser`.
Changelog:
- v1 -> v2:
- Rebased
- Apply the same fix for the PVE context as in [1]
[1] https://lists.proxmox.com/pipermail/pve-devel/2023-October/059294.html
debcargo-conf:
Lukas Wagner (1):
package mail-parser 0.8.2
src/mail-parser/debian/changelog | 6 ++
src/mail-parser/debian/copyright | 49 ++++++++++++
.../debian/copyright.debcargo.hint | 77 +++++++++++++++++++
src/mail-parser/debian/debcargo.toml | 2 +
4 files changed, 134 insertions(+)
create mode 100644 src/mail-parser/debian/changelog
create mode 100644 src/mail-parser/debian/copyright
create mode 100644 src/mail-parser/debian/copyright.debcargo.hint
create mode 100644 src/mail-parser/debian/debcargo.toml
proxmox:
Lukas Wagner (4):
sys: email: add `forward`
notify: introduce Error::Generic
notify: add mechanisms for email message forwarding
notify: add PVE/PBS context
Cargo.toml | 1 +
proxmox-notify/Cargo.toml | 5 +-
proxmox-notify/src/context/common.rs | 27 ++++
.../src/{context.rs => context/mod.rs} | 14 +-
proxmox-notify/src/context/pbs.rs | 130 ++++++++++++++++++
proxmox-notify/src/context/pve.rs | 82 +++++++++++
proxmox-notify/src/endpoints/gotify.rs | 21 +--
proxmox-notify/src/endpoints/sendmail.rs | 62 +++++----
proxmox-notify/src/filter.rs | 8 +-
proxmox-notify/src/lib.rs | 109 +++++++++++++--
proxmox-sys/src/email.rs | 52 ++++++-
11 files changed, 451 insertions(+), 60 deletions(-)
create mode 100644 proxmox-notify/src/context/common.rs
rename proxmox-notify/src/{context.rs => context/mod.rs} (54%)
create mode 100644 proxmox-notify/src/context/pbs.rs
create mode 100644 proxmox-notify/src/context/pve.rs
proxmox-perl-rs:
Lukas Wagner (2):
notify: construct Notification via constructor
pve-rs: notify: remove notify_context for PVE
common/src/notify.rs | 8 +--
pve-rs/Cargo.toml | 2 +-
pve-rs/src/lib.rs | 7 ++-
pve-rs/src/notify_context.rs | 117 -----------------------------------
4 files changed, 6 insertions(+), 128 deletions(-)
delete mode 100644 pve-rs/src/notify_context.rs
pve-cluster:
Lukas Wagner (1):
datacenter config: add new parameters for system mail forwarding
src/PVE/DataCenterConfig.pm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
pve-manager:
Lukas Wagner (1):
ui: notify: add system-mail settings, configuring mail forwarding
www/manager6/dc/NotificationEvents.js | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
proxmox-mail-forward:
Lukas Wagner (1):
feed forwarded mails into proxmox_notify
Cargo.toml | 8 +-
src/main.rs | 348 +++++++++++++++++++++++++++++++++++-----------------
2 files changed, 238 insertions(+), 118 deletions(-)
pve-docs:
Lukas Wagner (1):
notification: add docs for system mail forwarding
notifications.adoc | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
Summary over all repositories:
24 files changed, 899 insertions(+), 313 deletions(-)
--
murpp v0.4.0
next reply other threads:[~2023-10-02 8:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-02 8:06 Lukas Wagner [this message]
2023-10-02 8:06 ` [pve-devel] [PATCH v2 debcargo-conf 01/11] package mail-parser 0.8.2 Lukas Wagner
2023-10-20 15:36 ` [pve-devel] applied: " Thomas Lamprecht
2023-10-02 8:06 ` [pve-devel] [PATCH v2 proxmox 02/11] sys: email: add `forward` Lukas Wagner
2023-10-02 8:06 ` [pve-devel] [PATCH v2 proxmox 03/11] notify: introduce Error::Generic Lukas Wagner
2023-10-02 8:06 ` [pve-devel] [PATCH v2 proxmox 04/11] notify: add mechanisms for email message forwarding Lukas Wagner
2023-10-02 8:06 ` [pve-devel] [PATCH v2 proxmox 05/11] notify: add PVE/PBS context Lukas Wagner
2023-10-02 8:06 ` [pve-devel] [PATCH v2 proxmox-perl-rs 06/11] notify: construct Notification via constructor Lukas Wagner
2023-10-02 8:06 ` [pve-devel] [PATCH v2 proxmox-perl-rs 07/11] pve-rs: notify: remove notify_context for PVE Lukas Wagner
2023-10-02 8:06 ` [pve-devel] [PATCH v2 pve-cluster 08/11] datacenter config: add new parameters for system mail forwarding Lukas Wagner
2023-10-02 8:06 ` [pve-devel] [PATCH v2 pve-manager 09/11] ui: notify: add system-mail settings, configuring " Lukas Wagner
2023-10-02 8:06 ` [pve-devel] [PATCH v2 proxmox-mail-forward 10/11] feed forwarded mails into proxmox_notify Lukas Wagner
2023-10-02 8:06 ` [pve-devel] [PATCH v2 pve-docs 11/11] notification: add docs for system mail forwarding Lukas Wagner
2023-10-17 7:28 ` [pve-devel] [PATCH v2 many 00/11] notifications: feed system mails into proxmox_notify Lukas Wagner
2023-10-19 8:30 ` Lukas Wagner
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=20231002080624.198759-1-l.wagner@proxmox.com \
--to=l.wagner@proxmox.com \
--cc=pve-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