2430 Commits

Author SHA1 Message Date
Thomas Lamprecht
dc9ee73751 schema: bump version to 2.0.1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-09-20 11:46:02 +02:00
Gabriel Goller
bcdcb181ee 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>
2023-09-18 16:41:06 +02:00
Dominik Csapak
359da67e9b 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>
2023-09-07 18:12:51 +02:00
Hannes Laimer
92be86d776 schema: serialize enum unit variants
... since deserializing them already works

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
2023-09-07 17:29:36 +02:00
Thomas Lamprecht
498341ec0d apt: bump version to 0.10.6-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-09-05 15:29:49 +02:00
Thomas Lamprecht
fb90d53caf 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>
2023-09-05 15:19:38 +02:00
Thomas Lamprecht
4e2cc6fd53 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>
2023-09-05 15:15:46 +02:00
Thomas Lamprecht
195e9e1cdf 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>
2023-09-05 10:09:00 +02:00
Thomas Lamprecht
1e47036528 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>
2023-09-04 17:58:45 +02:00
Thomas Lamprecht
767582a2eb apt: unify match-arm for ceph sources.list location
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-09-04 17:58:45 +02:00
Thomas Lamprecht
ae3c04a76b 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>
2023-09-04 17:58:45 +02:00
Lukas Wagner
bcd134a349 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>
2023-08-30 17:37:31 +02:00
Dominik Csapak
299a478f15 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>
2023-08-30 09:20:38 +02:00
Dominik Csapak
151e2cfdfd 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>
2023-08-30 09:18:44 +02:00
Dominik Csapak
271a55f187 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>
2023-08-29 14:14:52 +02:00
Dietmar Maurer
022fdacb25 proxmox-client: add post_without_body
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-08-27 16:19:31 +02:00
Lukas Wagner
d49fc1aa2f 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>
2023-08-25 15:32:34 +02:00
Wolfgang Bumiller
c81068097b bump proxmox-client to 0.2.3-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-25 09:03:00 +02:00
Wolfgang Bumiller
8617442560 client: fixup checks for api calls not returning data
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-25 09:03:00 +02:00
Wolfgang Bumiller
f20f9bb9f7 client: set content type header on requests
this got lost with the recent refactoring

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-25 08:56:41 +02:00
Wolfgang Bumiller
6286ff4eeb bump proxmox-client to 0.2.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-25 08:37:25 +02:00
Wolfgang Bumiller
d7f6fc4db5 client: fix content type parsing with included charset
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-25 08:36:19 +02:00
Max Carrara
1f351625a5 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>
2023-08-23 09:51:52 +02:00
Max Carrara
ede73a6561 client/login: clippy fixes
Signed-off-by: Max Carrara <m.carrara@proxmox.com>
2023-08-22 10:04:16 +02:00
Wolfgang Bumiller
68fe8baf95 bump proxmox-client to 0.2.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-16 14:33:01 +02:00
Wolfgang Bumiller
97025d4143 package proxmox-login 0.1.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-16 14:30:38 +02:00
Wolfgang Bumiller
a909d5789c client: convenience helper to get a serialized ticket
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-10 14:33:55 +02:00
Wolfgang Bumiller
490008d596 client: expose AuthenticationKind
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-10 14:27:31 +02:00
Wolfgang Bumiller
bea97ccce1 client: add Client::set_authentication method
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-10 14:14:06 +02:00
Wolfgang Bumiller
2fd5502321 bump proxmox-client to 0.2.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-10 11:15:36 +02:00
Wolfgang Bumiller
604e467684 client: add TlsOptions::parse_fingerprint
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-10 10:44:04 +02:00
Wolfgang Bumiller
dff830ba04 client: impl HttpApiClient for refs, Arcs and Rcs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-09 15:29:38 +02:00
Wolfgang Bumiller
a3322e49b9 client: put requests
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-09 15:29:38 +02:00
Wolfgang Bumiller
ffe908f636 client: handle response data
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-09 13:21:02 +02:00
Wolfgang Bumiller
1c96afd0ec 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>
2023-08-09 13:21:02 +02:00
Wolfgang Bumiller
0f19f2125f 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>
2023-08-09 13:21:02 +02:00
Wolfgang Bumiller
a9a267f04f 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>
2023-08-09 13:21:02 +02:00
Wolfgang Bumiller
e0b102d932 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>
2023-08-09 13:21:02 +02:00
Wolfgang Bumiller
0c45d51406 login: add userid and api_url getters
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-09 13:21:02 +02:00
Max Carrara
8841b389e3 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>
2023-08-09 12:48:04 +02:00
Wolfgang Bumiller
e9499bbcf2 bump proxmox-ldap to 0.2.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-08 14:09:19 +02:00
Wolfgang Bumiller
ade1d19b0a bump proxmox-apt to 0.10.5-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-08 14:05:51 +02:00
Stefan Sterz
c74167f528 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>
2023-08-08 14:01:27 +02:00
Stefan Sterz
92e02f6e33 ldap: add an integration test for check_connection
Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2023-08-08 14:01:25 +02:00
Fabian Grünbichler
445e032eee 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>
2023-08-08 13:59:17 +02:00
Lukas Wagner
5ea70421b3 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>
2023-08-08 11:48:01 +02:00
Lukas Wagner
41b2e49123 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>
2023-08-08 11:29:36 +02:00
Lukas Wagner
a36769b11a clippy fix: complex type definitions
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-08 11:29:36 +02:00
Lukas Wagner
3c7c9fc55d clippy fix: the following explicit lifetimes could be elided
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-08 11:29:36 +02:00
Lukas Wagner
6c38a997af clippy fix: useless use of format!
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-08 11:29:36 +02:00