summaryrefslogtreecommitdiffstats
path: root/src/journal-remote/journal-remote.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2016-01-24 07:49:04 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2016-01-24 08:11:21 +0100
commitd10accb0b1af1950882fd91f19dc7df4b0e11aa6 (patch)
tree6553c6ab864914c98e6c0e206e3bcfc96f19403b /src/journal-remote/journal-remote.c
parentjournal-remote: make --url option support arbitrary url (diff)
downloadsystemd-d10accb0b1af1950882fd91f19dc7df4b0e11aa6.tar.xz
systemd-d10accb0b1af1950882fd91f19dc7df4b0e11aa6.zip
journal-remote: output file name is determined by the remote hostname
When --url option is specified, e.g. --url='http://some.host:19531/entries' retrieved remote journal entries will be stored to /var/log/journal/remote/remote-some.host.journal
Diffstat (limited to 'src/journal-remote/journal-remote.c')
-rw-r--r--src/journal-remote/journal-remote.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index fa0cc99b89..68237be643 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -898,7 +898,8 @@ static int remoteserver_init(RemoteServer *s,
}
if (arg_url) {
- const char *url, *hostname;
+ const char *url;
+ char *hostname, *p;
if (!strstr(arg_url, "/entries")) {
if (endswith(arg_url, "/"))
@@ -924,7 +925,15 @@ static int remoteserver_init(RemoteServer *s,
startswith(arg_url, "http://") ?:
arg_url;
- r = add_source(s, fd, (char*) hostname, false);
+ hostname = strdupa(hostname);
+ if (!hostname)
+ return log_oom();
+ if ((p = strchr(hostname, '/')))
+ *p = '\0';
+ if ((p = strchr(hostname, ':')))
+ *p = '\0';
+
+ r = add_source(s, fd, hostname, false);
if (r < 0)
return r;
}