Commit Graph

2894 Commits

Author SHA1 Message Date
Dietmar Maurer
3bbbece6a2 handle_async_api_request: put rpcenv into a Box
So that we can pass rpcenv into futures.
2019-05-09 18:01:24 +02:00
Dietmar Maurer
d5901112de src/server/formatter.rs: further cleanups and renaming ... 2019-05-09 13:28:26 +02:00
Dietmar Maurer
5b91995837 src/server/formatter.rs: rename format_result to format_data
To avoid confusions with Rust Result type.
2019-05-09 13:15:15 +02:00
Dietmar Maurer
1b61b80482 src/api2/admin/datastore/backup.rs: implement upload chunk 2019-05-09 13:06:09 +02:00
Dietmar Maurer
66f849d272 rc/api2/admin/datastore/h2upload.rs: implement BackupEnvironment
To pass arbitrary information/state to api methods.
2019-05-08 11:26:54 +02:00
Dietmar Maurer
010e7b80a8 src/server/rest.rs: use generics to pass RpcEnvironment 2019-05-08 11:09:01 +02:00
Dietmar Maurer
19b33e55af src/server/rest.rs: make handle_(a)sync_api_request public 2019-05-07 11:23:52 +02:00
Dietmar Maurer
16b5c3c80b RestEnvironment: derive Clone 2019-05-07 11:09:18 +02:00
Dietmar Maurer
e53d4dadaa move normalize_path to tools::normalize_uri_path 2019-05-07 09:44:34 +02:00
Dietmar Maurer
83f663b7a3 src/server/state.rs: use new BroadcastData helper 2019-04-30 10:21:48 +02:00
Wolfgang Bumiller
88aaa1841a use double-fork for reload
To ensure the new process' parent is pid 1, so systemd won't
complain about supervising a process it does not own.

Fixes the following log spam on reloads:
Apr 25 10:50:54 deb-dev systemd[1]: proxmox-backup.service: Supervising process 1625 which is not our child. We'll most likely not notice when it exits.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-04-25 11:02:12 +00:00
Wolfgang Bumiller
30150eef0f use service Type=notify
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-04-25 11:01:33 +00:00
Wolfgang Bumiller
efd898a71c tools/daemon: add sd_notify wrapper
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-04-25 11:01:28 +00:00
Wolfgang Bumiller
e6bdfe0674 api_schema: allow generic api handler functions
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-04-16 11:22:23 +02:00
Dietmar Maurer
3e4290e956 src/server/command_socket.rs: check control socket permissions 2019-04-11 10:51:59 +02:00
Wolfgang Bumiller
04f7276b1a tools/daemon: dup the TcpListener file descriptor
Now that we let hyper shutdown gracefully we need an owned
version of the listening socket to prevent it from closing
before running the reload preparations.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-04-10 15:20:10 +02:00
Dietmar Maurer
dfb73ee286 src/server/worker_task.rs: implement abort_worker (via command_socket) 2019-04-10 12:42:24 +02:00
Dietmar Maurer
1662975b70 src/server/command_socket.rs: correctly handle/spawn handle parallel connections 2019-04-10 11:05:00 +02:00
Dietmar Maurer
116990f264 src/server/worker_task.rs: use abstract socket 2019-04-10 09:03:17 +02:00
Dietmar Maurer
203b64ee92 start hyper server using with_graceful_shutdown()
Without, hyper keeps some futures running, and the server does not
correctly shutdown.
2019-04-10 08:24:32 +02:00
Dietmar Maurer
230d6ebc2a src/server/command_socket.rs: code cleanup - fix error message 2019-04-09 12:47:42 +02:00
Dietmar Maurer
1432561044 src/server/command_socket.rs: implement auto_remove flag
Remove the socket file on close.
2019-04-09 11:47:23 +02:00
Dietmar Maurer
8c4656ea04 src/server/command_socket.rs: simple command socket 2019-04-08 17:59:39 +02:00
Dietmar Maurer
b9e9f05aaf src/tools/daemon.rs: use new ServerState handler 2019-04-08 14:00:23 +02:00
Dietmar Maurer
9761b81b84 implement server state/signal handling, depend on tokio-signal 2019-04-08 13:59:07 +02:00
Dietmar Maurer
71d03f1ef4 src/tools/file_logger.rs: fix test 2019-04-06 11:24:37 +02:00
Dietmar Maurer
ff995ce0e1 src/server.rs: improve crate layout 2019-04-06 09:17:25 +02:00
Dietmar Maurer
e3e5ef3929 src/tools/file_logger.rs: new - accept AsRef<Path> 2019-04-03 14:13:33 +02:00
Dietmar Maurer
1ee4442d87 src/tools/file_logger.rs: change timestamp format to rfc3339 2019-04-03 08:58:43 +02:00
Dietmar Maurer
edc588857e add global var to indicate server shutdown requests 2019-04-01 12:05:11 +02:00
Dietmar Maurer
c76ceea941 src/server/rest.rs: use formatter to encode errors 2019-04-01 08:04:12 +02:00
Dietmar Maurer
24c023fe47 src/server/rest.rs: generate csrf token if we have a valid ticket
This is important if the user reloads the browser page.
2019-04-01 07:52:30 +02:00
Dietmar Maurer
022b626bc0 src/server/rest.rs: correctly extract content type 2019-03-19 12:50:15 +01:00
Wolfgang Bumiller
50e95f7c39 daemon: simplify daemon creation
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-03-19 12:12:54 +01:00
Wolfgang Bumiller
3aa2dbc857 tools: daemon: rename some structs
Reloadable resources are now 'Reloadable' instead of
'ReexecContinue'.

The struct handling the reload is a 'Reloader', not a
'ReexecStore'.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-03-19 11:09:46 +01:00
Wolfgang Bumiller
14ed3eb57c tools: implement ReexecContinue for tokio's TcpListener
This is the only thing we currently need to keep alive for
reloads.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-03-18 12:29:18 +01:00
Wolfgang Bumiller
66c138a51a tools: daemon: add a default signalfd helper
Proxy and daemon for now just want to handle reload via
`SIGHUP`, so provide a helper creating the signalfd stream
doing that - this is simply a filtered stream which passes
the remaining signals through, so it can be used exactly
like the signalfd stream could before to add more signals.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-03-18 12:29:18 +01:00
Wolfgang Bumiller
946995d984 tools: add daemon helpers
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-03-18 12:29:18 +01:00
Dietmar Maurer
6dd8bfb84b src/tools/ticket.rs: define const TICKET_LIFETIME 2019-03-05 12:56:21 +01:00
Dietmar Maurer
b9febc5f1c src/tools/file_logger.rs: class to log into files 2019-03-01 09:34:29 +01:00
Dietmar Maurer
9b4e1de1c0 rc/server/rest.rs: allow to pass parameters as application/json 2019-02-27 12:37:53 +01:00
Wolfgang Bumiller
3dc99a5049 cleanup
Error::from is already a function taking 1 parameter,
there's no need to wrap it with `|e| Error::from(e)`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-02-18 13:21:27 +01:00
Dietmar Maurer
435615a34a src/server/rest.rs: correctly insert NoLogExtension() 2019-02-18 06:54:12 +01:00
Dietmar Maurer
bc6fa1684e src/server/rest.rs: get_index() include username and CSRF token
When we have an valid ticket. Also delay get_index() if called with
an invalid ticket.
2019-02-17 19:28:32 +01:00
Dietmar Maurer
c4c7466024 src/server/rest.rs: factor our normalize_path() 2019-02-17 17:31:53 +01:00
Dietmar Maurer
fce8be6fe1 src/server/rest.rs: improve logs for unauthorized request 2019-02-17 17:18:44 +01:00
Dietmar Maurer
b1c1c468ee improve api_schema module structure 2019-02-17 10:16:33 +01:00
Dietmar Maurer
304bfa59a8 rename src/api to src/api_schema 2019-02-17 09:59:20 +01:00
Dietmar Maurer
124b26b892 cleanup auth code, verify CSRF prevention token 2019-02-16 15:52:55 +01:00
Dietmar Maurer
1aff635a23 server/rest.rs: add method to log message 2019-02-15 10:16:12 +01:00