teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame 0154-Ensure-unit-is-journaled-for-short-lived-or-oneshot-.patch

Zbigniew Jędrzejewski-Szmek 126222
From d8b3047ccb52c2b55683f2fe12f0674f63d746cb Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek 126222
From: Dan McGee <dan@archlinux.org>
Zbigniew Jędrzejewski-Szmek 126222
Date: Sun, 8 Dec 2013 13:27:05 -0600
Zbigniew Jędrzejewski-Szmek 126222
Subject: [PATCH] Ensure unit is journaled for short-lived or oneshot processes
Zbigniew Jędrzejewski-Szmek 126222
Zbigniew Jędrzejewski-Szmek 126222
In the time it takes to process incoming log messages, the process we
Zbigniew Jędrzejewski-Szmek 126222
are logging details for may exit. This means the cgroup data is no
Zbigniew Jędrzejewski-Szmek 126222
longer available from '/proc'. Unfortunately, the way the code was
Zbigniew Jędrzejewski-Szmek 126222
structured before, we never log _SYSTEMD_UNIT if we don't have this
Zbigniew Jędrzejewski-Szmek 126222
cgroup information.
Zbigniew Jędrzejewski-Szmek 126222
Zbigniew Jędrzejewski-Szmek 126222
Add an else if case that allows the passed in unit_id to be logged even
Zbigniew Jędrzejewski-Szmek 126222
if we couldn't capture cgroup information. This ensures a command like
Zbigniew Jędrzejewski-Szmek 126222
`journalctl -u run-XXX` will return all log messages from a oneshot
Zbigniew Jędrzejewski-Szmek 126222
process.
Zbigniew Jędrzejewski-Szmek 126222
---
Zbigniew Jędrzejewski-Szmek 126222
 src/journal/journald-server.c | 3 +++
Zbigniew Jędrzejewski-Szmek 126222
 1 file changed, 3 insertions(+)
Zbigniew Jędrzejewski-Szmek 126222
Zbigniew Jędrzejewski-Szmek 126222
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
Zbigniew Jędrzejewski-Szmek 126222
index a0a8e9c..1fcb3d5 100644
Zbigniew Jędrzejewski-Szmek 126222
--- a/src/journal/journald-server.c
Zbigniew Jędrzejewski-Szmek 126222
+++ b/src/journal/journald-server.c
Zbigniew Jędrzejewski-Szmek 126222
@@ -626,6 +626,9 @@ static void dispatch_message_real(
Zbigniew Jędrzejewski-Szmek 126222
                         }
Zbigniew Jędrzejewski-Szmek 126222
 
Zbigniew Jędrzejewski-Szmek 126222
                         free(c);
Zbigniew Jędrzejewski-Szmek 126222
+                } else if (unit_id) {
Zbigniew Jędrzejewski-Szmek 126222
+                        x = strappenda("_SYSTEMD_UNIT=", unit_id);
Zbigniew Jędrzejewski-Szmek 126222
+                        IOVEC_SET_STRING(iovec[n++], x);
Zbigniew Jędrzejewski-Szmek 126222
                 }
Zbigniew Jędrzejewski-Szmek 126222
 
Zbigniew Jędrzejewski-Szmek 126222
 #ifdef HAVE_SELINUX