Commit Graph

886 Commits

Author SHA1 Message Date
Fabian Ebner
63b9f31c7b fix prefix for nested commands
Fixes a regression from commit f50a627f34
which resulted in re-using the prefix without sub-commands when calling
handle_simple_command(_future)

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-11-05 11:18:03 +01:00
Wolfgang Bumiller
8a9a87bbf4 tfa: make AuthResponse fields public
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-11-04 13:21:41 +01:00
Wolfgang Bumiller
ad8fc652f6 make u2f registration challenge Deserialize
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-11-02 13:07:38 +01:00
Wolfgang Bumiller
a6f8f84632 make u2f attestation certificate optional
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-11-02 12:49:47 +01:00
Wolfgang Bumiller
31b7620f20 bump proxmox to 0.7.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-10-30 15:15:32 +01:00
Wolfgang Bumiller
6255336f04 totp: rename step to period
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-10-30 15:13:42 +01:00
Wolfgang Bumiller
0cd88fd832 bump proxmox to 0.6.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-10-29 15:04:07 +01:00
Wolfgang Bumiller
8cbf9cb7c8 add proxmox::tools::tfa
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-10-29 15:01:26 +01:00
Wolfgang Bumiller
05749ab419 test fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-10-29 14:51:22 +01:00
Fabian Grünbichler
51f5acea22 rpcenv: rename user to auth_id
since it does no longer store just a userid, but potentially an API
token identifier as well

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-10-29 13:59:24 +01:00
Thomas Lamprecht
7d34e6f3a4 api macro: reuse generated default const for "unwrap_or"
Instead of setting a default value to a const and inside an
.unwrap_or_else closure, lets set it only to the const and reuse that
later in .unwrap_or

To achieve that we move the "unrwap_or" code for param plumbing code generation
a bit later so that we have easy access to the generated const name.
As all this code is related to optional/default-value stuff it does read still
relatively OK with that change, IMO.

This has the advantage of not getting a warning like:

>  warning: constant is never used: `API_METHOD_EXAMPLE_FOO_PARAM_DEFAULT_FORCE`
>   --> src/api2/node/foo.rs
>    |
> XY |             force: {
>    |             ^^^^^
>    = note: `#[warn(dead_code)]` on by default

When one has a API endpoint like:

> #[api(
>     input: {
>         properties: {
>             force: {
>                 type: bool,
>                 optional: true,
>                 default: false,
>             },
>         },
>     },
>     ...
> )]
> /// Example
> fn example_foo(force: bool) -> Result<(), Error> {
>     if force {
>         // do something
>     }
>     Ok(())
> }

It effectively changes the output for optional parameters with a default set
and no Option<T> from

> let p = p.unwrap_or_else(|| #default_value);

to

> let p = p.unwrap_or(#const_name_for_default);

where the "#const_name_for_default" is a pub const with value
"#default_value"

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-27 09:17:12 +01:00
Thomas Lamprecht
7575f890ed tools fs: fix comment typo and strange glyph
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-20 18:46:50 +02:00
Wolfgang Bumiller
fe652c9263 bump proxmox version to 0.5.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-10-19 12:32:51 +02:00
Wolfgang Bumiller
9cd97f9851 proxmox::tools::fs: remove deprecated functions
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-10-19 12:32:37 +02:00
Fabian Grünbichler
daab5a9faf proxmox: bump nix dependency
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-10-19 12:11:50 +02:00
Dietmar Maurer
f3c10cc9df bump proxmox version to 0.4.4-1 2020-10-16 10:30:22 +02:00
Thomas Lamprecht
88586e9343 api: RPC environment: add client IP getter/setter to trait
This is similar to what we have in PVE and PMG now. Will be used to
set the real client IP for proxied connections.

with a dummy implementation, which avoids the need to implement it
for the CLI or Backup environments, which do not have or care for a
client IP

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-14 13:53:04 +02:00
Wolfgang Bumiller
e5456f873d clippy fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-10-14 11:13:20 +02:00
Dietmar Maurer
75bc02d9db bump proxmox version to 0.4.3-1 2020-10-08 09:00:22 +02:00
Thomas Lamprecht
82172720a4 tools: change constnamemap to a more automatic constnamedbitmap
We only used this for the privileges for now, and there it's a
nuisance to alter all bit definitions manually if something is added.

This change makes it count the bits up automatically.

Rename the macro to indicate that this is not a generic name map but
a more specific named bit mapping.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-08 08:54:26 +02:00
Wolfgang Bumiller
19dc729b7b formatting fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-10-05 12:04:22 +02:00
Wolfgang Bumiller
9fa9c76a9c improve error messages in parse_rfc3339
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-10-05 09:16:51 +02:00
Wolfgang Bumiller
307cb04795 big formatting cleanup
had to be done, sorry not sorry

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-10-02 10:00:04 +02:00
Wolfgang Bumiller
ef5c719150 formatting fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-10-02 09:59:52 +02:00
Dominik Csapak
ef6ccff5d1 proxmox/tools/common_regex: improve IPRE_BRACKET
by disallowing [] around ipv4 adresses (which is not very common)

we did not use this anywhere, so there should not be any compatibility
problem

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-09-30 06:13:58 +02:00
Dietmar Maurer
d79e1cfefe bump version to 0.4.2-1 2020-09-28 10:06:28 +02:00
Dietmar Maurer
f9763e12f9 simplify open_file_locked 2020-09-28 09:16:53 +02:00
Dominik Csapak
5440c65787 proxmox/tools/fs: create tmpfile helper
by factoring out the code we had in 'replace_file'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-09-28 07:09:02 +02:00
Dominik Csapak
115f003742 proxmox/tools/fs: add shared lock helper
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-09-28 07:02:48 +02:00
Wolfgang Bumiller
b9552a97e9 module consistency
tools/time.rs -> tools/time/mod.rs
sys/linux/procfs.rs -> sys/linux/procfs/mod.rs

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-09-22 09:02:15 +02:00
Thomas Lamprecht
29ed80c0a7 d/changelog: fixup email address
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-09-21 16:52:58 +02:00
Dietmar Maurer
c0a376058a bump version to 0.4.1-1 2020-09-21 10:22:52 +02:00
Dietmar Maurer
48d049d4bf proxmox/src/tools/email.rs: use slice instead of Vec 2020-09-21 10:03:48 +02:00
Dietmar Maurer
2702a2a7b5 bump versions to proxmox 0.4.0 and proxmox-api-macro 0.2.2 2020-09-19 06:32:06 +02:00
Dominik Csapak
3458d3fa69 api-macro: replace ident hashmap with simple find
after benchmarking (again), i found that doing a simple find instead
of saving the inidices for the ident strings in a hashmap has
no real performance impact (the max list size for the properties
are max ~25 at the moment, so this should not be impacting compile
times much) but it is much simpler

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-09-19 06:28:36 +02:00
Fabian Grünbichler
3be70bc4a8 permissions: introduce UserParam permission
to safely differentiate between checking
- the current user matches some static string
- the current user matches the value in some (path) parameter.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-09-18 18:20:01 +02:00
Dietmar Maurer
f84ac35804 bump version to 0.3.9, api-macro dependency to 0.2.1 2020-09-17 08:33:17 +02:00
Dietmar Maurer
2fb7f4a312 bump proxmox-api-macro version to 0.2.1-1 2020-09-17 08:26:25 +02:00
Dominik Csapak
958e72aa69 api-macro: relax Fieldname rules
by replacing more characters ('.','+') by '_' and prefix them when
it starts with a number

we sometimes need to parse such fields, e.g in serde attributes like
 #[serde(rename = "802.3ad")]

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-09-17 08:21:17 +02:00
Dominik Csapak
29763449f0 api-macro: fix broken binary ident search
the 'properties_' list is sorted by the the literal string of a
fieldname, but we binary-search for the 'ident_str' (which may be
different, since we map '-' to '_' for example)

by creating a hashmap to map from ident to index, we can do a simple
lookup in that case that will work

benchmarks showed no measurable performance difference

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-09-17 08:20:44 +02:00
Fabian Grünbichler
94c96348a7 time: add tests for gmtime range
mainly so we notice if this assumption does not hold for some platform
or changes in the future.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-09-15 13:13:40 +02:00
Fabian Grünbichler
0830d33e99 time/rfc3339: add leading zeroes for years < 1000
strftime(3) does not mention this explicitly, but years before 1000 have
their leading zero(es) stripped, which is not valid according to either
ISO-8601 or its profile RFC3339.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-09-15 13:13:29 +02:00
Fabian Grünbichler
c698d4b889 time: add tests for RFC3339 corner cases
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-09-15 13:13:17 +02:00
Fabian Grünbichler
ceefaa8095 time: allow leap seconds when parsing RFC3339
we don't ever produce those, but they are valid RFC3339 strings

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-09-15 13:12:58 +02:00
Fabian Grünbichler
ed7c58cf47 time: add test for leap second parsing/converting
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-09-15 13:12:23 +02:00
Dietmar Maurer
8cb07ac905 bump proxmox version to 0.3.8-1 2020-09-14 13:41:14 +02:00
Dietmar Maurer
c295aa961c remove chrono dependency and related code 2020-09-14 13:38:53 +02:00
Dietmar Maurer
3efc4d244b check year in epoch_to_rfc3339, new helpers strftime_local and strftime_utc 2020-09-14 12:43:49 +02:00
Dietmar Maurer
557cce7ae0 new helpers epoch_i64 and epoch_f64
These helpers use rust std SystemTime. Removed the libc time() binding.
2020-09-14 10:45:34 +02:00
Dietmar Maurer
e3b62ae3b2 proxmox/src/tools/serde.rs: fix epoch_as_rfc3339 doctest 2020-09-13 16:20:56 +02:00