summaryrefslogtreecommitdiff
path: root/src/journal-remote
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2017-08-27 16:34:53 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2017-08-27 16:34:57 +0900
commit6b1b9f75c85d26ddbda62e7b7afa6944044f4f95 (patch)
tree7d8e2584d73574a0249c4c26d255c498707ad5d4 /src/journal-remote
parentc298b083c652f84a08f67d314ffff8ac92f6188c (diff)
downloadsystemd-6b1b9f75c85d26ddbda62e7b7afa6944044f4f95.tar.gz
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.
Diffstat (limited to 'src/journal-remote')
-rw-r--r--src/journal-remote/journal-remote.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index 1ed350649c..7201421d91 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