3506 Commits

Author SHA1 Message Date
9db7bc90f6 Merge remote-tracking branch 'upstream/master' 2025-03-28 15:28:55 +03:00
Lukas Wagner
4097d3697d notify: gotify: use constant from http crate for 'Authorization' header
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2025-03-25 19:37:37 +01:00
Lukas Wagner
6d4c115f05 notify: webhook: gotify: set Content-Length header
To quote from RFC 9110 [1]:

  A user agent SHOULD send Content-Length in a request when
  the method defines a meaning for enclosed content and it
  is not sending Transfer-Encoding. For example, a user agent
  normally sends Content-Length in a POST request even when
  the value is 0 (indicating empty content).
  A user agent SHOULD NOT send a Content-Length header field
  when the request message does not contain content and the
  method semantics do not anticipate such data.

It seemed like our HTTP client lib did not set the header
automatically, which is why we should do it manually.

While most services seemed to have worked fine without setting
the header, some Microsoft services seem to require it
to accept the webhook request [2].

[1] https://datatracker.ietf.org/doc/html/rfc9110#name-content-length
[2] https://forum.proxmox.com/threads/158827

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2025-03-25 19:37:37 +01:00
Thomas Lamprecht
7abd2da759 pbs-api-types: acl: fix indentation error in macro
expand tabs to spaces

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-03-24 17:56:13 +01:00
Dietmar Maurer
ec8a3de133 sys: procfs: split read_meminfo into read and parse functions
So that we can write tests.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2025-03-20 18:42:05 +01:00
Wolfgang Bumiller
da8fdea632 rest-server: bump to 0.8.8-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-20 14:45:19 +01:00
Christian Ebner
10cf5ed7b4 rest-server: worker task: include context in state error message
Currently the anyhow error context of a given error is not included
in the error message, as `to_string` does use the default formatting
[0].

Include the error context, formatting it as single line as the
message is also shown to the users in e.g. the Proxmox Backup Severs
task state in the UI.

[0] https://docs.rs/anyhow/latest/anyhow/struct.Error.html#display-representations

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2025-03-20 14:40:58 +01:00
Maximiliano Sandoval
25c08ad247 sys: add variable bindings for temporaries in unsafe blocks
These will produce an error in edition 2024 otherwise. The reason this
is needed is because the `unsafe` block has its own scope.

The bytes were defined inside of the let-mut block to preserve the
lifetime they had before this commit.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2025-03-19 12:32:42 +01:00
Wolfgang Bumiller
e06277ac7a log: bump to 0.2.8-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-19 12:19:43 +01:00
Wolfgang Bumiller
86a517d087 sys: bump to 0.6.6-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-19 12:19:43 +01:00
Wolfgang Bumiller
57eb5a36e9 sys, shared-memory: deny unsafe_op_in_unsafe_fn explicitly
can be removed in these and the other crates when switching to edition
2024

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-19 12:19:43 +01:00
Wolfgang Bumiller
d42810e3c1 log, rest-server: cargo fmt / formatting cleanups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-19 12:19:43 +01:00
Maximiliano Sandoval
3db442fb8f async: accommodate to edition 2024 changes to RPIT
Prevents the following error:

```
error[E0597]: `inner` does not live long enough
   --> proxmox-async/src/broadcast_future.rs:109:24
    |
107 |         inner: Arc<Mutex<BroadCastFutureBinding<T>>>,
    |         ----- binding `inner` declared here
108 |     ) -> impl Future<Output = Result<T, Error>> {
109 |         let mut data = inner.lock().unwrap();
    |                        ^^^^^ borrowed value does not live long enough
...
121 |         data.broadcast.listen()
    |         ----------------------- argument requires that `inner` is borrowed for `'static`
122 |     }
    |     - `inner` dropped here while still borrowed

error[E0597]: `data` does not live long enough
   --> proxmox-async/src/broadcast_future.rs:121:9
    |
109 |         let mut data = inner.lock().unwrap();
    |             -------- binding `data` declared here
...
121 |         data.broadcast.listen()
    |         ^^^^-------------------
    |         |
    |         borrowed value does not live long enough
    |         argument requires that `data` is borrowed for `'static`
122 |     }
    |     - `data` dropped here while still borrowed
```

The use<...> pattern was introduced in rust 1.82.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2025-03-19 12:19:33 +01:00
Maximiliano Sandoval
51c3a31115 mark blocks inside unsafe fns unsafe
In edition 2024 unsafe code inside unsafe functions has to be explicitly
marked as such.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2025-03-19 12:19:19 +01:00
Maximiliano Sandoval
9be42ea5ad daemon: set_var is now unsafe
In edition 2024 set_var is unsafe.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2025-03-19 12:19:19 +01:00
Maximiliano Sandoval
abd07ffcff mark extern C blocks as unsafe
This is required in edition 2024.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2025-03-19 12:19:19 +01:00
Gabriel Goller
a75b97da76 log, rest-server: worker_task: add log_unfiltered
To write result message manually, bypassing tracing.

The workertasks currently get their status from parsing the log
messages in the task-log file. The problem is that if these messages are
filtered – which is now possible using the PBS_LOG env variable – some
workertasks will end up with a "stopped: unknown" status. This is not
desirable so write the message manually to the workertask file and
bypass tracing.

This way we are guaranteed that, regardless of the max logging level the
user sets, the final message (and status) is written.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2025-03-19 12:19:02 +01:00
Wolfgang Bumiller
c99308ecfc log: factor out NoWorkerTask filter
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-19 11:52:08 +01:00
Wolfgang Bumiller
6bdd07075d log: fix doctests
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-19 11:51:53 +01:00
Gabriel Goller
656fedb0c4 log: add layer for pve workertasks in perlmod crates
Add a layer that outputs messages to stderr in a specific format. In
PVE, stderr is rerouted to the tasklog if the we are within a
workertask. Therefore, ensure the stderr output is formatted
appropriately.

Reported-by: Lukas Wagner <l.wagner@proxmox.com>
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2025-03-19 09:52:35 +01:00
Gabriel Goller
f6269b800d log: introduce logging builder
Add a builder-like struct to compose a tracing logger using different
layers. Instead of having an init function per product/binary or
super-specific init functions that describe the logger, have a dynamic
builder. The builder improves the usability and makes the logging
initialization more self-explaining.

Suggested-by: Lukas Wagner <l.wagner@proxmox.com>
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2025-03-19 09:52:35 +01:00
Shannon Sterz
3e382fd29c auth-api: set content type header for the new HttpOnly ticket endpoint
otherwise some clients might struggle to interpret the body correctly

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-14 09:28:11 +01:00
Fabian Grünbichler
b82e51f15a bump proxmox-router to 3.1.1-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2025-03-13 13:58:50 +01:00
Fabian Grünbichler
e4bc435beb env_logger: bump to 0.11
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2025-03-13 13:55:29 +01:00
Wolfgang Bumiller
f32f48b119 router: cli: avoid unnecessary clones/allocation
The `new_args` Vec is directly passed to the other Vec's `.extend()`,
which takes an `IntoIterator` consuming it, so just pass the
intermediate `Iterator`.

The `rest` Vec owns its strings and we don't need it afterwards, so
similarly, we can consume it via `.extend()` instead of a manual
push(s.clone()) loop.

The .truncate(0) can just be .clear() - they are equivalent according
to their documentation.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-13 11:46:52 +01:00
586535e456 Merge remote-tracking branch 'upstream/master' 2025-03-07 14:06:22 +03:00
Shannon Sterz
00c75c734d tree-wide: fix private intra doc links
a previous commit fixed up all intra doc links that were present on
public apis, this also fixes the links for private members.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-07 11:35:03 +01:00
9e27dfa8a5 Use 'alt-linux' feature by default 2025-03-07 05:44:25 +03:00
Shannon Sterz
a9a7bbdabc auth-api: fix intra doc link for Empty
`Display` isn't used directly anymore, so fix up the intra doc link
here again.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 16:35:51 +01:00
Wolfgang Bumiller
5c7b1ab4ab tfa, auth-api: simplify and restyle Display implementation
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-06 15:25:24 +01:00
Shannon Sterz
4836cb5334 tree-wide: fix intra doc links
this fixes intra document links or rephrases the documentation in a
more appropriate way to remove all `broken_intra_doc_links` warnings.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:25:24 +01:00
Shannon Sterz
ccb34b33e2 api-macro: re-order ObjectSchema fields to be sorted
this panics when running `cargo test` otherwise, as the api macro
requires fields in `ObjectSchema`s to be sorted now.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:25:24 +01:00
Shannon Sterz
f0b23def30 router: fix nested doc test cases to match inteded output
commit 68b13965 (router: docs: add horizontal line before nested
command docs) broke the nested command group test case. this commit
adapts the expected output accordingly.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:25:24 +01:00
Shannon Sterz
4fc074b4ba network-api: ignore clippy lint about upper case acronyms
while the lint is correct about how these enum members should be
capitalized, the enum is marked as `pub` and all users of it would
need to adapt. so ignore the lint for now [1].

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:25:24 +01:00
Shannon Sterz
730f908458 apt: ignore clippy lint about new having to return Self
while this is a reasonable convention to follow, in this case the new
function is part of a public trait and changing the signature would
force all users to adapt. so ignore the lint for now [1].

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#new_ret_no_self

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:25:24 +01:00
Shannon Sterz
8fc324ee73 apt: ignore clippy lint about using a slice reference instead of &Vec
while the function would be more useful as pointed out by the clippy
lint, it i currently `pub` and users of the function would need to
adapt to the change here. so ignore the lint for now.

[1]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:25:24 +01:00
Shannon Sterz
59898d0177 rest-server/router: ignore type complexity clippy lint
the `type_complexity` clippy lint [1] is intended to make the code
more legible in most cases. however, the lint triggers on a member of
a private enum, an example minimal rest server and a private static
variable here. so the benefits of declaring a new type that would
encapsulate this complexity is minimal. hence, ignore the warnings for
now.

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:25:24 +01:00
Shannon Sterz
f9dd576783 router: ignore clippy lint missing_transmute_annotations
the `ApiHandler`'s `PartialEq` implementation makes heavy use of
`transmute`. clippy wants the types to be explicitly stated here and
not inferred, to avoid potential undefined behaviour if an unexpected
type is inferred. however, the types that would be inferred here are
so complex, that the code would become illegible anyway, so ignore
this lint for now.

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#missing_transmute_annotations

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:25:24 +01:00
Shannon Sterz
dcc6eb9918 shared-memory: specify generic types for transmute
this annotates a `transmute` call with proper types to avoid possible
undefined behaviour, as suggested by clippy [1].

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#missing_transmute_annotations

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:25:24 +01:00
Shannon Sterz
ab2d5c9777 acme/auth-api: add Default for types with un-parameterized new()
this fixes a clippy lint for types that have a `new()` function that
has no parameters [1]. this should allow using these types with
functions such as `unwrap_or_default()`.

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:25:24 +01:00
Shannon Sterz
efc8556c27 auth-api/tfa: prefer Display over ToString/an inherent function
this fixes two clippy lints that check if either `ToString` or an
inherent `to_string()` function is implement [1, 2]. `Display`
provides `ToString` for free and, thus, is preferable.

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#/inherent_to_string
[2]:
https://rust-lang.github.io/rust-clippy/master/index.html#to_string_trait_impl

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:17:35 +01:00
Shannon Sterz
d95a4f25e0 router: allow from_str on Confirmation that is not for FromStr
while usually this would improve ergonomics, in this case it isn't
clear whether all uses of `FromStr` would be considered valid here.
renaming the function would also make the type more confusing to use
as `from_str_with_default` also exists, so keep this for consistency.
this ignores a clippy lint [1].

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#should_implement_trait

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:16:04 +01:00
Shannon Sterz
92ecc301b6 sys: add truncate option to OpenOptions in test case
this resolves a clippy lint that checks for uses of `create()` without
`truncate()` [1].

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_open_options

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:15:43 +01:00
Shannon Sterz
946d95cfcd access-control/tfa: use ? instead of unnecessary match statements
this makes the code more concise and legible. fixes a clippy lint [1].

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#question_mark

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:15:22 +01:00
Shannon Sterz
a318fcedd3 tfa: remove needless as_bytes call
len() already returns the length in bytes, no need to call `as_bytes`
first. this fixes a clippy lint [1].

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#needless_as_bytes

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:15:11 +01:00
Shannon Sterz
0b9c1485c0 tfa: don't use block in conditions
this fixes a clippy style lint that does not allow blocks in
conditionals. moving the block out and the result into a temporary
variable should make this more legible [1].

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#blocks_in_conditions

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:14:19 +01:00
Shannon Sterz
d980c2229b tree-wide: remove clone calls on types that are Copy
this resolves a clippy lint that checks that `clone()` isn't called on
`Copy` types as that is unnecessary [1].

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:12:16 +01:00
Shannon Sterz
2c07729ff3 tree-wide: add parantheses to clarify precedence
this resolves a clippy lint that aims to improve legibility for people
unaware of rust's precendence rules [1].

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#precedence

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:11:00 +01:00
Shannon Sterz
2134657529 io: clippy fix: replace map() followed by any() with just any()
this fixes a clippy lint that complains about map invocations followed
by any invocations that are just checking for identity as this can be
replaced by just the any invocation alone [1].

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#map_all_any_identity

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-06 15:03:10 +01:00
Wolfgang Bumiller
b5e238613e auth-api: bump to 0.4.8-1
While *technically* breaking as it changes the method signature for
the `create_ticket` call to use a struct for its parameters, this is
only (supposed to be) used via its `CREATE_TICKET_API_METHOD` handler
to be passed to a router. Direct use of this does not make sense.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-04 16:03:17 +01:00