Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • G GLib
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 856
    • Issues 856
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 45
    • Merge requests 45
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • GLib
  • Issues
  • #2530
Closed
Open
Issue created Nov 13, 2021 by Ilya Basin@basinilya

g_log_writer_is_journald fails if a Journal Namespace is used

For my Glib program I configured a dedicated instance of journald using Journal Namespaces

GLib fails to recognize stderr as a journald socket and prints debug messages in plain text. It happens because the namespace is appended to the unix socket path: /run/systemd/journal.nicetunnel/stdout. The following fixed it for me:

diff --git a/glib/gmessages.c b/glib/gmessages.c
index 7affcd4d9..374b23ae4 100644
--- a/glib/gmessages.c
+++ b/glib/gmessages.c
@@ -2228,7 +2228,7 @@ g_log_writer_is_journald (gint output_fd)
   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");
 #endif

   return FALSE;

(although journal_sendv still has the hardcoded socket path "/run/systemd/journal/socket")

Config files:

/etc/systemd/journald@nicetunnel.conf:

[Journal]
Storage=volatile
RuntimeMaxUse=20M

/etc/systemd/system/nicetunnel.service:

[Unit]
Description=My Test Service
[Service]
ExecStart=/home/il/builds/nicetunnel/build-msan/src/nicetunnel --peer-addr 127.0.0.1:1194 --stun-addr basinsrv
Environment="G_MESSAGES_DEBUG=nicetunnel"
LogNamespace=nicetunnel
User=il
Assignee
Assign to
Time tracking