Commit Graph

566 Commits

Author SHA1 Message Date
Dominik Csapak
dfcb50b690 tools/websocket: improve traits for WebSocketReader
by dropping unecessary trais for R
and impl Sync for ReaderState when R implements Sync

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 12:58:24 +02:00
Dominik Csapak
521b26d6a2 tools/websocket: require writer to be Unpin
so we can safely pin/unpin it

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 12:58:11 +02:00
Dominik Csapak
556df80841 tools/websocket: make mask not a reference
so we can drop the dereferencing, also use shorter syntax for mask_bit

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 12:57:56 +02:00
Dominik Csapak
d700327b8d tools: add Websocket helper
for now there is a helper for Reading and Writing
still missing is a utility for the handshake/accepting a connection

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 06:34:58 +02:00
Dominik Csapak
f74f33671a sys/linux: add PTY helper
for creating a PTY and make the secondary part a
controlling terminal for a child process

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 06:26:46 +02:00
Dominik Csapak
2cdddb8271 tools: add ByteBuffer
this is a Buffer struct that holds u8 and has convenience methods
for reading onto the back and consuming from the front

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 06:26:18 +02:00
Wolfgang Bumiller
5f9f3f373f cleanup: libc has 'getrandom' since 0.2.59
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-01 10:54:14 +02:00
Dietmar Maurer
2b6b94dd3a bump proxmox to 0.1.41-1 2020-06-26 10:36:35 +02:00
Dominik Csapak
d7165108cb api/router: percent decode the components of the uri
those can contain percent encoded values, so we have to decode them
before lookin up the path

this is especially important for the 'MatchAll' branch
when the parameter can contain some reserved characters

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-06-26 09:17:35 +02:00
Wolfgang Bumiller
53e7e76b5f bump proxmox to 0.1.40-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-12 13:56:00 +02:00
Wolfgang Bumiller
2eaea4b9ea tools: add mmap helper
Mmap<T> acts like a slice of `T`s, inhereting its `Send` and
`Sync` traits

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-12 13:54:12 +02:00
Wolfgang Bumiller
3516c9e2ec AsHex Display helper
This way we can use
    println!("something: {}", AsHex(bytes));

without having to turn them into an allocated string first.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-12 11:18:41 +02:00
Wolfgang Bumiller
c927b5ebba add TtyOutpu helper and use it for read_password
This way read_password() will not write the prompt into
stdout if stdout was redirected into a file, but instead
opens `/dev/tty`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-09 11:16:41 +02:00
Dietmar Maurer
620775d267 bump version to 0.1.39-1 2020-06-05 07:27:10 +02:00
Dominik Csapak
72974335a4 fix Permission::Privilege path check
when checking a path, we only pushed the components to the checked value
that would contain a parameter and not fixed ones

e.g. from the path components (with params datastore="foo")
["datastore", "{datastore}"]

only ["foo"] was given to the lookup_privs function
instead of ["datastore", "foo"]

this fixes an issue where e.g. a prune on /datastore/foo would fail
for a user that has the role DatastorePowerUser on /datastore (with
propagate) or /datastore/foo

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-06-05 07:24:15 +02:00
Dominik Csapak
2ca2559c94 add tests for check_api_permission
add tests for check_api_permission and many Permission combinations
this test fails for now and will be fixed with the next commit

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-06-05 07:14:50 +02:00
Dietmar Maurer
de2354bc3c bump version to 0.1.38-1 2020-05-28 09:51:42 +02:00
Dietmar Maurer
7b24c384b1 proxmox/src/tools/fs.rs: add additional helpers to get file contents 2020-05-28 09:49:45 +02:00
Dietmar Maurer
f42c189ee7 bump version toö 0.1.37-1 2020-05-26 12:55:04 +02:00
Dominik Csapak
60335cded0 proxmox: add string_as_base64 serde (de)serializer
this can be used to automatically convert string fields to base64

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-05-26 12:53:52 +02:00
Wolfgang Bumiller
c66fa6d8e1 bump proxmox to 0.1.36-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-05-25 12:12:07 +02:00
Wolfgang Bumiller
411e63ce29 procfs: iowait_percent fixup
Fix time delta calculation, and use old percentage when
querying more often than once a second.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-05-25 12:11:08 +02:00
Wolfgang Bumiller
438262b503 formatting fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-05-25 11:12:08 +02:00
Wolfgang Bumiller
e412ffdd37 bump proxmox to 0.1.35-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-05-25 11:11:21 +02:00
Wolfgang Bumiller
293293aa9b procfs: add loadavg reader
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-05-25 11:08:07 +02:00
Wolfgang Bumiller
e2da4921f6 make CLOCK_TICKS public
The ProcFsStat type uses values which need to be scaled by
it, so it makes sense to have this be public.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-05-25 11:08:07 +02:00
Wolfgang Bumiller
e5953f683c procfs: add iowait_percent
The calculation for this is based on the pve code.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-05-25 11:08:07 +02:00
Wolfgang Bumiller
ce84d19f63 procfs: don't count guest and guest_nice times twice
See the following kernel code snippet from
kernel/sched/cputime.c's account_guest_time():

    /* Add guest time to cpustat. */
    if (task_nice(p) > 0) {
        cpustat[CPUTIME_NICE] += cputime;
        cpustat[CPUTIME_GUEST_NICE] += cputime;
    } else {
        cpustat[CPUTIME_USER] += cputime;
        cpustat[CPUTIME_GUEST] += cputime;
    }

So the old sum was wrong as some time frames were counted
double in the `total` value.

The data will likely still deviate from PVE, but we should
check by how much, as this version does seem more accurate.
We can still fix it to just use the same math as pve if it
seems off.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-05-25 11:07:39 +02:00
Dietmar Maurer
c5b2694a44 bump version to 0.1.34-1 2020-05-20 13:17:55 +02:00
Dominik Csapak
10012dcb17 add 'constnamemap' macro
to be able to define constant values but still have some mapping to
the name of it

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-05-20 13:16:17 +02:00
Dietmar Maurer
34d09a5d07 pumb version to 0.1.33-1 2020-05-20 06:26:35 +02:00
Dietmar Maurer
2f8a28f34c proxmox/src/api/section_config.rs: simplify code 2020-05-20 06:25:07 +02:00
Dominik Csapak
b1fd556f3b section_config: fixup fallback schema in parse
we also have to fallback to the id_schema of the section_config when
we parse it, not only on write

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-05-20 06:16:34 +02:00
Dietmar Maurer
456e6eaa0b bump version to 0.1.32 2020-05-19 09:51:38 +02:00
Dominik Csapak
2f039380d2 proxmox: section_config: add convert_to_typed_array
converts a parsed section config to an Vector of typed items

this way we can simply get a list of users from the user config

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-05-19 09:09:47 +02:00
Dominik Csapak
e7a5768e04 proxmox: section_config: add id_property to SectionConfigPlugin
if set in the SectionConfigPlugin, we set the given
field to the section_id for each entry

this way we can have e.g. the userid in the Struct and ObjectSchema,
without having to write it twice to the config but we are still getting
it when parsing the config

when a plugin does not specify an id_property, then the id_schema of
the SectionConfig will be used as fallback

also adds a test for this with multiple plugins

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-05-19 09:08:49 +02:00
Dietmar Maurer
3283b4f25e bump version to 0.1.31-1 2020-05-18 09:50:37 +02:00
Dietmar Maurer
bd4b4bdc15 proxmox/src/api/rpc_environment.rs: use Value to store metadata
And impl. Index and IndexMut to make it easy to access/set the metadata.
2020-05-18 09:38:00 +02:00
Fabian Grünbichler
b450a72ffa update dependencies
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-05-18 09:33:52 +02:00
Wolfgang Bumiller
fa25b17cd0 api-macro: bump version to 0.1.9-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-05-18 09:17:35 +02:00
Dietmar Maurer
5fa994abb5 bump version to 0.1.30-1 2020-05-15 17:47:35 +02:00
Dietmar Maurer
3156e4c289 proxmox/src/tools/time.rs: binding for libc localtime/timelocal 2020-05-15 17:47:35 +02:00
Wolfgang Bumiller
7d6ecaa306 api-macro: remove more unnecessary parentheses
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-05-15 09:15:10 +02:00
Wolfgang Bumiller
b671b2fce2 api-macro: remove some unnecessary parentheses in output
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-05-14 15:39:40 +02:00
Dietmar Maurer
e375f2eb95 bump version to 0.1.29-1 2020-05-12 12:57:53 +02:00
Dietmar Maurer
faadd5bba5 proxmox/src/api/section_config.rs: make record_order public
It is sometimes usable to record the order.
2020-05-12 12:56:27 +02:00
Dietmar Maurer
3adcdacc22 bump version to 0.1.28-1 2020-05-12 09:15:47 +02:00
Dietmar Maurer
7d5a8fdda7 proxmox/src/api/section_config.rs: add support for systemd config files 2020-05-12 09:14:03 +02:00
Dietmar Maurer
414daabbcb proxmox/src/api/section_config.rs: support array properties 2020-05-12 08:27:23 +02:00
Dietmar Maurer
e847487b29 bump version to 0.1.27-1 2020-05-08 08:08:17 +02:00