[glib/glib-2-70: 1/2] gmessages: Support namespaced journals




commit 04507fcaff6fce5e85712a823e0d89c4e636bf9d
Author: Philip Withnall <pwithnall endlessos org>
Date:   Tue Nov 16 14:43:12 2021 +0000

    gmessages: Support namespaced journals
    
    Spotted and diagnosed by Ilya Basin.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Fixes: #2530

 glib/gmessages.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/glib/gmessages.c b/glib/gmessages.c
index 7affcd4d9..2e8a34817 100644
--- a/glib/gmessages.c
+++ b/glib/gmessages.c
@@ -2225,10 +2225,14 @@ g_log_writer_is_journald (gint output_fd)
   if (output_fd < 0)
     return FALSE;
 
+  /* Namespaced journals start with `/run/systemd/journal.${name}/` (see
+   * `RuntimeDirectory=systemd/journal.%i` in `systemd-journald@.service`. The
+   * default journal starts with `/run/systemd/journal/`. */
   addr_len = sizeof(addr);
   err = getpeername (output_fd, &addr.sa, &addr_len);
   if (err == 0 && addr.storage.ss_family == AF_UNIX)
-    return g_str_has_prefix (addr.un.sun_path, "/run/systemd/journal/");
+    return (g_str_has_prefix (addr.un.sun_path, "/run/systemd/journal/") ||
+            g_str_has_prefix (addr.un.sun_path, "/run/systemd/journal."));
 #endif
 
   return FALSE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]