]> git.proxmox.com Git - proxmox.git/log
proxmox.git
3 months agonotify: include 'hostname' metadata field for forwarded mails
Lukas Wagner [Wed, 13 Dec 2023 16:37:40 +0000 (17:37 +0100)]
notify: include 'hostname' metadata field for forwarded mails

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
3 months agonotify: add separate context for unit-tests
Lukas Wagner [Wed, 10 Jan 2024 09:31:22 +0000 (10:31 +0100)]
notify: add separate context for unit-tests

... as using PVEContext for tests is brittle and annoying for some
tests.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
3 months agonotify: api: allow resetting built-in targets if used by a matcher
Lukas Wagner [Wed, 10 Jan 2024 09:31:21 +0000 (10:31 +0100)]
notify: api: allow resetting built-in targets if used by a matcher

In the 'delete'-handler targets, we check if a
target is still referenced by a matcher - if it is, we return an
error. For built-in targets, this is actually not necessary, since
'deleting' a built-in only resets it to its default settings - it will
continue to exist after that.
The user could easily trigger this if 'mail-to-root', which is
referenced by 'default-matcher' is modified and then reset to its
defaults: An error is shown, the built-in target is not reset.

This commit disables this check if it is a built-in target.

Renamed the helper 'ensure_unused' to 'ensure_safe_to_delete' in the
process.

Also fixed the tests in api::test - they were never executed due to a
faulty #[cfg] directive.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
3 months agonotify: smtp: add `Auto-Submitted` header to email body
Lukas Wagner [Wed, 10 Jan 2024 09:52:52 +0000 (10:52 +0100)]
notify: smtp: add `Auto-Submitted` header to email body

`Auto-Submitted` is defined in the rfc 5436 [1] and describes how
an automatic response (f.e. ooo replies, etc.) should behave on the
emails. When using `Auto-Submitted: auto-generated` (or any value
other than `none`) automatic replies won't be triggered.

[1]: https://www.rfc-editor.org/rfc/rfc3834.html

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
3 months agonotify: smtp: forward original message instead nesting
Lukas Wagner [Wed, 10 Jan 2024 09:52:51 +0000 (10:52 +0100)]
notify: smtp: forward original message instead nesting

For mails forwarded by `proxmox-mail-forward` to an SMTP target, the
original message was nested as a 'message/rfc822' message part.
Originally this approach was chosen to avoid having to rewrite
message headers.
Good email-clients, such as Thunderbird can display these inline.
Other, more limited clients will show these messages as an attached
.eml file, which is not really a good user experience.

This patch changes the approach for message forwarding to be more like
forwarding mails in a mail client. We create a new message and
add the original message body as a body. Additionally, we also copy
over all message headers that are relevant to correctly display the
original message body (e.g. Content-Type, Content-Transfer-Encoding)

Tested with a couple of different email messages (varying in
structure, body parts, encoding, etc.) against the following SMTP
relays:
  - gmail
  - outlook
  - our own webmail service

Originally reported in our community forum:
https://forum.proxmox.com/threads/proxmox-mail-forward-sends-mails-as-eml.137710/

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
3 months agobump proxmox-sys to 0.5.3-1
Wolfgang Bumiller [Mon, 8 Jan 2024 11:48:18 +0000 (12:48 +0100)]
bump proxmox-sys to 0.5.3-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 months agobump proxmox-time dependency to 1.1.6
Wolfgang Bumiller [Mon, 8 Jan 2024 11:17:47 +0000 (12:17 +0100)]
bump proxmox-time dependency to 1.1.6

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 months agobump proxmox-time to 1.1.6
Wolfgang Bumiller [Mon, 8 Jan 2024 11:17:16 +0000 (12:17 +0100)]
bump proxmox-time to 1.1.6

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 months agosys: email: use `epoch_to_rfc2822` from proxmox_time
Lukas Wagner [Mon, 11 Dec 2023 13:29:08 +0000 (14:29 +0100)]
sys: email: use `epoch_to_rfc2822` from proxmox_time

`strftime`'s formatting is locale-dependent. If the system locale was
set to e.g. de_DE.UTF-8, the `Date` header became invalid
(e.g Mo instead of Mon for 'Monday'), tripping up some mail clients
(e.g. KMail).

This commit should fix this by using the new `epoch_to_rfc2822`
function from proxmox_time. Under the hood, this function uses
`strftime_l` with a fixed locale (C).

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
3 months agotime: posix: add epoch_to_rfc2822
Lukas Wagner [Mon, 11 Dec 2023 13:29:07 +0000 (14:29 +0100)]
time: posix: add epoch_to_rfc2822

This is the format used in the 'Date' header in mails.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
3 months agotime: posix: add bindings for strftime_l
Lukas Wagner [Mon, 11 Dec 2023 13:29:06 +0000 (14:29 +0100)]
time: posix: add bindings for strftime_l

This variant of strftime can be provided with a locale_t, which
determines the locale used for time formatting.

A struct `Locale` was also introduced as a safe wrapper around
locale_t.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
3 months agotime: posix: inline vars in string formatting
Lukas Wagner [Mon, 11 Dec 2023 13:29:05 +0000 (14:29 +0100)]
time: posix: inline vars in string formatting

No functional changes.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
3 months agotime: posix: use strftime from the `libc` crate.
Lukas Wagner [Mon, 11 Dec 2023 13:29:04 +0000 (14:29 +0100)]
time: posix: use strftime from the `libc` crate.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
4 months agoclient: do a POST instead of PUT in `post_without_body`
Lukas Wagner [Wed, 3 Jan 2024 14:04:59 +0000 (15:04 +0100)]
client: do a POST instead of PUT in `post_without_body`

Probably a copy-paste mistake.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
4 months agobump api-macro to 1.0.7-1
Wolfgang Bumiller [Wed, 6 Dec 2023 15:02:42 +0000 (16:02 +0100)]
bump api-macro to 1.0.7-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agobump proxmox-tfa to 4.1.1
Wolfgang Bumiller [Wed, 6 Dec 2023 15:01:13 +0000 (16:01 +0100)]
bump proxmox-tfa to 4.1.1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agobump proxmox-router to 2.1.2-1
Wolfgang Bumiller [Wed, 6 Dec 2023 15:00:10 +0000 (16:00 +0100)]
bump proxmox-router to 2.1.2-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agobump proxmox-apt to 0.10.7-1
Wolfgang Bumiller [Wed, 6 Dec 2023 14:58:53 +0000 (15:58 +0100)]
bump proxmox-apt to 0.10.7-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agotfa: fix deserialize-default in TfaUser
Wolfgang Bumiller [Wed, 6 Dec 2023 13:54:46 +0000 (14:54 +0100)]
tfa: fix deserialize-default in TfaUser

Note that this was currently not deserialized anywhere, so this was
not an issue, but the api-macro now treats this as an error.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agoapi-macro: make skip_serializing_if without default an error
Wolfgang Bumiller [Wed, 6 Dec 2023 13:38:04 +0000 (14:38 +0100)]
api-macro: make skip_serializing_if without default an error

except for Option types, since this causes deserialization issues

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agoapi-macro: add VariantAttrib
Wolfgang Bumiller [Wed, 6 Dec 2023 12:53:48 +0000 (13:53 +0100)]
api-macro: add VariantAttrib

separated out of FieldAttrib without the `flatten` attribute, since we
don't support this on enum variants

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agoapi-macro: rename SerdeAttrib to FieldAttrib
Wolfgang Bumiller [Wed, 6 Dec 2023 12:52:27 +0000 (13:52 +0100)]
api-macro: rename SerdeAttrib to FieldAttrib

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agorouter: fix warning
Wolfgang Bumiller [Wed, 6 Dec 2023 13:39:44 +0000 (14:39 +0100)]
router: fix warning

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agoMerge branch 'proxmox-acme-merge'
Wolfgang Bumiller [Mon, 4 Dec 2023 10:52:39 +0000 (11:52 +0100)]
Merge branch 'proxmox-acme-merge'

5 months agobump proxmox-acme to 0.5.0
Wolfgang Bumiller [Mon, 4 Dec 2023 10:46:38 +0000 (11:46 +0100)]
bump proxmox-acme to 0.5.0

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agoadd proxmox-acme to workspace
Wolfgang Bumiller [Mon, 4 Dec 2023 10:45:00 +0000 (11:45 +0100)]
add proxmox-acme to workspace

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agoMerge branch 'proxmox-acme'
Wolfgang Bumiller [Mon, 4 Dec 2023 10:43:15 +0000 (11:43 +0100)]
Merge branch 'proxmox-acme'

5 months agodrop rustfmt.toml
Wolfgang Bumiller [Mon, 4 Dec 2023 10:42:54 +0000 (11:42 +0100)]
drop rustfmt.toml

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agodrop -rs suffix
Wolfgang Bumiller [Mon, 4 Dec 2023 10:42:42 +0000 (11:42 +0100)]
drop -rs suffix

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agomove to proxmox-acme
Wolfgang Bumiller [Mon, 4 Dec 2023 10:41:59 +0000 (11:41 +0100)]
move to proxmox-acme

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agoexpand helper function by eab credentials
Folke Gleumes [Tue, 14 Nov 2023 14:14:02 +0000 (15:14 +0100)]
expand helper function by eab credentials

Signed-off-by: Folke Gleumes <f.gleumes@proxmox.com>
5 months agoOption<Vec<>> -> Vec<>
Wolfgang Bumiller [Mon, 4 Dec 2023 09:13:46 +0000 (10:13 +0100)]
Option<Vec<>> -> Vec<>

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agoproxmox-apt: fix digest api type in APTRepositoryFile
Dietmar Maurer [Mon, 4 Dec 2023 08:39:54 +0000 (09:39 +0100)]
proxmox-apt: fix digest api type in APTRepositoryFile

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 months agoadd meta fields returned by the directory
Folke Gleumes [Tue, 14 Nov 2023 14:14:01 +0000 (15:14 +0100)]
add meta fields returned by the directory

According to the rfc, the meta field contains additional fields that
weren't covered by the Meta struct. Of the additional fields, only
external_account_required will be used in the near future, but others
were added for completeness and the case that they might be used in the
future.

Signed-off-by: Folke Gleumes <f.gleumes@proxmox.com>
5 months agoadd external account binding
Folke Gleumes [Tue, 14 Nov 2023 14:14:00 +0000 (15:14 +0100)]
add external account binding

Functionality was added as a additional setter function, which hopefully
prevents any breakages. Since a placeholder Option an the AccountData
was already present, but has never been used, replacing the field with
an Option of a fully defined type should also be minimally intrusive.

Signed-off-by: Folke Gleumes <f.gleumes@proxmox.com>
5 months agoproxmox-apt: fix serde attributes for API types
Dietmar Maurer [Sat, 2 Dec 2023 13:45:57 +0000 (14:45 +0100)]
proxmox-apt: fix serde attributes for API types

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 months agotree-wide: fix various typos
Thomas Lamprecht [Wed, 29 Nov 2023 17:32:06 +0000 (18:32 +0100)]
tree-wide: fix various typos

found with codespell

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agosys: bump to 0.5.2-1
Wolfgang Bumiller [Wed, 29 Nov 2023 14:26:04 +0000 (15:26 +0100)]
sys: bump to 0.5.2-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agosys: email: move Auto-Submitted header up
Gabriel Goller [Wed, 29 Nov 2023 14:15:11 +0000 (15:15 +0100)]
sys: email: move Auto-Submitted header up

Move the Auto-Submitted header out of the multipart section.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
5 months agosys: cleanup assigned and immediately returned var
Wolfgang Bumiller [Wed, 29 Nov 2023 13:57:18 +0000 (14:57 +0100)]
sys: cleanup assigned and immediately returned var

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agosys: add helper to get bootmode and secureboot status
Gabriel Goller [Wed, 29 Nov 2023 13:28:57 +0000 (14:28 +0100)]
sys: add helper to get bootmode and secureboot status

Helper that return the current boot_mode and secureboot status.
Detection works the same as in pve, we use `/sys/firmware/efi` and
the `efivars/SecureBoot-xxx..` file.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
5 months agobump rest-server to 0.5.1-1
Wolfgang Bumiller [Tue, 28 Nov 2023 10:32:25 +0000 (11:32 +0100)]
bump rest-server to 0.5.1-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agoproxmox-rest-server: do not use formatter for AuthErr
Dietmar Maurer [Mon, 27 Nov 2023 10:17:08 +0000 (11:17 +0100)]
proxmox-rest-server: do not use formatter for AuthErr

We want to get a 401 error at HTTP level.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agoproxmox-rest-server: return status code with ExtJsFormatter
Dietmar Maurer [Mon, 27 Nov 2023 09:09:17 +0000 (10:09 +0100)]
proxmox-rest-server: return status code with ExtJsFormatter

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agobump proxmox-auth-api to 0.3.2
Wolfgang Bumiller [Mon, 27 Nov 2023 13:39:54 +0000 (14:39 +0100)]
bump proxmox-auth-api to 0.3.2

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agobump proxmox-rest-server to 0.5.0-1
Wolfgang Bumiller [Mon, 27 Nov 2023 13:33:25 +0000 (14:33 +0100)]
bump proxmox-rest-server to 0.5.0-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agorest-server: Add `Redirector`
Max Carrara [Tue, 21 Nov 2023 10:08:45 +0000 (11:08 +0100)]
rest-server: Add `Redirector`

The `Redirector` is a simple `Service` that redirects HTTP requests
to HTTPS and can be served by a `hyper::Server`.

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agorest-server: Refactor `AcceptBuilder`, provide support for optional TLS
Max Carrara [Tue, 21 Nov 2023 10:08:44 +0000 (11:08 +0100)]
rest-server: Refactor `AcceptBuilder`, provide support for optional TLS

The new public function `accept_tls_optional()` is added, which
accepts both plain TCP streams and TCP streams running TLS. Plain TCP
streams are sent along via a separate channel in order to clearly
distinguish between "secure" and "insecure" connections.

Furthermore, instead of `AcceptBuilder` itself holding a reference to
an `SslAcceptor`, its public functions now take the acceptor as an
argument. The public functions' names are changed to distinguish
between their functionality in a more explicit manner:

  * `accept()` --> `accept_tls()`
  *        NEW --> `accept_tls_optional()`

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agosubscription: update d/control
Fabian Grünbichler [Mon, 27 Nov 2023 13:08:18 +0000 (14:08 +0100)]
subscription: update d/control

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
5 months agobump proxmox-subscription to 0.4.2-1
Fabian Grünbichler [Mon, 27 Nov 2023 12:43:10 +0000 (13:43 +0100)]
bump proxmox-subscription to 0.4.2-1

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
5 months agosubscription: expose the `next_due_date` as an `i64`
Stefan Sterz [Thu, 9 Nov 2023 15:33:59 +0000 (16:33 +0100)]
subscription: expose the `next_due_date` as an `i64`

internally `SubscriptionInfo` already uses the `parse_next_due` helper
to parse the next due date to an epoch. this exposes a function that
allows us to use the epoch outside of this crate too. for example, a
user of pom may have multiple subscription for the same system. in
that case we want to apply the one with the due date that is furthest
in the future.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
5 months agosubscription: let ProductType derive Hash
Fabian Grünbichler [Mon, 27 Nov 2023 12:59:11 +0000 (13:59 +0100)]
subscription: let ProductType derive Hash

for usage in HashMap keys

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
5 months agotype: move `ProductType` type to `proxmox-subscription` from pom
Stefan Sterz [Thu, 9 Nov 2023 15:33:58 +0000 (16:33 +0100)]
type: move `ProductType` type to `proxmox-subscription` from pom

previously this type lived inside of pom. this made it harder to
access the product type from a `SubscriptionInfo` trait in other
products. move the type here so we can check product types more
consistently across products (e. g. in pom and pbs)

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
5 months agobump tfa to 4.1.0
Wolfgang Bumiller [Thu, 23 Nov 2023 08:21:11 +0000 (09:21 +0100)]
bump tfa to 4.1.0

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agobump schema to 2.0.2-1
Wolfgang Bumiller [Thu, 23 Nov 2023 08:16:13 +0000 (09:16 +0100)]
bump schema to 2.0.2-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agoproxmox-schema: derive PartialEq for UPID (for GUI)
Dietmar Maurer [Mon, 20 Nov 2023 10:10:22 +0000 (11:10 +0100)]
proxmox-schema: derive PartialEq for UPID (for GUI)

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 months agonotify: bump version to 0.3.0-1
Thomas Lamprecht [Fri, 17 Nov 2023 07:39:09 +0000 (08:39 +0100)]
notify: bump version to 0.3.0-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agosys: bump version to 0.5.1-1
Thomas Lamprecht [Fri, 17 Nov 2023 09:40:17 +0000 (10:40 +0100)]
sys: bump version to 0.5.1-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agonotify: update d/control
Thomas Lamprecht [Fri, 17 Nov 2023 07:37:36 +0000 (08:37 +0100)]
notify: update d/control

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agosys: purge pty module
Thomas Lamprecht [Fri, 17 Nov 2023 07:35:17 +0000 (08:35 +0100)]
sys: purge pty module

it was only used in the terminal proxy and got moved there.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agonotify: add built-in config and 'origin' parameter
Lukas Wagner [Tue, 14 Nov 2023 12:59:23 +0000 (13:59 +0100)]
notify: add built-in config and 'origin' parameter

This allows us to define a (modifiable) builtin-config, which is
at the moment hardcoded in PVEContext

The 'origin' parameter indicates whether a config entry was created by
a user, builtin or a modified builtin.

These changes require context to be set for tests, so we set
PVEContext by default if in a test context. There might be a nicer
solution for that, but for now this should work.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
5 months agonotify: add 'disable' parameter for matchers and targets.
Lukas Wagner [Tue, 14 Nov 2023 12:59:22 +0000 (13:59 +0100)]
notify: add 'disable' parameter for matchers and targets.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
5 months agonotify: add api for smtp endpoints
Lukas Wagner [Tue, 14 Nov 2023 12:59:21 +0000 (13:59 +0100)]
notify: add api for smtp endpoints

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
5 months agonotify: add 'smtp' endpoint
Lukas Wagner [Tue, 14 Nov 2023 12:59:20 +0000 (13:59 +0100)]
notify: add 'smtp' endpoint

This commit adds a new endpoint type, namely 'smtp'. This endpoint
uses the `lettre` crate to directly send emails to SMTP relays.

The `lettre` crate was chosen since it is by far the most popular SMTP
implementation for Rust that looks like it is well maintained.
Also, it includes async support (for when we want to extend
proxmox-notify to be async).

For this new endpoint type, a new section-config type was introduced
(smtp). It has the same fields as the type for `sendmail`, with the
addition of some new options (smtp server, authentication, tls mode,
etc.).

Some of the behavior that is shared between sendmail and smtp
endpoints has been moved to a new `endpoints::common::mail` module.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
5 months agonotify: add PVE/PBS context
Lukas Wagner [Tue, 14 Nov 2023 12:59:19 +0000 (13:59 +0100)]
notify: add PVE/PBS context

This commit moves PVEContext from `proxmox-perl-rs` into the
`proxmox-notify` crate, since we now also need to access it from
`promxox-mail-forward`. The context is now hidden behind a feature
flag `pve-context`, ensuring that we only compile it when needed.

This commit adds PBSContext, since we now require it for
`proxmox-mail-forward`. Some of the code for PBSContext comes
from `proxmox-mail-forward`.

This commit also changes the global context from being stored in a
`once_cell` to a regular `Mutex`, since we now need to set/reset
the context in `proxmox-mail-forward`.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
5 months agonotify: add mechanisms for email message forwarding
Lukas Wagner [Tue, 14 Nov 2023 12:59:18 +0000 (13:59 +0100)]
notify: add mechanisms for email message forwarding

As preparation for the integration of `proxmox-mail-foward` into the
notification system, this commit makes a few changes that allow us to
forward raw email messages (as passed from postfix).

For mail-based notification targets, the email will be forwarded
as-is, including all headers. The only thing that changes is the
message envelope.
For other notification targets, the mail is parsed using the
`mail-parser` crate, which allows us to extract a subject and a body.
As a body we use the plain-text version of the mail. If an email is
HTML-only, the `mail-parser` crate will automatically attempt to
transform the HTML into readable plain text.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
5 months agosys: email: add `forward`
Lukas Wagner [Tue, 14 Nov 2023 12:59:17 +0000 (13:59 +0100)]
sys: email: add `forward`

This new function forwards an email to new recipients.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
5 months agonotify: let a matcher always match if it has no matching directives
Lukas Wagner [Tue, 14 Nov 2023 12:59:16 +0000 (13:59 +0100)]
notify: let a matcher always match if it has no matching directives

This should be a bit more intuitive to users than the current
behavior, which is 'always match' for mode==all and 'never match' for
mode==any. The current behavior originates in the neutral element of
the underlying logical operation (and, or).

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
5 months agonotify: matcher: introduce common trait for match directives
Lukas Wagner [Tue, 14 Nov 2023 12:59:15 +0000 (13:59 +0100)]
notify: matcher: introduce common trait for match directives

This allows us to make the match-checking code a bit shorter.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
5 months agonotify: add calendar matcher
Lukas Wagner [Tue, 14 Nov 2023 12:59:14 +0000 (13:59 +0100)]
notify: add calendar matcher

This allows matching by a notification's timestamp:

matcher: foo
  match-calendar mon..fri 8-12

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
5 months agonotify: replace filters and groups with matcher-based system
Lukas Wagner [Tue, 14 Nov 2023 12:59:13 +0000 (13:59 +0100)]
notify: replace filters and groups with matcher-based system

This shifts notification routing into the matcher-system. Every
notification has associated metadata (key-value fields, severity -
to be extended) that can be match with match directives in
notification matchers. Right now, there are 2 matching directives,
match-field and match-severity. The first one allows one to do a
regex match/exact match on a metadata field, the other one allows one
to match one or more severites.
Every matcher also allows 'target' directives, these decide which
target(s) will be notified if a matcher matches a notification.

Since routing now happens in matchers, the API for sending is
simplified, since we do not need to specify a target any more.

The API routes for filters and groups have been removed completely.
The parser for the configuration file will still accept filter/group
entries, but will delete them once the config is saved again. This is
needed to allow a smooth transition from the old system to the new
system, since the old system was already available on pvetest.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
5 months agonotify: factor out notification content into its own type
Lukas Wagner [Tue, 14 Nov 2023 12:59:12 +0000 (13:59 +0100)]
notify: factor out notification content into its own type

This will be useful later for system mail forwarding, where
the content of the mail should be forwarded unchanged.

This moves notification properties into this new type and calls them
'data'. They will exclusively used for template rendering.
`Notification` will receive a separate field for metadata, which
will be useful for notification filtering. This decouples
template rendering and filtering, which enables us to be very precise
about which metadata fields we allow to be used in filters.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
5 months agonotify: introduce Error::Generic
Lukas Wagner [Tue, 14 Nov 2023 12:59:11 +0000 (13:59 +0100)]
notify: introduce Error::Generic

... as leaf error-type for anything for which we do not necessarily
want a separate enum variant.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
5 months agohttp: rate limited stream: fix typo in rustdoc comment
Lukas Wagner [Thu, 21 Sep 2023 11:19:26 +0000 (13:19 +0200)]
http: rate limited stream: fix typo in rustdoc comment

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
5 months agoapt: repositories: document status property for standard repository
Fiona Ebner [Fri, 29 Sep 2023 07:00:53 +0000 (09:00 +0200)]
apt: repositories: document status property for standard repository

Suggested-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
6 months agorest-server: parse upid: improve on comments and variables
Thomas Lamprecht [Thu, 26 Oct 2023 08:38:59 +0000 (10:38 +0200)]
rest-server: parse upid: improve on comments and variables

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 months agorest-server: extend documentation for reading status of a UPID
Thomas Lamprecht [Thu, 26 Oct 2023 08:26:09 +0000 (10:26 +0200)]
rest-server: extend documentation for reading status of a UPID

Including some possible pitfalls when using this.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 months agorest-server: code complexity clean-up in task-log rotation
Thomas Lamprecht [Wed, 18 Oct 2023 17:41:55 +0000 (19:41 +0200)]
rest-server: code complexity clean-up in task-log rotation

avoid using the negative in the if check and extract the value to be
passed upfront.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 months agorest-server: better document task-log archive rotation
Thomas Lamprecht [Wed, 18 Oct 2023 17:39:00 +0000 (19:39 +0200)]
rest-server: better document task-log archive rotation

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 months agosys: depreacate PTY module, moves to termproxy directly
Thomas Lamprecht [Tue, 24 Oct 2023 11:52:15 +0000 (13:52 +0200)]
sys: depreacate PTY module, moves to termproxy directly

As termproxy only used this module from the huge proxmox-sys crate,
and this module was also only used here, it makes sense to move it
over there (and dropping proxmox-sys halved build-time from 8.5 s to
4.2 s).

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 months agoschema: beautify parameter error output
Gabriel Goller [Mon, 23 Oct 2023 07:57:24 +0000 (09:57 +0200)]
schema: beautify parameter error output

If there is only one error, output in a single line, without any
excessive newlines at the end. If there are multiple errors, show them
in a bulleted list.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
6 months agoproxmox-tfa: derive Copy, Clone and PartialEq on TfaType (for GUI)
Dietmar Maurer [Mon, 23 Oct 2023 09:44:45 +0000 (11:44 +0200)]
proxmox-tfa: derive Copy, Clone and PartialEq on TfaType (for GUI)

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
6 months agoDailyDuration: derive PartialEq (for GUI)
Dietmar Maurer [Fri, 20 Oct 2023 10:01:27 +0000 (12:01 +0200)]
DailyDuration: derive PartialEq (for GUI)

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
6 months agorest-server: factor out task-log directory and creation
Thomas Lamprecht [Wed, 18 Oct 2023 17:36:32 +0000 (19:36 +0200)]
rest-server: factor out task-log directory and creation

We had two call sites deriving the directory "shard" where the task
log file is actually saved to, this can lead to ugly bugs and is
better done in a central single-source-of-truth way.

While at it factor out the creation of the log file (and it's shard
directory) to avoid crowding the WorkerTask new fn to much.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 months agobump proxmox-client to 0.3.0-1
Wolfgang Bumiller [Mon, 16 Oct 2023 11:26:51 +0000 (13:26 +0200)]
bump proxmox-client to 0.3.0-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
6 months agohuman-byte: d/control bump
Wolfgang Bumiller [Mon, 16 Oct 2023 11:04:48 +0000 (13:04 +0200)]
human-byte: d/control bump

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
6 months agobump proxmox-human-byte to 0.1.2
Wolfgang Bumiller [Mon, 16 Oct 2023 11:03:01 +0000 (13:03 +0200)]
bump proxmox-human-byte to 0.1.2

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
6 months agoHumanByte: make fields public
Dietmar Maurer [Mon, 16 Oct 2023 10:27:28 +0000 (12:27 +0200)]
HumanByte: make fields public

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
6 months agotfa: more optional dependency cleanup
Wolfgang Bumiller [Mon, 16 Oct 2023 07:00:17 +0000 (09:00 +0200)]
tfa: more optional dependency cleanup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
6 months agotfa: make totp a feature and mark all optional deps as optional
Wolfgang Bumiller [Mon, 16 Oct 2023 06:58:08 +0000 (08:58 +0200)]
tfa: make totp a feature and mark all optional deps as optional

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
6 months agoworkspace: set resolver to 2 to silence a warning
Wolfgang Bumiller [Mon, 16 Oct 2023 06:53:35 +0000 (08:53 +0200)]
workspace: set resolver to 2 to silence a warning

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
7 months agoreplace deprecated X509Extension::new_nid
Wolfgang Bumiller [Tue, 3 Oct 2023 11:45:10 +0000 (13:45 +0200)]
replace deprecated X509Extension::new_nid

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
7 months agobump proxmox-api-macro to 1.0.6-1
Fabian Grünbichler [Mon, 2 Oct 2023 07:27:45 +0000 (09:27 +0200)]
bump proxmox-api-macro to 1.0.6-1

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
7 months agobump proxmox-sortable-macro to 0.1.3-1
Fabian Grünbichler [Mon, 2 Oct 2023 07:24:18 +0000 (09:24 +0200)]
bump proxmox-sortable-macro to 0.1.3-1

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
7 months agobump proxmox-router to 2.1.1-1
Fabian Grünbichler [Mon, 2 Oct 2023 07:10:12 +0000 (09:10 +0200)]
bump proxmox-router to 2.1.1-1

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
7 months agoupdate to syn 2
Wolfgang Bumiller [Thu, 28 Sep 2023 11:05:29 +0000 (13:05 +0200)]
update to syn 2

This mostly affected attribute parsing (due to the syn::Meta changes).
Also creating `DelimSpan`s for custom-built `syn::Attribute`s is a
bit... ugly.
Upshot: turns out we can drop some helpers in util.rs with the new
`syn::Meta` changes.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
7 months agorouter: bump env_logger to 0.10 and move to workspace
Wolfgang Bumiller [Thu, 28 Sep 2023 07:59:48 +0000 (09:59 +0200)]
router: bump env_logger to 0.10 and move to workspace

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
7 months agoclient: fix optional data for errors
Dominik Csapak [Thu, 14 Sep 2023 10:41:30 +0000 (12:41 +0200)]
client: fix optional data for errors

previously we changed the internal type of the 'data' property
from Option<T> to T in the assumption the api always returns
'data:null'.

this is actually only the case when the api call succeeds. in an error
case there is no data property at all.

to fix this issue while behaving the same for 'data:null' we have to
revert to Option<T> for RawApiResponse but instead of always throwing an
error for 'data:null' in 'check' we now try there to deserialize from
Value::Null for T if there was no data. This will succeed for the Type
'()' which was the motivation for the original change.

The only downside is that the RawApiResponse now has a trait bound that
T is deserializeable, but was a requirement for using it anyway
(as there was no other way of constructing it)

Fixes: 271a55f ("client: remove option from inner RawApiResponse")
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
7 months agoschema: bump version to 2.0.1
Thomas Lamprecht [Wed, 20 Sep 2023 09:42:57 +0000 (11:42 +0200)]
schema: bump version to 2.0.1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
7 months agofix #4162: sys: added `auto-submitted` header to email body
Gabriel Goller [Fri, 8 Sep 2023 13:06:57 +0000 (15:06 +0200)]
fix #4162: sys: added `auto-submitted` header to email body

`Auto-Submitted` is defined in the rfc 5436 [1] and describes how
an automatic response (f.e. ooo replies, etc.) should behave on the
emails. When using `Auto-Submitted: auto-generated` (or any value
other than `none`) automatic replies won't be triggered.

[1]: https://www.rfc-editor.org/rfc/rfc3834.html

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>