Commit Graph

3050 Commits

Author SHA1 Message Date
Wolfgang Bumiller
3c34ef5573 section-config: use builder pattern for ObjectSchema
To prepare for a breaking change in proxmox-schema.
Since new fields in the schema constitute a breaking change, using the
builder methods will let this compile later as well.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-14 11:48:52 +01:00
Wolfgang Bumiller
c99a31c66f router: test: sort object schema properties
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-14 10:34:29 +01:00
Dominik Csapak
be57fb0122 schema: updater: add blanked implementation for PropertyString
so that we can have a property:

```
foo: Option<PropertyString<Bar>>,
```

within a struct that derives `Updater`

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2025-01-14 10:19:54 +01:00
Wolfgang Bumiller
8c5fa1c562 schema: fix pointer/length confusion in str_slice_to_range
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-13 15:22:40 +01:00
Wolfgang Bumiller
62e105a34e api-macro: bump to 1.3.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-09 14:21:53 +01:00
Wolfgang Bumiller
dce9102163 api-macro: add json_schema!() macro
This allows using the json schema notation to generate `Schema`
expressions.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-09 14:19:42 +01:00
Wolfgang Bumiller
619c290cf8 client: bump to 0.5.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-09 14:16:03 +01:00
Dietmar Maurer
b31ab119bb client: improve api error message (avoid duplicate status code)
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2025-01-09 12:02:28 +01:00
Wolfgang Bumiller
ddc154e5cd notify: add missing tracing::error macro import
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-07 10:20:37 +01:00
Thomas Lamprecht
b74391cada daemon: bump version to 0.1.2-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-12-30 15:34:16 +01:00
Thomas Lamprecht
1db49cb269 daemon: try to remove existing unix socket in bind directly
We tried this unconditionally on start-up in the PDM for the priv. API
daemon, but we actually only want to clean-up on fresh bind, not on
restoring the FD on daemon reload. Otherwise the unprivileged daemon
cannot connect to the privileged one anymore after the latter got
reloaded.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-12-30 15:30:10 +01:00
Thomas Lamprecht
7648aabf42 daemon: output debug log when restoring FD passed through env
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-12-30 15:29:34 +01:00
Thomas Lamprecht
cc4ee60452 apt: bump version to 0.11.6-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-12-19 12:46:05 +01:00
Thomas Lamprecht
aba50ebc38 apt: bump version to 0.11.6-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-12-19 12:42:45 +01:00
Thomas Lamprecht
942186e2b7 apt: pdm uses separator for test repo
For consistency with it's other repositories, we might migrate other
products also to this schema with a future major release (and nginx
rewrite config for backward compatibility)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-12-19 12:40:26 +01:00
Gabriel Goller
df6b705f56 notify: migrate from log to tracing
Migrated from `log` to `tracing`. Imported `tracing` only as it has a
smaller footprint (and less dependencies) than `proxmox_log`.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
2024-12-05 13:22:24 +01:00
Thomas Lamprecht
212249e009 sys: bump version to 0.6.5-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-12-05 08:32:47 +01:00
Thomas Lamprecht
87dd908530 client: run cargo fmt
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-12-05 08:32:47 +01:00
Shannon Sterz
8eae5a8330 product-config: use inner mutability for PRODUCT_CONFIG
with edition 2024 `static mut` references will be disallowed [1]. the
recommended way to work around this is to use inner mutability, so use a
`OnceLock` for the `PRODUCT_CONFIG` as that should not change throughout
the run time of an application.

[1]:
https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2024-12-04 09:54:12 +01:00
Shannon Sterz
115adf42bd acme-api: use inner mutability for ACME_ACME_CONFIG
in edition 2024 references to mutable static will be disallowed [1]. the
recommended way around this is to use types with inner mutability. so
use a `OnceLock` for `ACME_ACME_CONFIG` as the directoryfor ACME
configuration purposes shouldn't change throughout the run time of an
application.

[1]:
https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2024-12-04 09:53:51 +01:00
Maximiliano Sandoval
b256ee391c apt: repositories: remove unnecessary if-let in iterator
Fixes the manual_flatten clippy lint:

```
warning: unnecessary `if let` since only the `Some` variant of the iterator element is used
  --> proxmox-apt/src/repositories/mod.rs:40:5
   |
40 |       for digest in digests.values() {
   |       ^             ---------------- help: try: `digests.values().copied().flatten()`
   |  _____|
   | |
41 | |         if let Some(digest) = digest {
42 | |             common_raw.extend_from_slice(&digest[..]);
43 | |         }
44 | |     }
   | |_____^
   |
help: ...and remove the `if let` statement in the for loop
  --> proxmox-apt/src/repositories/mod.rs:41:9
   |
41 | /         if let Some(digest) = digest {
42 | |             common_raw.extend_from_slice(&digest[..]);
43 | |         }
   | |_________^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten
   = note: `#[warn(clippy::manual_flatten)]` on by default
```

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
FG: use `into_values().flatten()` instead of `values().copied().flatten()
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-12-03 13:50:23 +01:00
Maximiliano Sandoval
34c66e1542 sys: systemd: remove empty line after outer attribute
Fixes the clippy lint:

```
warning: empty line after outer attribute
 --> proxmox-sys/src/systemd.rs:7:1
  |
7 | / #[allow(clippy::manual_range_contains)]
8 | |
  | |_
9 |   fn parse_hex_digit(d: u8) -> Result<u8, Error> {
  |   ---------------------------------------------- the attribute applies to this function
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_outer_attr
  = note: `#[warn(clippy::empty_line_after_outer_attr)]` on by default
  = help: if the empty line is unintentional remove it
```

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-12-03 13:44:05 +01:00
Maximiliano Sandoval
c8d49a7d38 docs: remove empty lines in docs
Fixes the clippy lints:

```
warning: empty line after doc comment
  --> proxmox-lang/src/lib.rs:33:1
   |
33 | / /// ```
34 | |
   | |_
35 |   #[macro_export]
36 |   macro_rules! try_block {
   |   ---------------------- the comment documents this macro
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
   = note: `#[warn(clippy::empty_line_after_doc_comments)]` on by default
   = help: if the empty line is unintentional remove it

warning: empty line after doc comment
   --> proxmox-router/src/cli/mod.rs:308:5
    |
308 | /     /// Can be used multiple times.
309 | |
    | |_
310 |       /// Finish the command line interface.
311 |       pub fn build(self) -> CommandLineInterface {
    |       ------------------------------------------ the comment documents this method
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
    = note: `#[warn(clippy::empty_line_after_doc_comments)]` on by default
    = help: if the empty line is unintentional remove it
help: if the documentation should include the empty line include it in the comment
    |
309 |     ///
    |
```

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-12-03 13:44:05 +01:00
Maximiliano Sandoval
3f62a4dacf remove unnecessary return statement
Fixes the clippy lint:

```
warning: unneeded `return` statement
  --> proxmox-time/src/week_days.rs:31:14
   |
31 |         _ => return Err(parse_error(text, "weekday")),
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
   = note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
   |
31 |         _ => Err(parse_error(text, "weekday")),
   |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-12-03 13:44:05 +01:00
Maximiliano Sandoval
3492a0cee5 elide lifetimes where possible
This is possible on newer rustc.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-12-03 13:44:05 +01:00
Maximiliano Sandoval
4cb3579786 router: parsing: docs: fix 'instead' typo
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-12-03 13:44:05 +01:00
Maximiliano Sandoval
10b15fb2ad router: parsing: docs: fix Records::from link
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-12-03 13:44:05 +01:00
Maximiliano Sandoval
1b5e8ee0dd apt: repositories: use if-let instead of match for Option
Fixes the single_match clippy lint:

```
warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
  --> proxmox-apt/src/repositories/mod.rs:41:9
   |
41 | /         match digest {
42 | |             Some(digest) => common_raw.extend_from_slice(&digest[..]),
43 | |             None => (),
44 | |         }
   | |_________^ help: try: `if let Some(digest) = digest { common_raw.extend_from_slice(&digest[..]) }`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
   = note: `#[warn(clippy::single_match)]` on by default
```

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-12-03 13:44:05 +01:00
Maximiliano Sandoval
90e4dc5f8f api: webhook: doc: add indentation to list item
```
warning: doc list item without indentation
   --> proxmox-notify/src/api/webhook.rs:131:5
    |
131 | ///   (`400 Bad request`)
    |     ^^
    |
    = help: if this is supposed to be its own paragraph, add a blank line
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation
    = note: `#[warn(clippy::doc_lazy_continuation)]` on by default
help: indent this line
    |
131 | ///     (`400 Bad request`)
    |       ++
```

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-12-03 13:44:05 +01:00
Maximiliano Sandoval
8062e1abb3 apt: file: Use unwrap_or_default instead of match
Fixes the manual_unwrap_or_default clippy lint:

```
warning: match can be simplified with `.unwrap_or_default()`
   --> proxmox-apt/src/repositories/file.rs:369:30
    |
369 |               let mut origin = match repo.get_cached_origin(apt_lists_dir) {
    |  ______________________________^
370 | |                 Ok(option) => option,
371 | |                 Err(_) => None,
372 | |             };
    | |_____________^ help: replace it with: `repo.get_cached_origin(apt_lists_dir).unwrap_or_default()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default
    = note: `#[warn(clippy::manual_unwrap_or_default)]` on by default
```

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-12-03 13:44:05 +01:00
Thomas Lamprecht
9205e65d21 rest-server: bump version to 0.8.5
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-12-02 18:15:11 +01:00
Dominik Csapak
787c2e03d7 sys: open directories with O_CLOEXEC
Factor out the open-flags to use for directories and add the CLOEXEC
flag to ensure that open FDs do not get passed to any child process.

A prominent cases where this can happen is the proxmox-daemon reload
code, which re-execs itself in a forked child-process and thus gets
all FDs passed.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
 [ TL: expand doc-comment and reword commit message to point at actual
   thing this fixes (exec not daemon reload) ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-12-02 17:06:25 +01:00
Dominik Csapak
0547659e2c sys: fs: set CLOEXEC when creating temp files
In general we want all open files to have set CLOEXEC since our
reloading mechanism can basically fork at any moment and we don't want
newer daemons to carry around old file descriptors, especially lock
files.

Since `make_tmp_file` is called by many things (e.g. open_file_locked,
logrotate, rrd), set O_CLOEXEC with mkostemp.

This fixes issues with leftover file descriptors e.g. tape backups not
working because of lingering locks after a reload, or having deleted
rrd files open.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-12-02 16:59:44 +01:00
Fabian Grünbichler
b2d31f075d rest-server: increase task index lock timeout to 15s
this lock can be quite contended, until the surrounding code is properly split
to reduce this contention it should help to give the worker task
creation/cleanup code a bit more breathing room.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-12-02 16:56:46 +01:00
Fabian Grünbichler
57c8242dc2 rest-server: close race window when updating worker task count
this mimics how the count is updated when spawning a new task - the lock scope
needs to cover the count update itself, else there's a race when multiple
worker's log their result at the same time..

Co-developed-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-12-02 16:54:52 +01:00
Fabian Grünbichler
4e51ac3527 rest-server: handle failure in worker task setup correctly
if setting up a new worker fails after it has been inserted into the
WORKER_TASK_LIST, we need to clean it up instead of bubbling up the error right
away, else we "leak" the worker task and it never finishes..

a worker task that never finishes will indefinitely block shutdown
of the rest server process, including the "old" process when reloading
the rest server.

this issue was found in the wild on a system with lock contention on the
file-based lock covering task index updating leading to lock acquiring
timeouts.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-12-02 16:54:18 +01:00
Shannon Sterz
6e600c74a8 notify: use proxmox-sendmail forward implementation
moves to depending on `proxmox-sendmail` for forwarding mails via
`sendmail` too.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
2024-12-02 15:38:48 +01:00
Shannon Sterz
043fec42f8 sendmail: add mail-forwarder feature
this moves the mail forwarding implementation from `proxmox-notify` into
`proxmox-sendmail` to cover more `sendmail` related use-cases in one
place.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
2024-12-02 15:38:48 +01:00
Shannon Sterz
57c84dbfb5 notify: switch sendmail endpoint over to new crate
use the new `proxmox-sendmail` crate instead of the bespoke
implementation in `proxmox-notify`.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
2024-12-02 15:38:48 +01:00
Shannon Sterz
a69e86dff1 sendmail: add sendmail crate
add the `proxmox-sendmail` crate that makes it easier to send mails via
the `sendmail` utility. features include:

- multipart/alternative support for html+plain text mails
- multipart/mixed support for mails with attachments
- automatic nesting of multipart/alternative and multipart/mixed parts
- masks multiple receivers by default, can be disabled
- encoding Subject, To, From, and attachment file names correctly
- adding an `Auto-Submitted` header to avoid triggering automated mails

also includes several tests to ensure that mails are formatted
correctly. debian packaging is also provided.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
 [ TL: update years in d/copyright ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-12-02 15:38:48 +01:00
Thomas Lamprecht
8a1166be4b log: bump version to 0.2.7
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-27 13:31:57 +01:00
Gabriel Goller
cc79b2f08a log: ignore to_stdout parameter
This parameter causes the FileLogger to duplicate the log output to
stdout. This causes duplicate output on proxmox-backup-manager because
this is now handled by tracing. This should be removed completely in the
future.
In the worst case this will only result in missing log lines on stdout
(which is visible only on proxmox-backup-manager/client invocations
anyway).

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
 [ TL: add doc-comment to struct, note why it can be removed ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-27 13:29:14 +01:00
Thomas Lamprecht
7200cd7e23 time: bump version to 2.0.3-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-26 16:53:50 +01:00
Christian Ebner
17bc0ac616 time: also implement From<&TimeSpan> for f64
Extend the already present `From<TimeSpan> for f64` implementation to
allow using the reference as well. There is no need to take ownership
and consume the `TimeSpan` object for conversion.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-26 16:50:56 +01:00
Christian Ebner
548411808e time: fix typos in TimeSpan related docstring
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-26 16:50:56 +01:00
Thomas Lamprecht
f4868ff519 tree-wide: check in d/control meta changes for newer debcargo
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-26 14:44:33 +01:00
Thomas Lamprecht
42d1128d9d noitfy: bump version to 0.5.1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-26 14:38:56 +01:00
Thomas Lamprecht
bfe099f4f1 workspace: update proxmox-http-client to 0.9.4
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-26 14:37:43 +01:00
Lukas Wagner
dfe81b5db8 notify: webhook, gotify: set HTTP request timeout of 10s
By default, the sync client from proxmox-http (powered by ureq) does not
have any request timeout. To avoid blocking the current thread for a
prolonged period of time, we now make use of the previously added
`Client::new_with_timeout` function to create a new HTTP client with a
default timeout of 10 seconds.

In the long run it would be nicer to have a higher timeout here, say
60s, to cope with flaky and high-latency networks and potentially
overloaded targets. But for that we need to change the architecture of
how notifications are send out to ensure that now thread accepting
connections can be blocked.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
 [ TL: Change timeout from 5s to 10s as trade-off and expand commit
   message slightly with some reasoning for that still relatively
   short time value ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-26 14:12:57 +01:00
Thomas Lamprecht
6664b4150d http: bump version to 0.9.4
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-26 14:00:42 +01:00