]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal-remote: output file name is determined by the remote hostname
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 24 Jan 2016 06:49:04 +0000 (15:49 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 24 Jan 2016 07:11:21 +0000 (16:11 +0900)
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

src/journal-remote/journal-remote.c

index fa0cc99b89e8eea74fe2193ea5ce1d9b07f0c745..68237be643bcf47f51d89dcae33f457f55ad616a 100644 (file)
@@ -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;
         }