From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <l.wagner@proxmox.com>
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 D1187A12A8
 for <pve-devel@lists.proxmox.com>; Fri, 10 Nov 2023 15:58:57 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 3EA1F3250
 for <pve-devel@lists.proxmox.com>; Fri, 10 Nov 2023 15:58:27 +0100 (CET)
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 <pve-devel@lists.proxmox.com>; Fri, 10 Nov 2023 15:58:26 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id F3C1447B44
 for <pve-devel@lists.proxmox.com>; Fri, 10 Nov 2023 15:58:25 +0100 (CET)
From: Lukas Wagner <l.wagner@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Fri, 10 Nov 2023 15:57:48 +0100
Message-Id: <20231110145753.809938-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.013 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
 T_SCC_BODY_TEXT_LINE    -0.01 -
Subject: [pve-devel] [PATCH v3 many 0/5] 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 <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Fri, 10 Nov 2023 14:58:57 -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.

The forwarding behavior is the following:
  - PVE installed: Use PVE's notifications.cfg
  - PBS installed: Use PBS's notifications.cfg if present. If not,
    use an empty configuration and add a default sendmail target and
    a matcher - this is needed because notifications are not yet
    integrated in PBS. In that way, the forwarding behavior is still
    the same as before on PBS (forward to root@pam via sendmail).
  - PVE/PBS co-installed: Use PVE's config *and* PBS's config. 
    If PBS's notifications.cfg does not exist, 
    a default sendmail target will *not* be added, to avoid
    forwarding the same mail twice. 
    For co-installations we assume for now that PVE has a sensible
    matcher/target config for forwarded mails.

Required patches:
  - series: 'overhaul notification system, use matchers instead of filters' [2]
  - pve-docs: 'notifications: update docs to for matcher-based notifications' [3]
  - Also, these two patches for 'proxmox' from the SMTP target series [4] are needed:
    - 'sys: email: add `forward`'
    - 'notify: add mechanisms for email message forwarding'

Changelog:
  - v1 -> v2:
    - Rebased
    - Apply the same fix for the PVE context as in [1]
  - v2 -> v3:
    - Rebased on top of matcher-based notification system:
      This simplifies proxmox-mail-forward by a great deal, since 
      notification routing is moved into the matcher. This means 
      proxmox-mail-forward does not need to read /etc/pve/datacenter.cfg
      any more to determine the target for the notification.

[1] https://lists.proxmox.com/pipermail/pve-devel/2023-October/059294.html
[2] https://lists.proxmox.com/pipermail/pve-devel/2023-November/059818.html
[3] https://lists.proxmox.com/pipermail/pve-devel/2023-November/059872.html
[4] https://lists.proxmox.com/pipermail/pve-devel/2023-November/059894.html
[5] https://lists.proxmox.com/pipermail/pve-devel/2023-November/059899.html
[6] https://lists.proxmox.com/pipermail/pve-devel/2023-November/059900.html



proxmox:

Lukas Wagner (1):
  notify: add PVE/PBS context

 proxmox-notify/Cargo.toml            |   3 +-
 proxmox-notify/src/context.rs        |  21 -----
 proxmox-notify/src/context/common.rs |  27 ++++++
 proxmox-notify/src/context/mod.rs    |  36 ++++++++
 proxmox-notify/src/context/pbs.rs    | 130 +++++++++++++++++++++++++++
 proxmox-notify/src/context/pve.rs    |  82 +++++++++++++++++
 6 files changed, 277 insertions(+), 22 deletions(-)
 delete mode 100644 proxmox-notify/src/context.rs
 create mode 100644 proxmox-notify/src/context/common.rs
 create mode 100644 proxmox-notify/src/context/mod.rs
 create mode 100644 proxmox-notify/src/context/pbs.rs
 create mode 100644 proxmox-notify/src/context/pve.rs


proxmox-perl-rs:

Lukas Wagner (1):
  pve-rs: notify: remove notify_context for PVE

 pve-rs/Cargo.toml            |   2 +-
 pve-rs/src/lib.rs            |   7 ++-
 pve-rs/src/notify_context.rs | 117 -----------------------------------
 3 files changed, 5 insertions(+), 121 deletions(-)
 delete mode 100644 pve-rs/src/notify_context.rs


proxmox-mail-forward:

Lukas Wagner (2):
  feed forwarded mails into proxmox_notify
  update d/control

 Cargo.toml     |   6 +-
 debian/control |   6 +-
 src/main.rs    | 255 +++++++++++++++++++++++--------------------------
 3 files changed, 125 insertions(+), 142 deletions(-)


pve-docs:

Lukas Wagner (1):
  notifications: add documentation for system mail forwarding

 notifications.adoc | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)


Summary over all repositories:
  13 files changed, 423 insertions(+), 285 deletions(-)

-- 
murpp v0.4.0