feat: allow logging to stdout

The --log option accepts "-" as filename. This prevents rest-server from
opening the log file, it simply writes to the STDOUT stream provided by
the caller.

**BREAKING** in case use really used "-" to specify a file named "-"
you'll need to update your rest-server invocation to use "./-".
This commit is contained in:
Heiko Schlittermann (HS12-RIPE)
2023-03-23 19:19:18 +01:00
parent 94d5861c50
commit 9f074d8b3a
3 changed files with 25 additions and 4 deletions

View File

@@ -0,0 +1,13 @@
Feature: Allows "-" as filename for the `--log` option.
When (e.g. for debugging purpose) the rest server is invoked like
sudo -u restic rest-server … --log /dev/stdout
it tries to open `/dev/stdout` (O_CREATE, O_WRITE, O_APPEND). This
operation fails, as in the above invocation, `/dev/stdout` is owned by
the caller (here: root) and only writable for the caller. Subprocesses
get just the filedescriptor. Using `/proc/self/fd/1` didn't work either,
for the same reasons.
https://github.com/restic/rest-server/pull/217