Commit Graph

2405 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
Dietmar Maurer
c6f8eaf481 src/server/rest.rs: avoid compiler warning 2020-07-10 09:13:52 +02:00
Dietmar Maurer
991cc982c7 src/server/rest.rs: disable debug logs 2020-07-09 16:18:14 +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
Dominik Csapak
52148f892d improve 'debug' parameter
instead of checking on '1' or 'true', check that it is there and not
'0' and 'false'. this allows using simply

https://foo:8007/?debug

instead of

https://foo:8007/?debug=1

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-06-26 09:12:14 +02:00
Dietmar Maurer
fa9323b5c4 src/tools/daemon.rs: reopen STDOUT/STDERR journald streams to get correct PID in logs 2020-06-22 13:06:53 +02:00
Wolfgang Bumiller
ef783bdbef tools::daemon: sync with child after MainPid message
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-22 10:58:04 +02:00
Wolfgang Bumiller
93686a9ad7 tools::daemon: fetch exe name in the beginning
We get the path to our executable via a readlink() on
"/proc/self/exe", which appends a " (deleted)" during
package reloads.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-22 10:31:54 +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
Dominik Csapak
50fa6045b3 api2/status: use new rrd::extract_cached_data
and drop the now unused extract_lists function

this also fixes a bug, where we did not add the datastore to the list at
all when there was no rrd data

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-10 13:31:16 +02:00
Dominik Csapak
11cb8cd008 rrd: move creation of serde value into api
there is now a 'extract_cached_data' which just returns
the data of the specified field, and an api function that converts
a list of fields to the correct serde value

this way we do not have to create a serde value in rrd/cache.rs
(makes for a better interface)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-10 13:31:14 +02:00
Dominik Csapak
9a860821e4 refactor time functions to tools
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-10 13:31:10 +02:00
Dominik Csapak
20ada7a08c rrd: add 'extract_lists'
this is an interface to simply get the Vec<Option<f64>> out of rrd
without going through serde values

we return a list of timestamps and a HashMap with the lists we could find
(otherwise it is not in the map)

if no lists could be extracted, the time list is also empty

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-06-09 12:19:06 +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
Thomas Lamprecht
4e33373ca1 typo fixes all over the place
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-30 16:39:08 +02:00
Dietmar Maurer
1fa3341d68 rrd: reduce io by saving data only once a minute 2020-05-29 09:16:13 +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