Commit Graph

2138 Commits

Author SHA1 Message Date
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
Lukas Wagner
58b29dfbcf clippy fix: warning: this let-binding has unit value
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-08 11:29:36 +02:00
Lukas Wagner
b6abb52a78 clippy fix: binary comparison to literal Option::None
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-08 11:29:36 +02:00
Lukas Wagner
8f7566209c clippy fix: unnecessary use of to_string
See:
https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-08 11:29:36 +02:00
Lukas Wagner
b272279ef1 clippy fix: you should consider adding a Default implementation
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-08 11:29:36 +02:00
Lukas Wagner
268fcfb43a clippy fix: this (Default) impl can be derived
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-08 11:29:36 +02:00
Lukas Wagner
6f9cc14b9e clippy fix: redundant closure
See:
https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-08 11:29:36 +02:00
Lukas Wagner
82164203bd clippy fix: unneeded return statement
See:
https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-08 11:29:36 +02:00
Lukas Wagner
81ca4ae6a1 clippy fix: needless borrow
See:
https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-08 11:29:36 +02:00
Lukas Wagner
b4b186c544 clippy fix: calls to drop with a value that implements Copy
Dropping a copy leaves the original intact

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

I assume the `drop` was used to silence a 'unused variable' warning,
so I silenced it by other means.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-08 11:29:36 +02:00
Lukas Wagner
de6337ae6d clippy fix: the borrowed expression implements the required traits
See: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-08 11:05:20 +02:00
Dietmar Maurer
b7a64cd4a2 proxmox-login: depend on js_sys on wasm32
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-08-07 12:03:49 +02:00
Dietmar Maurer
ffa64bead7 add special impl for epoch_i64() on target_arch="wasm32" 2023-08-07 11:56:15 +02:00
Wolfgang Bumiller
17f5eac57a client: drop Send for non-wasm as well on response future
To see if it is even still necessary given that it's not a trait
object type where auto traits would need to be explicit...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-07 11:06:10 +02:00
Wolfgang Bumiller
1531a619ab client: rename response future to ResponseFuture
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-07 10:59:07 +02:00
Wolfgang Bumiller
a7435e757b client: drop retry logic
This should be moved to where we actually need it, not be part of the
generic product client.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-07 10:57:39 +02:00
Dietmar Maurer
2b212cf4e3 proxmox-client: do not require Send for wasm32 target
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-08-05 09:10:28 +02:00
Wolfgang Bumiller
748588f81c proxmox-login: add 'source' impls for errors
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-03 13:03:30 +02:00
Wolfgang Bumiller
34a79cdd0c bump proxmox-api-macro to 1.0.5-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-03 08:25:13 +02:00
Wolfgang Bumiller
ba6a628601 client: getters for the inner client
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-03 08:22:45 +02:00
Dietmar Maurer
9599cb6fd6 proxmox-login: fix ticket userid check for PMG quarantine tickets
We simply strip the "@quarantine" at the end.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-08-02 15:10:44 +02:00
Wolfgang Bumiller
25024fa687 import proxmox-client crate
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-01 15:49:43 +02:00
Wolfgang Bumiller
a9191c2253 update README
include repository.workspace=true for the [package] base section

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-01 15:48:19 +02:00
Wolfgang Bumiller
d6a550b71c login: improve response handling
we have use cases where we have bytes, and serde_json has a from_slice
method, doing the utf-8 check unnecessarily is pointless, while going
from &str to &[u8] is free...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-01 15:21:09 +02:00
Wolfgang Bumiller
5859017061 bump proxmox-notify to 0.2.0
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-28 11:56:56 +02:00
Wolfgang Bumiller
17cf5f9593 more import cleanups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-28 11:47:39 +02:00
Wolfgang Bumiller
7cb339dfa3 notify: cleanup all the imports sections
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-28 11:47:39 +02:00
Wolfgang Bumiller
985717d948 bump proxmox-router to 2.1.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-28 11:26:01 +02:00
Wolfgang Bumiller
1ce7294e06 http-error: add debian packaging and bump as 0.1.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-28 11:06:48 +02:00
Lukas Wagner
1a75668dc9 notify: use HttpError from proxmox-http-error
Also improve API documentation in terms of which HttpError is
returned when.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-28 10:47:07 +02:00
Lukas Wagner
add38769f8 router: re-export HttpError from proxmox-http-error
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-28 10:47:05 +02:00
Lukas Wagner
779c45eaad http-error: add new http-error crate
Break out proxmox-router's HttpError into it's own crate so that it can
be used without pulling in proxmox-router.

This commit also implements `Serialize` for `HttpError` so that it can
be returned from perlmod bindings, allowing Perl code to access the
status code as well as the message.

Also add some smoke-tests to make sure that the `http_bail` and
`http_err` macros actually produce valid code.

Suggested-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-28 10:47:03 +02:00
Lukas Wagner
a1cbaea766 notify: fix tests if not all features are enabled
Some tests are now disabled if not all required features are enabled.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-28 10:43:57 +02:00
Lukas Wagner
f6fa851d1f notify: fix build warnings if not all features are enabled
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-28 10:43:55 +02:00
Wolfgang Bumiller
1e095e5ab8 bump proxmox-notify to 0.1.0-1, initial release
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-24 11:05:45 +02:00
Wolfgang Bumiller
d951b3329f bump proxmox-auth-api to 0.3.1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-24 11:03:49 +02:00