dcavalca / rpms / systemd

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