Commit Graph

758 Commits

Author SHA1 Message Date
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
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
Dietmar Maurer
dcf220db80 bump proxmox version to 0.3.5-1 2020-09-04 06:37:16 +02:00
Dominik Csapak
db1da0f645 tools/time: give tm struct as mut reference
mktime/timegm can modify the timestruct (to normalize the time, e.g.
convert the january 40 to february 9)

to use that feature, we have to give a mutable reference, else the
struct will be copied and the original left untouched

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-09-04 06:27:58 +02:00
Wolfgang Bumiller
c0d2165d75 and run rustfmt over another big chunk of code
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-28 08:59:26 +02:00
Wolfgang Bumiller
ba7c389142 more formatting fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-28 08:56:54 +02:00
Wolfgang Bumiller
bbc94222f5 formatting fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-28 08:55:16 +02:00
Dietmar Maurer
001f2525fa bump proxmox to 0.3.4-1 2020-08-28 06:25:36 +02:00
Hannes Laimer
66004f22c6 email: add small function to send multi-part emails using sendmail
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
2020-08-28 06:23:54 +02:00
Wolfgang Bumiller
aef02efce3 bump proxmox to 0.3.3-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-10 11:30:49 +02:00
Wolfgang Bumiller
6cd1aac558 add serde forwarding convenience macros
* forward_deserialize_to_from_str
* forward_serialize_to_display

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-10 09:38:50 +02:00
Wolfgang Bumiller
6da4dd5bbb clippy: use matches for if let -> bool
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-04 16:24:13 +02:00
Wolfgang Bumiller
66ae742cb3 bump proxmox dep to 0.3.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-04 11:12:11 +02:00
Wolfgang Bumiller
9da029a8c3 tools/mod.rs: sort modules
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-04 10:29:03 +02:00
Wolfgang Bumiller
570f89f6a5 add lock_file and open_file_locked
to proxmox::tools::fs

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-04 09:31:15 +02:00
Wolfgang Bumiller
401ba6f927 add proxmox::sys::timer module (moved from proxmox-backup)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-04 09:27:59 +02:00
Wolfgang Bumiller
d34e00af0c move uuid serde code to uuid.rs
And avoid the temporary string allocation where possible.

Implementing foreign traits in external modules is bad
practice. The `serde` module is for implementations which
deviate from the expected default.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-03 11:25:25 +02:00
Dietmar Maurer
f2230ad2ab bump version to 0.3.1-1 2020-08-02 11:52:25 +02:00
Dietmar Maurer
a7390a3d0e Uuid: implement Serlialize/Deserialize 2020-08-02 11:50:26 +02:00