|
|
c62b8e |
From 9f2aa24a4cad32e10cba693be95f3ff9c46ee73e Mon Sep 17 00:00:00 2001
|
|
|
c62b8e |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
c62b8e |
Date: Sun, 27 Aug 2017 16:34:53 +0900
|
|
|
c62b8e |
Subject: [PATCH] journal-remote: show error message if output file name does
|
|
|
c62b8e |
not end with .journal
|
|
|
c62b8e |
|
|
|
c62b8e |
`journalctl -o export | systemd-journal-remote -o /tmp/dir -`
|
|
|
c62b8e |
gives the following error messages.
|
|
|
c62b8e |
```
|
|
|
c62b8e |
Failed to open output journal /tmp/dir: Invalid argument
|
|
|
c62b8e |
Failed to get writer for source stdin: Invalid argument
|
|
|
c62b8e |
Failed to create source for fd:0 (stdin): Invalid argument
|
|
|
c62b8e |
```
|
|
|
c62b8e |
And these are hard to understand what is the problem.
|
|
|
c62b8e |
This commit makes journal-remote check whether the output file name
|
|
|
c62b8e |
ends with .journal suffix or not, and if not, output error message.
|
|
|
c62b8e |
|
|
|
c62b8e |
(cherry picked from commit 6b1b9f75c85d26ddbda62e7b7afa6944044f4f95)
|
|
|
c62b8e |
|
|
|
c62b8e |
Resolves: bz#1267552
|
|
|
c62b8e |
---
|
|
|
c62b8e |
src/journal-remote/journal-remote.c | 13 +++++++++----
|
|
|
c62b8e |
1 file changed, 9 insertions(+), 4 deletions(-)
|
|
|
c62b8e |
|
|
|
c62b8e |
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
|
|
|
c62b8e |
index e65daf6a0b..431e28329b 100644
|
|
|
c62b8e |
--- a/src/journal-remote/journal-remote.c
|
|
|
c62b8e |
+++ b/src/journal-remote/journal-remote.c
|
|
|
c62b8e |
@@ -1479,10 +1479,15 @@ static int parse_argv(int argc, char *argv[]) {
|
|
|
c62b8e |
arg_split_mode = JOURNAL_WRITE_SPLIT_NONE;
|
|
|
c62b8e |
}
|
|
|
c62b8e |
|
|
|
c62b8e |
- if (arg_split_mode == JOURNAL_WRITE_SPLIT_NONE
|
|
|
c62b8e |
- && arg_output && is_dir(arg_output, true) > 0) {
|
|
|
c62b8e |
- log_error("For SplitMode=none, output must be a file.");
|
|
|
c62b8e |
- return -EINVAL;
|
|
|
c62b8e |
+ if (arg_split_mode == JOURNAL_WRITE_SPLIT_NONE && arg_output) {
|
|
|
c62b8e |
+ if (is_dir(arg_output, true) > 0) {
|
|
|
c62b8e |
+ log_error("For SplitMode=none, output must be a file.");
|
|
|
c62b8e |
+ return -EINVAL;
|
|
|
c62b8e |
+ }
|
|
|
c62b8e |
+ if (!endswith(arg_output, ".journal")) {
|
|
|
c62b8e |
+ log_error("For SplitMode=none, output file name must end with .journal.");
|
|
|
c62b8e |
+ return -EINVAL;
|
|
|
c62b8e |
+ }
|
|
|
c62b8e |
}
|
|
|
c62b8e |
|
|
|
c62b8e |
if (arg_split_mode == JOURNAL_WRITE_SPLIT_HOST
|