]> git.proxmox.com Git - proxmox.git/log
proxmox.git
2 years agotree wide: typo fixes through codespell
Thomas Lamprecht [Tue, 7 Jun 2022 07:22:45 +0000 (09:22 +0200)]
tree wide: typo fixes through codespell

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agotree wide: clippy lint fixes
Thomas Lamprecht [Thu, 2 Jun 2022 13:59:53 +0000 (15:59 +0200)]
tree wide: clippy lint fixes

most (not all) where done automatically

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoupdate to nix 0.24 / rustyline 9 / proxmox-sys 0.3
Fabian Grünbichler [Thu, 2 Jun 2022 11:10:33 +0000 (13:10 +0200)]
update to nix 0.24 / rustyline 9 / proxmox-sys 0.3

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agobuild: bump required log version
Fabian Grünbichler [Mon, 16 May 2022 13:02:07 +0000 (15:02 +0200)]
build: bump required log version

else logging using "{var}" in format strings doesn't work properly.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agorest: example: fix comment width
Thomas Lamprecht [Thu, 12 May 2022 09:57:51 +0000 (11:57 +0200)]
rest: example: fix comment width

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest server: daemon: update PID file before sending MAINPID notification
Fabian Ebner [Wed, 4 May 2022 11:33:24 +0000 (13:33 +0200)]
rest server: daemon: update PID file before sending MAINPID notification

There is a race upon reload, where it can happen that:
1. systemd forks off /bin/kill -HUP $MAINPID
2. Current instance forks off new one and notifies systemd with the
   new MAINPID.
3. systemd sets new MAINPID.
4. systemd receives SIGCHLD for the kill process (which is the current
   control process for the service) and reads the PID of the old
   instance from the PID file, resetting MAINPID to the PID of the old
   instance.
5. Old instance exits.
6. systemd receives SIGCHLD for the old instance, reads the PID of the
   old instance from the PID file once more. systemd sees that the
   MAINPID matches the child PID and considers the service exited.
7. systemd receivese notification from the new PID and is confused.
   The service won't get active, because the notification wasn't
   handled.

To fix it, update the PID file before sending the MAINPID
notification, similar to what a comment in systemd's
src/core/service.c suggests:
> /* Forking services may occasionally move to a new PID.
>  * As long as they update the PID file before exiting the old
>  * PID, they're fine. */
but for our Type=notify "before sending the notification" rather than
"before exiting", because otherwise, the mix-up in 4. could still
happen (although it might not actually be problematic without the
mix-up in 6., it still seems better to avoid).

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agobump proxmox-compression dependency to 0.1.1
Wolfgang Bumiller [Wed, 13 Apr 2022 07:37:20 +0000 (09:37 +0200)]
bump proxmox-compression dependency to 0.1.1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agobump proxmox-schema dependency to 1.3.1 for streaming attribute
Wolfgang Bumiller [Wed, 13 Apr 2022 06:20:27 +0000 (08:20 +0200)]
bump proxmox-schema dependency to 1.3.1 for streaming attribute

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agobump proxmox-router dependency to 1.2
Wolfgang Bumiller [Wed, 13 Apr 2022 06:17:08 +0000 (08:17 +0200)]
bump proxmox-router dependency to 1.2

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agoadapt to the new ApiHandler variants
Dominik Csapak [Tue, 12 Apr 2022 14:15:09 +0000 (16:15 +0200)]
adapt to the new ApiHandler variants

namely 'StreamingSync' and 'StreamingAsync'
in rest-server by using the new formatter function,
and in the debug binary by using 'to_value'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agoproxmox-rest-server: OutputFormatter: add new format_data_streaming method
Dominik Csapak [Tue, 12 Apr 2022 14:15:08 +0000 (16:15 +0200)]
proxmox-rest-server: OutputFormatter: add new format_data_streaming method

that takes the data in form of a `Box<dyn SerializableReturn + Send>`
instead of a Value.

Implement it in json and extjs formatter, by starting a thread and
stream the serialized data via a `BufWriter<SenderWriter>` and use
the Receiver side as a stream for the response body.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agotree wide: some stylistic clippy fixes
Thomas Lamprecht [Sun, 10 Apr 2022 16:33:32 +0000 (18:33 +0200)]
tree wide: some stylistic clippy fixes

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest server: log rotation: refactor and comment improvements
Thomas Lamprecht [Thu, 7 Apr 2022 12:04:18 +0000 (14:04 +0200)]
rest server: log rotation: refactor and comment improvements

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest server: log rotation: fix off-by-one for max_days
Thomas Lamprecht [Thu, 7 Apr 2022 10:57:03 +0000 (12:57 +0200)]
rest server: log rotation: fix off-by-one for max_days

The entries in a file go from oldest end-time in the first time to
newest end-time in the last line. So, just because the first line is
older than the cut-off time, the remaining one doesn't necessarily
have to be old enough too. What we can know for sure that older than
the current checked rotations of the task archive are definitively up
for deletion.

Another possibility would be to check the last line, but as scanning
backwards is more expensive/complex to do while only being an actual
improvement in a very specific edge case (it's more likely to have a
mixed time-cutoff vs. task-log-file boundary than that those are
aligned)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest-server: add option to rotate task logs by 'max_days' instead of 'max_files'
Dominik Csapak [Mon, 28 Mar 2022 07:54:19 +0000 (09:54 +0200)]
rest-server: add option to rotate task logs by 'max_days' instead of 'max_files'

and use it with the configurable: 'task_log_max_days' of the node config

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agorest-server: cleanup_old_tasks: improve error handling
Dominik Csapak [Mon, 28 Mar 2022 07:54:17 +0000 (09:54 +0200)]
rest-server: cleanup_old_tasks: improve error handling

by not bubbling up most errors, and continuing on. this avoids that we
stop cleaning up because e.g. one directory was missing.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agorest server: rust fmt
Thomas Lamprecht [Wed, 6 Apr 2022 14:55:39 +0000 (16:55 +0200)]
rest server: rust fmt

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agobump proxmox-schema dep to 1.3
Wolfgang Bumiller [Fri, 4 Mar 2022 08:50:21 +0000 (09:50 +0100)]
bump proxmox-schema dep to 1.3

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agobump proxmox-async dep to 0.4
Wolfgang Bumiller [Mon, 21 Feb 2022 13:25:29 +0000 (14:25 +0100)]
bump proxmox-async dep to 0.4

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agobump proxmox-lang dep to 1.1
Wolfgang Bumiller [Mon, 21 Feb 2022 13:24:24 +0000 (14:24 +0100)]
bump proxmox-lang dep to 1.1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agouse io_format_err, io_bail, io_err_other from proxmox-lang
Dominik Csapak [Mon, 21 Feb 2022 10:39:18 +0000 (11:39 +0100)]
use io_format_err, io_bail, io_err_other from proxmox-lang

and move the comment from the local io_bail in pbs-client/src/pxar/fuse.rs
to the only use

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agodepend on new 'proxmox-compression' crate
Dominik Csapak [Mon, 21 Feb 2022 10:39:17 +0000 (11:39 +0100)]
depend on new 'proxmox-compression' crate

the compression utilities live there now

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agorest-server: bump schema to 1.2 and use convenience methods
Wolfgang Bumiller [Fri, 11 Feb 2022 13:09:45 +0000 (14:09 +0100)]
rest-server: bump schema to 1.2 and use convenience methods

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agoproxmox-rest-server: add missing 'derive' feature
Wolfgang Bumiller [Fri, 11 Feb 2022 12:57:48 +0000 (13:57 +0100)]
proxmox-rest-server: add missing 'derive' feature

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agomisc clippy fixes
Fabian Grünbichler [Tue, 8 Feb 2022 13:57:16 +0000 (14:57 +0100)]
misc clippy fixes

the trivial ones ;)

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agorest: add cookie_from_header helper
Thomas Lamprecht [Mon, 31 Jan 2022 14:50:23 +0000 (15:50 +0100)]
rest: add cookie_from_header helper

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agotree-wide: drop redundant clones
Fabian Grünbichler [Thu, 30 Dec 2021 12:20:03 +0000 (13:20 +0100)]
tree-wide: drop redundant clones

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agotree-wide: fix needless borrows
Fabian Grünbichler [Thu, 30 Dec 2021 11:57:37 +0000 (12:57 +0100)]
tree-wide: fix needless borrows

found and fixed via clippy

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agobump regex dep to 1.5
Wolfgang Bumiller [Thu, 16 Dec 2021 10:12:17 +0000 (11:12 +0100)]
bump regex dep to 1.5

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agocleanup schema function calls
Wolfgang Bumiller [Thu, 16 Dec 2021 10:02:53 +0000 (11:02 +0100)]
cleanup schema function calls

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agobump proxmox-schema to 1.1
Wolfgang Bumiller [Thu, 16 Dec 2021 10:08:44 +0000 (11:08 +0100)]
bump proxmox-schema to 1.1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agoupdate to proxmox-sys 0.2 crate
Dietmar Maurer [Tue, 23 Nov 2021 16:57:00 +0000 (17:57 +0100)]
update to proxmox-sys 0.2 crate

- imported pbs-api-types/src/common_regex.rs from old proxmox crate
- use hex crate to generate/parse hex digest
- remove all reference to proxmox crate (use proxmox-sys and
  proxmox-serde instead)

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2 years agod/control and Cargo.toml bumps
Wolfgang Bumiller [Mon, 22 Nov 2021 09:55:38 +0000 (10:55 +0100)]
d/control and Cargo.toml bumps

* pin-utils isn't used anymore
* proxmox-sys version should also be tracked in Cargo.toml

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agodepend on proxmox-async 0.2
Dietmar Maurer [Sat, 20 Nov 2021 16:14:02 +0000 (17:14 +0100)]
depend on proxmox-async 0.2

2 years agoproxmox-rest-server: remove pbs-tools dependency
Dietmar Maurer [Fri, 19 Nov 2021 17:06:54 +0000 (18:06 +0100)]
proxmox-rest-server: remove pbs-tools dependency

2 years agouse new proxmox-async crate
Dietmar Maurer [Fri, 19 Nov 2021 16:36:06 +0000 (17:36 +0100)]
use new proxmox-async crate

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2 years agouse new proxmox-sys crate
Dietmar Maurer [Fri, 19 Nov 2021 09:51:41 +0000 (10:51 +0100)]
use new proxmox-sys crate

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2 years agouse proxmox::tools::fd::fd_change_cloexec from proxmox 0.15.3
Dietmar Maurer [Thu, 18 Nov 2021 12:43:41 +0000 (13:43 +0100)]
use proxmox::tools::fd::fd_change_cloexec from proxmox 0.15.3

Depend on proxmox 0.15.3

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2 years agorest: make successful-ticket auth log a debug one to avoid syslog
Thomas Lamprecht [Wed, 10 Nov 2021 16:05:09 +0000 (17:05 +0100)]
rest: make successful-ticket auth log a debug one to avoid syslog

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoimplement Servive for RateLimitedStream
Dietmar Maurer [Thu, 4 Nov 2021 12:42:30 +0000 (13:42 +0100)]
implement Servive for RateLimitedStream

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2 years agouse new fsync parameter to replace_file and atomic_open_or_create
Dietmar Maurer [Wed, 20 Oct 2021 12:56:15 +0000 (14:56 +0200)]
use new fsync parameter to replace_file and atomic_open_or_create

Depend on proxmox 0.15.0 and proxmox-openid 0.8.1

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2 years agorest-server: use hashmap for parameter errors
Dominik Csapak [Tue, 19 Oct 2021 11:09:27 +0000 (13:09 +0200)]
rest-server: use hashmap for parameter errors

our ui expects a map here with 'field: "error"'. This way it can mark
the relevant field as invalid and correctly shows the complete error
message

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agouse complete_file_name from proxmox-router 1.1
Dietmar Maurer [Wed, 13 Oct 2021 10:55:51 +0000 (12:55 +0200)]
use complete_file_name from proxmox-router 1.1

2 years agoupdate to first proxmox crate split
Wolfgang Bumiller [Fri, 8 Oct 2021 09:19:37 +0000 (11:19 +0200)]
update to first proxmox crate split

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agobump proxmox dependency to 0.14.0 and proxmox-http to 0.5.0
Wolfgang Bumiller [Fri, 8 Oct 2021 09:18:22 +0000 (11:18 +0200)]
bump proxmox dependency to 0.14.0 and proxmox-http to 0.5.0

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agorest-server: add cleanup_old_tasks
Dominik Csapak [Thu, 7 Oct 2021 12:03:36 +0000 (14:03 +0200)]
rest-server: add cleanup_old_tasks

this is a helper that removes task log files that are not referenced
by the task archive anymore

it gets the oldest task archive file, gets the first endtime (the
oldest) and removes all files in the taskdir where the mtime is older
than that

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agoproxmox-rest-server: use new ServerAdapter trait instead of callbacks
Dietmar Maurer [Tue, 5 Oct 2021 09:01:05 +0000 (11:01 +0200)]
proxmox-rest-server: use new ServerAdapter trait instead of callbacks

Async callbacks are a PITA, so we now pass a single trait object which
implements check_auth and get_index.

2 years agoproxmox-rest-server: pass owned RestEnvironment to get_index
Dietmar Maurer [Mon, 4 Oct 2021 12:49:25 +0000 (14:49 +0200)]
proxmox-rest-server: pass owned RestEnvironment to get_index

This way we avoid pointers with lifetimes.

2 years agoproxmox-rest-server: cleanup, access api_auth using a method
Dietmar Maurer [Mon, 4 Oct 2021 11:32:19 +0000 (13:32 +0200)]
proxmox-rest-server: cleanup, access api_auth using a method

2 years agorest: daemon: group systemd FFI together
Thomas Lamprecht [Fri, 1 Oct 2021 14:46:59 +0000 (16:46 +0200)]
rest: daemon: group systemd FFI together

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest: daemon: sd notify: code cleanup
Thomas Lamprecht [Fri, 1 Oct 2021 14:45:19 +0000 (16:45 +0200)]
rest: daemon: sd notify: code cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest: daemon: sd notify barrier: avoid barging in between SystemdNotify enum and...
Thomas Lamprecht [Fri, 1 Oct 2021 14:44:28 +0000 (16:44 +0200)]
rest: daemon: sd notify barrier: avoid barging in between SystemdNotify enum and systemd_notify

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest: daemon: sd notify barrier: allow caller to set timeout
Thomas Lamprecht [Fri, 1 Oct 2021 13:27:46 +0000 (15:27 +0200)]
rest: daemon: sd notify barrier: allow caller to set timeout

else it's rather to subtle and not a nice interface considering that
we only want to have a thin wrapper for sd_notify_barrier..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest: daemon: comment why using a systemd barrier is important for main PID handover
Thomas Lamprecht [Fri, 1 Oct 2021 13:04:58 +0000 (15:04 +0200)]
rest: daemon: comment why using a systemd barrier is important for main PID handover

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest-server/daemon: use sd_notify_barrier for service reloading
Dominik Csapak [Thu, 30 Sep 2021 07:18:58 +0000 (09:18 +0200)]
rest-server/daemon: use sd_notify_barrier for service reloading

until now, we manually polled the systemd service state during a reload
so that the sd_notify messages get processed in the correct order
(RELOAD(old) -> MAINPID(old) -> READY(new))

with systemd >= 246 there is now 'sd_notify_barrier' which
blocks until systemd processed all prior messages

with that change, the daemon does not need to know the service name anymore

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoproxmox-rest-server: make get_index async
Dietmar Maurer [Fri, 1 Oct 2021 07:38:10 +0000 (09:38 +0200)]
proxmox-rest-server: make get_index async

2 years agoproxmox-rest-server: add comment why ApiService needs to be 'pub'
Dietmar Maurer [Fri, 1 Oct 2021 06:35:51 +0000 (08:35 +0200)]
proxmox-rest-server: add comment why ApiService needs to be 'pub'

2 years agoproxmox-rest-server: make check_auth async
Dietmar Maurer [Fri, 1 Oct 2021 05:29:11 +0000 (07:29 +0200)]
proxmox-rest-server: make check_auth async

2 years agoproxmox-rest-server: fix spelling errors
Dietmar Maurer [Fri, 1 Oct 2021 04:43:30 +0000 (06:43 +0200)]
proxmox-rest-server: fix spelling errors

2 years agoproxmox-rest-server: improve ApiService docs
Dietmar Maurer [Thu, 30 Sep 2021 15:18:47 +0000 (17:18 +0200)]
proxmox-rest-server: improve ApiService docs

2 years agoproxmox-rest-server: start module docs
Dietmar Maurer [Thu, 30 Sep 2021 11:49:29 +0000 (13:49 +0200)]
proxmox-rest-server: start module docs

2 years agorename CommandoSocket to CommandSocket
Dietmar Maurer [Thu, 30 Sep 2021 10:31:38 +0000 (12:31 +0200)]
rename CommandoSocket to CommandSocket

2 years agodrop fd_change_cloexec from proxmox-rest-server
Wolfgang Bumiller [Thu, 30 Sep 2021 10:42:28 +0000 (12:42 +0200)]
drop fd_change_cloexec from proxmox-rest-server

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agoproxmox-rest-server: improve docs
Dietmar Maurer [Thu, 30 Sep 2021 09:59:21 +0000 (11:59 +0200)]
proxmox-rest-server: improve docs

And rename enable_file_log to enable_access_log.

2 years agoproxmox-rest-server: improve docs
Dietmar Maurer [Thu, 30 Sep 2021 08:33:57 +0000 (10:33 +0200)]
proxmox-rest-server: improve docs

And renames abort_worker_async to abort_worker_nowait (avoid confusion,
because the function itself is not async).

2 years agoproxmox-rest-server: cleanup FileLogger docs
Dietmar Maurer [Thu, 30 Sep 2021 06:51:23 +0000 (08:51 +0200)]
proxmox-rest-server: cleanup FileLogger docs

2 years agocleanup: move use clause to top
Dietmar Maurer [Thu, 30 Sep 2021 06:40:55 +0000 (08:40 +0200)]
cleanup: move use clause to top

2 years agoproxmox-rest-server: allow to catch SIGINT and SIGHUP separately
Dietmar Maurer [Thu, 30 Sep 2021 06:03:34 +0000 (08:03 +0200)]
proxmox-rest-server: allow to catch SIGINT and SIGHUP separately

And make ServerState private.

2 years agoproxmox-rtest-server: make Reloader and Reloadable private
Dietmar Maurer [Thu, 30 Sep 2021 05:37:16 +0000 (07:37 +0200)]
proxmox-rtest-server: make Reloader and Reloadable private

2 years agoproxmox-rest-server: improve logging
Dietmar Maurer [Wed, 29 Sep 2021 12:34:25 +0000 (14:34 +0200)]
proxmox-rest-server: improve logging

And rename server_state_init() into catch_shutdown_and_reload_signals().

2 years agoproxmox-rest-server: avoid useless call to request_shutdown
Dietmar Maurer [Wed, 29 Sep 2021 10:46:00 +0000 (12:46 +0200)]
proxmox-rest-server: avoid useless call to request_shutdown

Also avoid unsafe code.

2 years agodaemon: simlify code (make it easier to use)
Dietmar Maurer [Wed, 29 Sep 2021 09:21:32 +0000 (11:21 +0200)]
daemon: simlify code (make it easier to use)

2 years agocleanup: make BoxedStoreFunc private
Dietmar Maurer [Wed, 29 Sep 2021 07:40:56 +0000 (09:40 +0200)]
cleanup: make BoxedStoreFunc private

There is no need to export this type.

2 years agoexamples: add example for a simple rest server with a small api
Dominik Csapak [Wed, 29 Sep 2021 07:04:19 +0000 (09:04 +0200)]
examples: add example for a simple rest server with a small api

show how to generally start a daemon that serves a rest api + index page

api calls are (prefixed with either /api2/json or /api2/extjs):
/ GET listing
/ping GET returns "pong"
/items GET lists existing items
POST lets user create new items
/items/{id} GET returns the content of a single item
PUT updates an item
DELETE deletes an item

Contains a small dummy user/authinfo

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest-server: use hypers AddrIncoming for proxmox-backup-api
Dominik Csapak [Wed, 29 Sep 2021 07:04:17 +0000 (09:04 +0200)]
rest-server: use hypers AddrIncoming for proxmox-backup-api

this has a 'from_listener' (tokio::net::TcpListener) since hyper 0.14.5 in
the 'tcp' feature (we use 'full', which includes that; since 0.14.13
it is not behind a feature flag anymore).

this makes it possible to create a hyper server without our
'StaticIncoming' wrapper and thus makes it unnecessary.

The only other thing we have to do is to change the Service impl from
tokio::net::TcpStream to hyper::server::conn::AddStream to fulfill the trait
requirements.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoExtJsFormatter: use ParameterError to correctly compute 'errors'
Dietmar Maurer [Tue, 28 Sep 2021 08:11:56 +0000 (10:11 +0200)]
ExtJsFormatter: use ParameterError to correctly compute 'errors'

By default, 'errors' is now empty.

Depend on proxmox 0.13.5.

2 years agoproxmox-rest-server: cleanup formatter, improve docs
Dietmar Maurer [Mon, 27 Sep 2021 10:59:06 +0000 (12:59 +0200)]
proxmox-rest-server: cleanup formatter, improve docs

Use trait for OutputFormatter. This is functionally equivalent,
but more rust-like...

2 years agoWorkerTaskContext: add shutdown_requested() and fail_on_shutdown()
Dietmar Maurer [Fri, 24 Sep 2021 09:56:53 +0000 (11:56 +0200)]
WorkerTaskContext: add shutdown_requested() and fail_on_shutdown()

2 years agocleanup WorkerTaskContext
Dietmar Maurer [Fri, 24 Sep 2021 09:39:30 +0000 (11:39 +0200)]
cleanup WorkerTaskContext

2 years agocleanup worker task logging
Dietmar Maurer [Fri, 24 Sep 2021 07:30:00 +0000 (09:30 +0200)]
cleanup worker task logging

In order to avoid name conflicts with WorkerTaskContext

- renamed WorkerTask::log to WorkerTask::log_message

Note: Methods have different fuction signatures

Also renamed WorkerTask::warn to WorkerTask::log_warning for
consistency reasons.

Use the task_log!() and task_warn!() macros more often.

2 years agorename TaskState to WorkerTaskContext
Dietmar Maurer [Fri, 24 Sep 2021 05:40:49 +0000 (07:40 +0200)]
rename TaskState to WorkerTaskContext

2 years agomove src/server/h2service.rs into proxmox-rest-server crate
Dietmar Maurer [Thu, 23 Sep 2021 10:38:09 +0000 (12:38 +0200)]
move src/server/h2service.rs into proxmox-rest-server crate

2 years agomove worker_task.rs into proxmox-rest-server crate
Dietmar Maurer [Thu, 23 Sep 2021 08:09:19 +0000 (10:09 +0200)]
move worker_task.rs into proxmox-rest-server crate

Also moved pbs-datastore/src/task.rs to pbs-tools, which now depends on 'log'.

2 years agouse UPID and systemd helpers from proxmox 0.13.4
Dietmar Maurer [Wed, 22 Sep 2021 10:46:44 +0000 (12:46 +0200)]
use UPID and systemd helpers from proxmox 0.13.4

2 years agomove src/server/rest.rs to proxmox-rest-server crate
Dietmar Maurer [Tue, 21 Sep 2021 05:58:51 +0000 (07:58 +0200)]
move src/server/rest.rs to proxmox-rest-server crate

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest server: cleanup auth-log handling
Dietmar Maurer [Tue, 21 Sep 2021 05:58:50 +0000 (07:58 +0200)]
rest server: cleanup auth-log handling

Handle auth logs the same way as access log.
- Configure with ApiConfig
- CommandoSocket command to reload auth-logs "api-auth-log-reopen"

Inside API calls, we now access the ApiConfig using the RestEnvironment.

The openid_login api now also logs failed logins and return http_err!(UNAUTHORIZED, ..)
on failed logins.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest server: do not use pbs_api_types::Authid
Dietmar Maurer [Tue, 21 Sep 2021 05:58:49 +0000 (07:58 +0200)]
rest server: do not use pbs_api_types::Authid

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest server: return UserInformation from ApiAuth::check_auth
Dietmar Maurer [Tue, 21 Sep 2021 05:58:48 +0000 (07:58 +0200)]
rest server: return UserInformation from ApiAuth::check_auth

This need impl UserInformation for Arc<CachedUserInfo> which is implemented
with proxmox 0.13.2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomake get_index and ApiConfig property (callback)
Dietmar Maurer [Tue, 21 Sep 2021 05:58:47 +0000 (07:58 +0200)]
make get_index and ApiConfig property (callback)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest server: simplify get_index() method signature
Dietmar Maurer [Tue, 21 Sep 2021 05:58:46 +0000 (07:58 +0200)]
rest server: simplify get_index() method signature

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomove normalize_uri_path and extract_cookie to proxmox-rest-server crate
Dietmar Maurer [Tue, 21 Sep 2021 05:58:45 +0000 (07:58 +0200)]
move normalize_uri_path and extract_cookie to proxmox-rest-server crate

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomove src/tools/compression.rs to proxmox-rest-server crate
Dietmar Maurer [Tue, 21 Sep 2021 05:58:44 +0000 (07:58 +0200)]
move src/tools/compression.rs to proxmox-rest-server crate

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomove src/server/formatter.rs to proxmox-rest-server crate
Dietmar Maurer [Tue, 21 Sep 2021 05:58:43 +0000 (07:58 +0200)]
move src/server/formatter.rs to proxmox-rest-server crate

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomove src/server/environment.rs to proxmox-rest-server crate
Dietmar Maurer [Tue, 21 Sep 2021 05:58:42 +0000 (07:58 +0200)]
move src/server/environment.rs to proxmox-rest-server crate

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomove src/tools/daemon.rs to proxmox-rest-server workspace
Dietmar Maurer [Tue, 21 Sep 2021 05:58:41 +0000 (07:58 +0200)]
move src/tools/daemon.rs to proxmox-rest-server workspace

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomove ApiConfig, FileLogger and CommandoSocket to proxmox-rest-server workspace
Dietmar Maurer [Tue, 21 Sep 2021 05:58:40 +0000 (07:58 +0200)]
move ApiConfig, FileLogger and CommandoSocket to proxmox-rest-server workspace

ApiConfig: avoid using  pbs_config::backup_user()
CommandoSocket: avoid using  pbs_config::backup_user()
FileLogger: avoid using  pbs_config::backup_user()
- use atomic_open_or_create_file()

Auth Trait: moved definitions to proxmox-rest-server/src/lib.rs
- removed CachedUserInfo patrameter
- return user as String (not Authid)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agostart new proxmox-rest-server workspace
Dietmar Maurer [Tue, 21 Sep 2021 05:58:39 +0000 (07:58 +0200)]
start new proxmox-rest-server workspace

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoavoid type re-exports
Dietmar Maurer [Tue, 14 Sep 2021 06:35:43 +0000 (08:35 +0200)]
avoid type re-exports

2 years agomore api type cleanups: avoid re-exports
Dietmar Maurer [Fri, 10 Sep 2021 10:25:32 +0000 (12:25 +0200)]
more api type cleanups: avoid re-exports

2 years agomove user configuration to pbs_config workspace
Dietmar Maurer [Fri, 10 Sep 2021 04:53:53 +0000 (06:53 +0200)]
move user configuration to pbs_config workspace

Also moved memcom.rs and cached_user_info.rs