summaryrefslogtreecommitdiff
path: root/src/journal-remote
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-03-28 02:07:31 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-03-28 02:29:19 +0900
commit7276d98cd290958a9b834ee815902df5253cba85 (patch)
tree6d6a23028733bfc199caff01c561a7cb500cc74b /src/journal-remote
parent8ee2fd9050a2f28e5c5177f7cfee5bfa092699e4 (diff)
downloadsystemd-7276d98cd290958a9b834ee815902df5253cba85.tar.gz
journal-remote: make specified output file absolute
After f12b399dd6362a03379cb769954ebfb9972236ed, the output path is also used to determine the directory to be vacuumed. And if a filename only path is specified, `writer_new()` fails since the commit. This makes the specified path is always made absolute. This should not change any behavior before the offending commit, as `journal_open()` opens the specified journal file with `AT_FDCWD`. Fixes #27012.
Diffstat (limited to 'src/journal-remote')
-rw-r--r--src/journal-remote/journal-remote-main.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c
index 2cc7428e78..c5ecc2b844 100644
--- a/src/journal-remote/journal-remote-main.c
+++ b/src/journal-remote/journal-remote-main.c
@@ -42,7 +42,7 @@ static int http_socket = -1, https_socket = -1;
static char** arg_gnutls_log = NULL;
static JournalWriteSplitMode arg_split_mode = _JOURNAL_WRITE_SPLIT_INVALID;
-static const char* arg_output = NULL;
+static char *arg_output = NULL;
static char *arg_key = NULL;
static char *arg_cert = NULL;
@@ -62,6 +62,7 @@ STATIC_DESTRUCTOR_REGISTER(arg_gnutls_log, strv_freep);
STATIC_DESTRUCTOR_REGISTER(arg_key, freep);
STATIC_DESTRUCTOR_REGISTER(arg_cert, freep);
STATIC_DESTRUCTOR_REGISTER(arg_trust, freep);
+STATIC_DESTRUCTOR_REGISTER(arg_output, freep);
static const char* const journal_write_split_mode_table[_JOURNAL_WRITE_SPLIT_MAX] = {
[JOURNAL_WRITE_SPLIT_NONE] = "none",
@@ -957,7 +958,9 @@ static int parse_argv(int argc, char *argv[]) {
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"cannot use --output/-o more than once");
- arg_output = optarg;
+ r = parse_path_argument(optarg, /* suppress_root = */ false, &arg_output);
+ if (r < 0)
+ return r;
break;
case ARG_SPLIT_MODE: