naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
dd65c9
From 70c096e5ae7bb7b415c82ee6cc177ac2d557feff Mon Sep 17 00:00:00 2001
dd65c9
From: Yu Watanabe <watanabe.yu+github@gmail.com>
dd65c9
Date: Sun, 24 Jan 2016 15:45:47 +0900
dd65c9
Subject: [PATCH] journal-remote: make --url option support arbitrary url
dd65c9
dd65c9
Currently, --url option supports the only form like http(s)://some.host:19531.
dd65c9
This commit adds support to call systemd-journal-remote as follwos:
dd65c9
systemd-journal-remote --url='http://some.host:19531'
dd65c9
systemd-journal-remote --url='http://some.host:19531/'
dd65c9
systemd-journal-remote --url='http://some.host:19531/entries'
dd65c9
systemd-journal-remote --url='http://some.host:19531/entries?boot&follow'
dd65c9
The first three example result the same and retrieve all entries.
dd65c9
The last example retrieves only current boot entries and wait new events.
dd65c9
dd65c9
Cherry-picked from: b68f6b0a794f9e6cb6457a0ac55041c4e7b1a5cb
dd65c9
Resolves: #1505385
dd65c9
---
dd65c9
 src/journal-remote/journal-remote.c | 9 ++++++++-
dd65c9
 1 file changed, 8 insertions(+), 1 deletion(-)
dd65c9
dd65c9
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
c62b8e
index 4fac55cc9a..a455fb6bd8 100644
dd65c9
--- a/src/journal-remote/journal-remote.c
dd65c9
+++ b/src/journal-remote/journal-remote.c
dd65c9
@@ -894,7 +894,14 @@ static int remoteserver_init(RemoteServer *s,
dd65c9
         if (arg_url) {
dd65c9
                 const char *url, *hostname;
dd65c9
 
dd65c9
-                url = strjoina(arg_url, "/entries");
dd65c9
+                if (!strstr(arg_url, "/entries")) {
dd65c9
+                        if (endswith(arg_url, "/"))
dd65c9
+                                url = strjoina(arg_url, "entries");
dd65c9
+                        else
dd65c9
+                                url = strjoina(arg_url, "/entries");
dd65c9
+                }
dd65c9
+                else
dd65c9
+                        url = strdupa(arg_url);
dd65c9
 
dd65c9
                 if (arg_getter) {
dd65c9
                         log_info("Spawning getter %s...", url);