]> git.proxmox.com Git - proxmox.git/log
proxmox.git
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 months agorest-server: accept empty body as valid parameters
Dominik Csapak [Thu, 24 Aug 2023 10:22:31 +0000 (12:22 +0200)]
rest-server: accept empty body as valid parameters

technically an empty string is not valid json, but when sending an api
request without any parameters, treating the empty body as an empty
parameter hash instead of an error, makes the the api more robust for
clients

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
8 months agoschema: serialize enum unit variants
Hannes Laimer [Tue, 29 Aug 2023 09:59:16 +0000 (11:59 +0200)]
schema: serialize enum unit variants

... since deserializing them already works

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
8 months agoapt: bump version to 0.10.6-1
Thomas Lamprecht [Tue, 5 Sep 2023 13:22:40 +0000 (15:22 +0200)]
apt: bump version to 0.10.6-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
8 months agoapt: use modern format string variables and small style cleanups
Thomas Lamprecht [Tue, 5 Sep 2023 13:19:34 +0000 (15:19 +0200)]
apt: use modern format string variables and small style cleanups

note: not complete, there's other code to check and rework, but I had
this already done so commit it, better than nothing.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
8 months agotests: factor out directory cleanup+creation
Thomas Lamprecht [Tue, 5 Sep 2023 10:46:20 +0000 (12:46 +0200)]
tests: factor out directory cleanup+creation

This moves the clean-up to happen up-front. That way one can still
inspect the test data after, e.g., a failed test.

Originally done almost like this in a patch from Fiona [0] that I just
overlooked, but now also factored out, avoid crowding the test code to
much with duplicate code.

[0]: https://lists.proxmox.com/pipermail/pve-devel/2023-June/057136.html

Suggested-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
8 months agoapt: fixup description for Reef repo
Thomas Lamprecht [Tue, 5 Sep 2023 08:08:59 +0000 (10:08 +0200)]
apt: fixup description for Reef repo

the "main" repo only exists for Quincy to allow an easier transition
from Proxmox VE 7 to Proxmox VE 8, for when the enterprise repo got
added for ceph too.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
8 months agoapt: add Ceph Reef to standard repo list
Thomas Lamprecht [Mon, 4 Sep 2023 15:14:19 +0000 (17:14 +0200)]
apt: add Ceph Reef to standard repo list

For now just duplicate the Ceph Quincy entries, as I want to avoid
using macros and we do not yet have support for enums inside enums
with the api macro.

Adapt and expand the tests slightly to have at least some simple
coverage there too.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
8 months agoapt: unify match-arm for ceph sources.list location
Thomas Lamprecht [Mon, 4 Sep 2023 15:12:31 +0000 (17:12 +0200)]
apt: unify match-arm for ceph sources.list location

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
8 months agoapt: tests: allow re-running digest test without clean-up
Thomas Lamprecht [Mon, 4 Sep 2023 15:53:32 +0000 (17:53 +0200)]
apt: tests: allow re-running digest test without clean-up

Files inside CARGO_TARGET_TMPDIR are only cleaned on `cargo clean`, so
tests that expect files to not exist need to cleanup themselves.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
9 months agosys: fs: move tests to a sub-module
Lukas Wagner [Mon, 21 Aug 2023 13:44:38 +0000 (15:44 +0200)]
sys: fs: move tests to a sub-module

This ensures that test code is not compiled in regular builds

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
9 months agoproxmox-time: implement epoch_to_rfc3339 for wasm
Dominik Csapak [Mon, 28 Aug 2023 13:30:21 +0000 (15:30 +0200)]
proxmox-time: implement epoch_to_rfc3339 for wasm

we just printed out the UTC version, this implements a localized version

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
9 months agotime: make RFC3339 format in wasm conform to usual format
Dominik Csapak [Mon, 28 Aug 2023 13:29:32 +0000 (15:29 +0200)]
time: make RFC3339 format in wasm conform to usual format

on other targets we print the timestamp without fractional seconds
('.xxxZ'), so we should remove that too on wasm

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
9 months agoclient: remove option from inner RawApiResponse
Dominik Csapak [Tue, 29 Aug 2023 12:04:40 +0000 (14:04 +0200)]
client: remove option from inner RawApiResponse

when using the client for an api call that does not return any data
(it returns '{"data":null}'), we would always get an error 'api returned
no data'. The message is technically correct, but it should not be an
error when we expect no data (e.g. most of our CRUD PUT/POST calls)

instead of having the Option<T> in the RawApiResponse type itself, move
it into to the 'nodata' function intended for api calls where we don't
expect any data.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
9 months agoproxmox-client: add post_without_body
Dietmar Maurer [Sun, 27 Aug 2023 14:16:37 +0000 (16:16 +0200)]
proxmox-client: add post_without_body

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
9 months agonotify: make template rendering helpers more robust
Lukas Wagner [Fri, 25 Aug 2023 11:35:57 +0000 (13:35 +0200)]
notify: make template rendering helpers more robust

This commit has the aim of making template rendering a bit more
robust. It does so by a.) Accepting also strings for helpers that
expect a number, parsing the number if needed, and b.) Ignoring errors
if a template helper fails to render a value and showing an error in
the logs, instead of failing to render the whole template (leading
to no notification being sent).

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
9 months agobump proxmox-client to 0.2.3-1
Wolfgang Bumiller [Fri, 25 Aug 2023 06:59:06 +0000 (08:59 +0200)]
bump proxmox-client to 0.2.3-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoclient: fixup checks for api calls not returning data
Wolfgang Bumiller [Fri, 25 Aug 2023 07:02:58 +0000 (09:02 +0200)]
client: fixup checks for api calls not returning data

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoclient: set content type header on requests
Wolfgang Bumiller [Fri, 25 Aug 2023 06:56:32 +0000 (08:56 +0200)]
client: set content type header on requests

this got lost with the recent refactoring

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agobump proxmox-client to 0.2.2-1
Wolfgang Bumiller [Fri, 25 Aug 2023 06:37:25 +0000 (08:37 +0200)]
bump proxmox-client to 0.2.2-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoclient: fix content type parsing with included charset
Wolfgang Bumiller [Fri, 25 Aug 2023 06:36:19 +0000 (08:36 +0200)]
client: fix content type parsing with included charset

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoasync: runtime: Modernise module and update docs
Max Carrara [Mon, 21 Aug 2023 11:37:45 +0000 (13:37 +0200)]
async: runtime: Modernise module and update docs

This commit updates all helper functions, taking into account recent
developments regarding `tokio`.

In particular, the `block_in_place()` and `block_on()` functions now
don't panic anymore if used within the single-threaded `tokio` runtime
and instead behave as expected in both runtime flavours.

Furthermore, because `tokio` may add more runtime flavours in the
future, all helpers will now panic if used within an unsupported
runtime. This is to prevent unforeseen behavioural quirks and
interactions with `tokio` internals.

The above changes make `BlockingGuard` redundant; it is consequently
removed.

The documentation is also updated, describing the behaviour of the
helper functions and the purpose of the `runtime.rs` module in more
detail.

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
9 months agoclient/login: clippy fixes
Max Carrara [Mon, 21 Aug 2023 11:48:15 +0000 (13:48 +0200)]
client/login: clippy fixes

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
9 months agobump proxmox-client to 0.2.1-1
Wolfgang Bumiller [Wed, 16 Aug 2023 12:32:06 +0000 (14:32 +0200)]
bump proxmox-client to 0.2.1-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agopackage proxmox-login 0.1.0-1
Wolfgang Bumiller [Wed, 16 Aug 2023 12:30:38 +0000 (14:30 +0200)]
package proxmox-login 0.1.0-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoclient: convenience helper to get a serialized ticket
Wolfgang Bumiller [Thu, 10 Aug 2023 12:30:31 +0000 (14:30 +0200)]
client: convenience helper to get a serialized ticket

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoclient: expose AuthenticationKind
Wolfgang Bumiller [Thu, 10 Aug 2023 12:27:31 +0000 (14:27 +0200)]
client: expose AuthenticationKind

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoclient: add Client::set_authentication method
Wolfgang Bumiller [Thu, 10 Aug 2023 12:14:06 +0000 (14:14 +0200)]
client: add Client::set_authentication method

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agobump proxmox-client to 0.2.0-1
Wolfgang Bumiller [Wed, 9 Aug 2023 11:22:14 +0000 (13:22 +0200)]
bump proxmox-client to 0.2.0-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoclient: add TlsOptions::parse_fingerprint
Wolfgang Bumiller [Thu, 10 Aug 2023 08:43:03 +0000 (10:43 +0200)]
client: add TlsOptions::parse_fingerprint

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoclient: impl HttpApiClient for refs, Arcs and Rcs
Wolfgang Bumiller [Wed, 9 Aug 2023 13:29:00 +0000 (15:29 +0200)]
client: impl HttpApiClient for refs, Arcs and Rcs

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoclient: put requests
Wolfgang Bumiller [Wed, 9 Aug 2023 12:53:39 +0000 (14:53 +0200)]
client: put requests

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoclient: handle response data
Wolfgang Bumiller [Tue, 8 Aug 2023 14:52:11 +0000 (16:52 +0200)]
client: handle response data

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoclient: turn Client inside out
Wolfgang Bumiller [Tue, 8 Aug 2023 09:03:58 +0000 (11:03 +0200)]
client: turn Client inside out

Since the WASM client cannot actually use a `http::Request` the way we
expect it to, that is, it cannot manually along cookies, we turn the
client bit inside out:

This crate mainly defines the `HttpApiClient` trait which expects the
http client to perform *authenticated* API calls, that is, the
handling of API tokens and tickets should happen at the *implementor*
side.

The product clients will require *this* trait to be implemented, and
will not themselves offer a way to login.

As for the `Client` struct, this will now instead *implement* this
trait and will *not* be used in the `wasm` ecosystem. Rather, this is
the ticket handling http client that already exists in the PWT based
ui code.

The PVE client in `pve-api-types` will not *contain* a `Client`
anymore, but rather, it will provide PVE api call implementations for
something implementing `HttpApiClient`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoclient: drop environment and login methods
Wolfgang Bumiller [Mon, 7 Aug 2023 12:25:25 +0000 (14:25 +0200)]
client: drop environment and login methods

The environment trait was useful on the CLI, but does not really
translate well to eg. the wasm ui (or pdm for that matter), so drop it
and instead have `.login` and `.login_tfa` just take the
`proxmox_login` type and handle the updating of authentication data.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoclient: replace Error trait with a type
Wolfgang Bumiller [Mon, 7 Aug 2023 09:55:59 +0000 (11:55 +0200)]
client: replace Error trait with a type

Because we ultimately also want to drop the `Environment` trait since
it is not suitable for all use cases (eg. wasm ui)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoclient: prepare to get rid of Error trait
Wolfgang Bumiller [Mon, 7 Aug 2023 09:19:39 +0000 (11:19 +0200)]
client: prepare to get rid of Error trait

First rename it so it's clear what "Error" refers to in the following
patches.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agologin: add userid and api_url getters
Wolfgang Bumiller [Mon, 7 Aug 2023 09:16:36 +0000 (11:16 +0200)]
login: add userid and api_url getters

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoproxmox-io: fix `sparse_copy` not copying sparsely on irregular read operations
Max Carrara [Mon, 17 Jul 2023 14:19:40 +0000 (16:19 +0200)]
proxmox-io: fix `sparse_copy` not copying sparsely on irregular read operations

In the uncommon circumstance that calls to `read()` end up reading any number of
bytes other than 4096, the subsequently read bytes become misaligned, causing
blocks of zeroes to be written unnecessarily.

To illustrate, imagine you have a 12KiB file:

  [x][x][x][x][ ][ ][ ][ ][x][x][x][x]
   └──4096──┘  └──4096──┘  └──4096──┘

The first and last block are filled with some data, whereas the middle block is
empty and will therefore result in only zeroes being read.

In order for the empty block to be skipped with `seek()`, the entire buffer has
to be filled with zeroes.

If, for example, the first `read()` ends up putting only 3KiB into the buffer,
the empty block in the middle won't be detected properly, as the buffer will
now always contain some data. What results are four misaligned reads:

  [x][x][x][x][ ][ ][ ][ ][x][x][x][x]
   ├─────┘  ├────────┘  ├────────┘  │
   1        2           3           4

This is fixed by ensuring chunks of 4KiB are always read into the buffer,
except when the last block is truncated. In order to prevent frequent small
reads, the incoming reader is also buffered via `io::BufReader`.

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
9 months agobump proxmox-ldap to 0.2.1-1
Wolfgang Bumiller [Tue, 8 Aug 2023 12:08:47 +0000 (14:08 +0200)]
bump proxmox-ldap to 0.2.1-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agobump proxmox-apt to 0.10.5-1
Wolfgang Bumiller [Tue, 8 Aug 2023 12:05:51 +0000 (14:05 +0200)]
bump proxmox-apt to 0.10.5-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoldap: only search base of base_dn when checking connection
Stefan Sterz [Fri, 21 Jul 2023 14:34:03 +0000 (16:34 +0200)]
ldap: only search base of base_dn when checking connection

this should avoid most common size limitations. the search should also
complete quicker as fewer results need to be computed. note that this
way a configuration may be accepted, but the related sync job can
fail due to and exceeded size limit warning for some ldap servers
(such as 2.5.14+dfsg-0ubuntu0.22.04.2).

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
9 months agoldap: add an integration test for `check_connection`
Stefan Sterz [Fri, 21 Jul 2023 14:34:02 +0000 (16:34 +0200)]
ldap: add an integration test for `check_connection`

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
9 months agofix #4868: map missing section field to 'unknown'
Fabian Grünbichler [Tue, 25 Jul 2023 08:31:10 +0000 (10:31 +0200)]
fix #4868: map missing section field to 'unknown'

needed for supporting some third-party repositories.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
9 months agoclippy fix: casting to the same type is unnecessary
Lukas Wagner [Tue, 8 Aug 2023 09:44:54 +0000 (11:44 +0200)]
clippy fix: casting to the same type is unnecessary

See: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
9 months agoclippy fix: deref on an immutable reference
Lukas Wagner [Tue, 8 Aug 2023 08:01:53 +0000 (10:01 +0200)]
clippy fix: deref on an immutable reference

See:
https://rust-lang.github.io/rust-clippy/master/index.html#borrow_deref_ref

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
9 months agoclippy fix: complex type definitions
Lukas Wagner [Tue, 8 Aug 2023 08:01:52 +0000 (10:01 +0200)]
clippy fix: complex type definitions

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
9 months agoclippy fix: the following explicit lifetimes could be elided
Lukas Wagner [Tue, 8 Aug 2023 08:01:51 +0000 (10:01 +0200)]
clippy fix: the following explicit lifetimes could be elided

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>