Merge branch 'backport-2338-journald-namespaced-glib-2-70' into 'glib-2-70'

Backport !2338 “gmessages: Support namespaced journals” to glib-2-70

See merge request GNOME/glib!2340
This commit is contained in:
Sebastian Dröge 2021-11-16 16:26:49 +00:00
commit ae0a0d0dd5

View File

@ -2225,10 +2225,14 @@ g_log_writer_is_journald (gint output_fd)
if (output_fd < 0) if (output_fd < 0)
return FALSE; 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); addr_len = sizeof(addr);
err = getpeername (output_fd, &addr.sa, &addr_len); err = getpeername (output_fd, &addr.sa, &addr_len);
if (err == 0 && addr.storage.ss_family == AF_UNIX) 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 #endif
return FALSE; return FALSE;