Commit Graph

72 Commits

Author SHA1 Message Date
Dietmar Maurer
3578d99f3e move normalize_path to tools::normalize_uri_path 2019-05-07 09:44:34 +02:00
Wolfgang Bumiller
d82ed9b0f5 tools: add AsyncMutex
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-04-29 14:19:03 +02:00
Dietmar Maurer
490be29ed6 src/tools/broadcast_future.rs: new helper class 2019-04-26 17:57:57 +02:00
Wolfgang Bumiller
efd1536eb7 add a wrapper around nix::unistd::pipe2
Using O_CLOEXEC by default, and returning Fd handles to
ensure they get dropped on bail!() or panic!() if the RawFds
aren't used yet.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-04-25 11:02:12 +00:00
Wolfgang Bumiller
897982e237 tools: add read/write convenience helpers
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-04-25 11:02:12 +00:00
Wolfgang Bumiller
d96bb7f163 tools: add Fd helper
stores a raw file descriptor with a drop handler for
safekeeping in closures

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-04-10 15:20:10 +02:00
Dietmar Maurer
7a630df709 implement server state/signal handling, depend on tokio-signal 2019-04-08 13:59:07 +02:00
Dietmar Maurer
35950380a9 src/server/worker_task.rs: carefully handle file permissions 2019-04-06 17:53:12 +02:00
Dietmar Maurer
1619a72063 src/tools.rs: implement create_dir_chown
Combinded mkdir with chown.
2019-04-06 16:50:23 +02:00
Dietmar Maurer
eea8131952 src/tools.rs: implement file_set_contents_full() 2019-04-06 13:53:43 +02:00
Dietmar Maurer
49cf9f3d0b src/tools.rs: file_get_json() - add new default parameter 2019-04-04 12:24:18 +02:00
Dietmar Maurer
3c2012f97a src/tools/procfs.rs: start helper tools to read procfs 2019-04-03 13:39:20 +02:00
Dietmar Maurer
92da93b245 abort GC on server shutdown 2019-04-01 12:13:02 +02:00
Dietmar Maurer
9136f857cc add global var to indicate server shutdown requests 2019-04-01 12:05:11 +02:00
Dietmar Maurer
a650f50301 src/tools/process_locker.rs: implement inter-process reader-writer locks 2019-03-22 08:05:51 +01:00
Wolfgang Bumiller
eb90c9e372 tools: style fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-03-20 09:57:13 +01:00
Wolfgang Bumiller
dce94d0e09 tools: add daemon helpers
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-03-18 12:29:18 +01:00
Wolfgang Bumiller
ff7049d481 tools: add fd_change_cloexec helper
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-03-18 12:29:18 +01:00
Dietmar Maurer
806500cd09 src/tools.rs: improve file name completion
Use current working directory by default.
2019-03-14 08:17:35 +01:00
Dietmar Maurer
496a67846f src/cli/command.rs: pass parsed parameters to completion function 2019-03-12 14:39:51 +01:00
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