public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox v2 0/5] sys: email: always format 'Date' header with C locale
@ 2023-12-11 13:29 Lukas Wagner
  2023-12-11 13:29 ` [pbs-devel] [PATCH proxmox v2 1/5] time: posix: use strftime from the `libc` crate Lukas Wagner
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Lukas Wagner @ 2023-12-11 13:29 UTC (permalink / raw)
  To: pve-devel, pbs-devel

This patch series makes the formatting of the 'Date' header for sent emails
independent of the system locale. Previously, strftime was used to generate
the header, but since this function is locale-aware, invalid Date headers
could be generated.
As an example, if the locale was `de_DE.UTF-8`, then 

Date: Di, 05 Dez 2023 12:05:50 +0100
 instead of  
Date: Tue, 05 Dec 2023 12:05:50 +0100

would be generated, violating RFC2822 [1]. This trips up some email clients 
(e.g. KMail), making them fall back to Jan 1970 (epoch 0).

This is fixed by adding `strftime_l`, which allows passing a locale to
used. Additionally, `epoch_to_rfc2822` was added, which formats a 
unix epoch value to a valid RFC2822 date string (with a fixed "C" locale).

Popped up in our forum:
https://forum.proxmox.com/threads/pve-mail-notification-kein-datum-mehr-zum-korrekten-einsortieren.137556

The following projects need to be bumped and rebuilt:
  - proxmox_sys, and therefore
      - proxmox_notify, and therefore
          - libpve-rs-perl 
          - proxmox-mail-forward
      - proxmox-backup (uses proxmox_sys::email::sendmail directly)

[1] https://www.rfc-editor.org/rfc/rfc2822#section-3.3

Changes v1 -> v2:
 - Fix TZ-dependent test case

Lukas Wagner (5):
  time: posix: use strftime from the `libc` crate.
  time: posix: inline vars in string formatting
  time: posix: add bindings for strftime_l
  time: posix: add epoch_to_rfc2822
  sys: email: use `epoch_to_rfc2822` from proxmox_time

 proxmox-sys/src/email.rs  |   3 +-
 proxmox-time/src/posix.rs | 151 +++++++++++++++++++++++++++++++-------
 2 files changed, 126 insertions(+), 28 deletions(-)

-- 
2.39.2




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-01-08 11:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-11 13:29 [pbs-devel] [PATCH proxmox v2 0/5] sys: email: always format 'Date' header with C locale Lukas Wagner
2023-12-11 13:29 ` [pbs-devel] [PATCH proxmox v2 1/5] time: posix: use strftime from the `libc` crate Lukas Wagner
2023-12-11 13:29 ` [pbs-devel] [PATCH proxmox v2 2/5] time: posix: inline vars in string formatting Lukas Wagner
2023-12-11 13:29 ` [pbs-devel] [PATCH proxmox v2 3/5] time: posix: add bindings for strftime_l Lukas Wagner
2023-12-11 13:29 ` [pbs-devel] [PATCH proxmox v2 4/5] time: posix: add epoch_to_rfc2822 Lukas Wagner
2023-12-11 13:29 ` [pbs-devel] [PATCH proxmox v2 5/5] sys: email: use `epoch_to_rfc2822` from proxmox_time Lukas Wagner
2024-01-08 10:42 ` [pbs-devel] [PATCH proxmox v2 0/5] sys: email: always format 'Date' header with C locale Lukas Wagner
2024-01-08 11:13 ` [pbs-devel] applied-series: " Wolfgang Bumiller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal