From c298b083c652f84a08f67d314ffff8ac92f6188c Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 27 Aug 2017 16:20:12 +0900 Subject: [PATCH 1/2] man: journal-remote: active mode without --url option requires output filename Closes #6675. --- man/systemd-journal-remote.xml | 37 ++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/man/systemd-journal-remote.xml b/man/systemd-journal-remote.xml index d7750e416eb..d37b9b20210 100644 --- a/man/systemd-journal-remote.xml +++ b/man/systemd-journal-remote.xml @@ -106,6 +106,8 @@ + SOURCES + When is given as a positional argument, events will be read from standard input. Other positional arguments will be treated as filenames @@ -124,6 +126,20 @@ instance, e.g. http://some.host:19531/ or https://some.host:19531/. + + + + + Program to invoke to retrieve data. The journal + event stream must be generated on standard output. + + Examples: + + --getter='curl "-HAccept: application/vnd.fdo.journal" https://some.host:19531/' + + --getter='wget --header="Accept: application/vnd.fdo.journal" -O- https://some.host:19531/' + + Passive sources can be specified in the following @@ -225,8 +241,9 @@ escaped hostname of the source endpoint of the connection, or the numerical address if the hostname cannot be determined. - In case of "active" sources, the output file name must - always be given explicitly. + In the case that "active" sources are given by the positional + arguments or option, the output file name + must always be given explicitly. @@ -265,20 +282,6 @@ The default is no. - - - - Program to invoke to retrieve data. The journal - event stream must be generated on standard output. - - Examples: - - --getter='curl "-HAccept: application/vnd.fdo.journal" https://some.host:19531/' - - --getter='wget --header="Accept: application/vnd.fdo.journal" -O- https://some.host:19531/' - - - @@ -288,7 +291,7 @@ Examples Copy local journal events to a different journal directory: -journalctl -o export | systemd-journal-remote -o /tmp/dir - +journalctl -o export | systemd-journal-remote -o /tmp/dir/foo.journal - From 6b1b9f75c85d26ddbda62e7b7afa6944044f4f95 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 27 Aug 2017 16:34:53 +0900 Subject: [PATCH 2/2] journal-remote: show error message if output file name does not end with .journal `journalctl -o export | systemd-journal-remote -o /tmp/dir -` gives the following error messages. ``` Failed to open output journal /tmp/dir: Invalid argument Failed to get writer for source stdin: Invalid argument Failed to create source for fd:0 (stdin): Invalid argument ``` And these are hard to understand what is the problem. This commit makes journal-remote check whether the output file name ends with .journal suffix or not, and if not, output error message. --- src/journal-remote/journal-remote.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index 1ed350649cf..7201421d915 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -1495,10 +1495,15 @@ static int parse_argv(int argc, char *argv[]) { arg_split_mode = JOURNAL_WRITE_SPLIT_NONE; } - if (arg_split_mode == JOURNAL_WRITE_SPLIT_NONE - && arg_output && is_dir(arg_output, true) > 0) { - log_error("For SplitMode=none, output must be a file."); - return -EINVAL; + if (arg_split_mode == JOURNAL_WRITE_SPLIT_NONE && arg_output) { + if (is_dir(arg_output, true) > 0) { + log_error("For SplitMode=none, output must be a file."); + return -EINVAL; + } + if (!endswith(arg_output, ".journal")) { + log_error("For SplitMode=none, output file name must end with .journal."); + return -EINVAL; + } } if (arg_split_mode == JOURNAL_WRITE_SPLIT_HOST