Commit Graph

152 Commits

Author SHA1 Message Date
Wolfgang Bumiller f54c19989c tools: add async signalfd handler
This provides a Stream<Item = siginfo> via nix' signalfd,
by wrapping it in tokio's PollEvented2 struct to allow
polling via tokio's event loop.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-03-12 08:04:28 +01:00
Dietmar Maurer 53cafb5925 src/tools.rs: impl file_get_json() 2019-03-05 12:56:21 +01:00
Dietmar Maurer af926291e0 avoid compiler warning 2019-03-03 09:52:06 +01:00
Dietmar Maurer f5f13ebc5a src/tools.rs: new helper json_object_to_query 2019-03-03 08:51:37 +01:00
Dietmar Maurer af53186e6a src/tools.rs: add simply string join 2019-03-02 16:15:45 +01:00
Dietmar Maurer 3b151414f8 src/tools/file_logger.rs: class to log into files 2019-03-01 09:34:29 +01:00
Wolfgang Bumiller fded74d0c7 style: BufferedReader -> BufferedRead
Single-method traits usually use the same name as their
method and aren't usually the 'noun' (which is usually an
implementation of them instead).

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-02-28 15:26:40 +01:00
Dietmar Maurer f8dfbb45c0 src/tools.rs: new helper required_array_param() 2019-02-26 08:48:17 +01:00
Wolfgang Bumiller c9b296f117 tools: add tty helper module
with read_password() and stdin_isatty() functions

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-02-20 14:43:07 +01:00
Dietmar Maurer 12400210a2 tools::file_get_contents - improve error message 2019-02-16 09:42:00 +01:00
Dietmar Maurer 6235a41862 tools::file_read_firstline - improve error message 2019-02-16 09:36:29 +01:00
Dietmar Maurer 5d14eb6a76 tools.rs: new helper to get uid/gid for the sepcified system user.
Or is there an easier way to get that info?
2019-02-15 15:33:12 +01:00
Dietmar Maurer fe651dd6e5 tools.rs: fix doc tests 2019-02-15 11:33:51 +01:00
Dietmar Maurer e80503d2a6 tools.rs: document try_block macro 2019-02-15 11:20:45 +01:00
Dietmar Maurer f0dbba8cbe tools.rs: new try_block macro 2019-02-15 10:59:12 +01:00
Wolfgang Bumiller 121f18efb7 tools: use scan_subdir iterator for scandir
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-02-14 10:09:59 +01:00
Wolfgang Bumiller b4d5787de9 tools: start fs submodule, add read_subdir
This creates an iterator relative to a RawFd via
nix::dir::Dir over nix::dir::Entrys.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-02-14 10:09:59 +01:00
Wolfgang Bumiller 6ed25cbe3a tools: add Tied value
Tie two dependent values together, such as a nix::Dir with
its nix::dir::Iter<'a> where 'a is tied to the Dir's
lifetime, making it otherwise impossible to return them or
store them in a struct.

Alternatively we could try the 'rental' crate.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-02-12 10:39:11 +01:00
Wolfgang Bumiller a7cac14ed9 tools: use std::fs::read for file_get_contents
Until we add the extra options like we have in pve, just use
the already existing (since 1.26) shortcut.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-02-04 15:35:32 +01:00
Dietmar Maurer b9903d6331 server/rest.rs: verify auth cookie 2019-01-31 12:22:00 +01:00
Dietmar Maurer 8d04280b29 tools/ticket.rs: add basic ticket support 2019-01-29 12:59:07 +01:00
Dietmar Maurer 1631c54fca tools::get_hardware_address - fix FILENAME, use file_get_contents() 2019-01-25 12:23:47 +01:00
Dietmar Maurer af2fddea4f api2/node/dns.rs: implement concurrent update protection 2019-01-25 11:38:59 +01:00
Dietmar Maurer 2296860027 tools.rs: move digest_to_hex() into tools 2019-01-25 10:58:28 +01:00
Dietmar Maurer 53157ca6cf tools.rs: implement file_get_contents() 2019-01-25 10:44:40 +01:00
Dietmar Maurer 8f973f8181 api2/node/dns.rs: implement resolv.conf parser 2019-01-24 14:59:40 +01:00
Dietmar Maurer 447787ab7c tools.rs: implement file_read_firstline 2019-01-24 10:43:30 +01:00
Dietmar Maurer 7e13b2d67f api2/subscription.rs: add subscription api class 2019-01-22 12:50:19 +01:00
Dietmar Maurer cce1676a9e tools.rs: use FnMut for scandir callback 2019-01-20 17:49:11 +01:00
Dietmar Maurer 443f3743bb tools.rs: new scandir() helper 2019-01-20 17:31:43 +01:00
Dietmar Maurer 7f0d67cf79 tools/wrapped_reader_stream.rs: new helper class
Will use that to download catar files.
2019-01-20 09:38:28 +01:00
Dietmar Maurer 383e857749 move complete_file_name() helper into tools.rs 2019-01-18 13:42:52 +01:00
Dietmar Maurer 0d38dcb43c cleanup nodename() 2019-01-18 10:13:45 +01:00
Dietmar Maurer 74a69302a7 tools.rs: new helper nodename() 2019-01-18 09:58:15 +01:00
Dietmar Maurer 0fe5d605e7 tools.rs: new helper required_string_param()
To extract parameters from Value.
2019-01-17 12:14:02 +01:00
Dietmar Maurer 318564ac03 buffered_read: return empty buffer on eof 2019-01-06 09:17:28 +01:00
Dietmar Maurer 0a72e26704 define and use BufferedReader trait 2019-01-05 17:28:20 +01:00
Dietmar Maurer 51b499db74 tools.rs: improve docs 2019-01-05 16:53:28 +01:00
Dietmar Maurer 95bd5dfec7 src/catar/encoder.rs: correctly sort goodby items 2018-12-29 17:00:48 +01:00
Dietmar Maurer 50ea43962e make map_struct functions public 2018-12-28 08:04:46 +01:00
Dietmar Maurer dc3de618ed new helper map_struct and map_struct_mut 2018-12-27 09:20:17 +01:00
Dietmar Maurer 28b96b56e1 open_file_locked: improve error message 2018-12-22 15:59:55 +01:00
Dietmar Maurer eae8aa3aa9 cleanups: avoid compiler warnings 2018-12-19 12:49:23 +01:00
Wolfgang Bumiller 1628a4c731 use timers with a signal for file locking
* rename lock_file -> open_file_locked,
* add lock_file as a function working on already-opened
  files
* change timeout types to std::time::Duration

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-12-19 11:23:00 +01:00
Wolfgang Bumiller 8cf6e764ad add tools::timer module
This wraps POSIX timers via timer_create(2).

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-12-19 11:23:00 +01:00
Dietmar Maurer 365bb90f17 move lock_file to tools.rs 2018-12-19 10:02:24 +01:00
Dietmar Maurer 606ce64bb0 image_index.rs:write idx of chunks (use mmap) 2018-12-15 14:51:05 +01:00
Dietmar Maurer 5f0c2d5652 remove debug println 2018-12-15 11:16:27 +01:00
Dietmar Maurer 43eeef28d1 move file_chunker to tools 2018-12-15 11:14:41 +01:00
Dietmar Maurer d64d80d20a add comment 2018-12-12 11:23:04 +01:00
Dietmar Maurer 1a7bc3dd5e file_set_contents: correctly use perm parameter 2018-12-09 16:41:54 +01:00
Dietmar Maurer f12f8ff1a6 implement tools::file_set_contents 2018-12-09 16:37:48 +01:00