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>
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>
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>
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>