by implementing Deref and DerefMut, renaming consume to 'remove_data'
adapt the usage inside of websocket (we did not use it anywhere else for now)
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
API_RETURN_* and API_PARAMETER_* schemas are no references
anymore to allow using them as external schemas via the
`"schema"` key inside object schemas inside the `#[api]`
macro.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
The docs say `into_boxed_slice()` "drops" excess capacity,
but doesn't specify whether that just means it becomes
inaccessible or the vector potentially reallocates to the
exact size.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>