ryantimwilson / rpms / systemd

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