Commit Graph

886 Commits

Author SHA1 Message Date
Dominik Csapak
5f4eace905 proxmox/tools/byte_buffer: improve ByteBuffer interface
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>
2020-07-15 12:33:18 +02:00
Wolfgang Bumiller
080b3b4329 tools::common_regex: add IPRE_BRACKET
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-14 09:48:55 +02:00
Wolfgang Bumiller
5eaadc1219 bump proxmox version to 0.2.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-10 11:04:20 +02:00
Wolfgang Bumiller
2904b622be bump api macro to 0.2.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-10 11:04:20 +02:00
Wolfgang Bumiller
e3800fb853 api-macro: test using return schemas within return objects
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-10 11:04:00 +02:00
Wolfgang Bumiller
0ce4c9eeb8 api-macro: reference consistency
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>
2020-07-10 10:56:29 +02:00
Wolfgang Bumiller
59467a11d6 completion: COMP_POINT is a codepoint count not a byte index
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-09 14:01:03 +02:00
Wolfgang Bumiller
aea0abf838 compile fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-07 14:45:15 +02:00
Wolfgang Bumiller
4f05a5d9f7 add websocket (default-)feature, make futures optional
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-07 12:06:34 +02:00
Wolfgang Bumiller
e65cc32cb8 make the proxmox crate without default features again
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-07 11:41:49 +02:00
Wolfgang Bumiller
ce859656ec some minor clippy lint cleanups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-07 09:44:50 +02:00
Wolfgang Bumiller
2aeeb83203 ByteBuffer: use T: AsyncRead, not AsyncReadExt
it's just weird otherwise

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-07 09:37:26 +02:00
Wolfgang Bumiller
7856139d72 test cleanups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-07 09:37:10 +02:00
Wolfgang Bumiller
a45555df07 ByteBuffer: don't require Sized on Read references
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-07 09:33:35 +02:00
Wolfgang Bumiller
8bae897ff6 ByteBuffer: actually test the doc comment code
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-07 09:32:16 +02:00
Wolfgang Bumiller
816015ed01 ByteBuffer: skip the temporary Vec
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>
2020-07-07 09:27:17 +02:00
Dietmar Maurer
f8ea74dfc1 bump version to 0.1.42-1 2020-07-03 13:01:48 +02:00
Dominik Csapak
68bddb9fed sys/linux/pty: add examples and docs
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 12:58:59 +02:00
Dominik Csapak
c734a627a8 tools/byte_buffer: add examples and docs
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 12:58:50 +02:00
Dominik Csapak
6fffca783e tools/websocket: add examples and docs
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 12:58:33 +02:00
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