From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 85F7B8765 for ; Thu, 31 Aug 2023 13:06:58 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1EBC78EA6 for ; Thu, 31 Aug 2023 13:06:28 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 31 Aug 2023 13:06:26 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 52A0C47B07 for ; Thu, 31 Aug 2023 13:06:26 +0200 (CEST) From: Lukas Wagner To: pve-devel@lists.proxmox.com Date: Thu, 31 Aug 2023 13:06:10 +0200 Message-Id: <20230831110621.340832-1-l.wagner@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.036 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 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. [pve.rs, lib.rs, main.rs, mod.rs, sendmail.rs, email.rs, filter.rs, notify.rs, datacenterconfig.pm, pbs.rs, common.rs, context.rs, gotify.rs] Subject: [pve-devel] [PATCH many 00/11] notifications: feed system mails into proxmox_notify X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Aug 2023 11:06:58 -0000 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`. 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