Commit Graph

2405 Commits

Author SHA1 Message Date
Thomas Lamprecht
a049949d14 server/rest: code cleanup: use async
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-12 13:36:45 +02:00
Fabian Grünbichler
16f05d6649 REST: don't print CSRF token
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-10-08 15:57:22 +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
Thomas Lamprecht
d2b63c504a REST server: avoid hard coding world readable API endpoints
while we probably do not add much more to them, it still looks ugly.

If this was made so that adding a World readable API call is "hard"
and not done by accident, it rather should be done as a test on build
time. But, IMO, the API permission schema definitions are easy to
review, and not often changed/added - so any wrong World readable API
call will normally still caught.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-05 08:29:43 +02:00
Thomas Lamprecht
c6ab240333 rest server: cleanup use statements
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-02 13:04:08 +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
Stefan Reiter
6eff0b289e rrd: fix integer underflow
Causes a panic if last_update is smaller than RRD_DATA_ENTRIES*reso,
which (I believe) can happen when inserting the first value for a DB.

Clamp the value to 0 in that case.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-10-01 14:30:32 +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
dc12cf44aa avoid chrono dependency, depend on proxmox 0.3.8
- remove chrono dependency

- depend on proxmox 0.3.8

- remove epoch_now, epoch_now_u64 and epoch_now_f64

- remove tm_editor (moved to proxmox crate)

- use new helpers from proxmox 0.3.8
  * epoch_i64 and epoch_f64
  * parse_rfc3339
  * epoch_to_rfc3339_utc
  * strftime_local

- BackupDir changes:
  * store epoch and rfc3339 string instead of DateTime
  * backup_time_to_string now return a Result
  * remove unnecessary TryFrom<(BackupGroup, i64)> for BackupDir

- DynamicIndexHeader: change ctime to i64

- FixedIndexHeader: change ctime to i64
2020-09-15 07:12:57 +02:00
Dietmar Maurer
110ceff08c avoid chrono dependency, depend on proxmox 0.3.8
- remove chrono dependency

- depend on proxmox 0.3.8

- remove epoch_now, epoch_now_u64 and epoch_now_f64

- remove tm_editor (moved to proxmox crate)

- use new helpers from proxmox 0.3.8
  * epoch_i64 and epoch_f64
  * parse_rfc3339
  * epoch_to_rfc3339_utc
  * strftime_local

- BackupDir changes:
  * store epoch and rfc3339 string instead of DateTime
  * backup_time_to_string now return a Result
  * remove unnecessary TryFrom<(BackupGroup, i64)> for BackupDir

- DynamicIndexHeader: change ctime to i64

- FixedIndexHeader: change ctime to i64
2020-09-15 07:12:57 +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
Dietmar Maurer
99351a7752 bump proxmox version to 0.3.7 2020-09-13 16:16:37 +02:00
Dietmar Maurer
b975317a47 fix epoch_as_rfc3339 serializer 2020-09-13 16:13:19 +02:00
Dietmar Maurer
d42fc47c4d src/tools/serde.rs: implement epoch_as_rfc3339 serializer 2020-09-13 11:52:46 +02:00
Dietmar Maurer
b164904a4f src/tools/time.rs: rename rfc_3339 to rfc3339 2020-09-13 11:42:15 +02:00
Dietmar Maurer
317d1a78fb src/tools/email.rs: avoid chrono dependency 2020-09-13 11:31:31 +02:00
Dietmar Maurer
8405dd740c src/tools/time.rs: add parse_rfc_3339 2020-09-13 11:09:20 +02:00
Dietmar Maurer
11ef587edd src/tools/time/tm_editor.rs: copied from proxmox backup 2020-09-13 11:02:52 +02:00
Dietmar Maurer
3aa8e22b0c proxmox/src/tools/time.rs: add epoch_to_rfc_3339 2020-09-13 10:51:27 +02:00
Dietmar Maurer
fb4e426a0a proxmox/src/tools/time.rs: fix previous commit 2020-09-12 15:07:12 +02:00
Dietmar Maurer
5eb5b21044 bump proxmox version to 0.3.6-1 2020-09-12 15:01:46 +02:00
Dietmar Maurer
9f837a4333 proxmox/src/tools/time.rs: add strftime bindings 2020-09-12 14:59:31 +02:00