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