]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logs-show: match init.scope rather than _PID=1 for UNIT= 40142/head
authorMike Yuan <me@yhndnzj.com>
Fri, 19 Dec 2025 00:56:26 +0000 (01:56 +0100)
committerMike Yuan <me@yhndnzj.com>
Fri, 19 Dec 2025 01:18:44 +0000 (02:18 +0100)
We should consider the whole init.scope trusted, and any
process trying to log on behalf of a unit there should be
attributed as so.

Follow-up for 4f25248b6e69855b4da6d01690821b9359928edc
Only with this commit is the change in effect.

src/shared/logs-show.c

index b01cb67acd6d59dbf31bdcb27635a295e523e52e..119c48936abb284cac02d9a64147571b18482b00 100644 (file)
@@ -1715,9 +1715,11 @@ int add_matches_for_unit_full(sd_journal *j, MatchUnitFlag flags, const char *un
                 /* Look for messages from the service itself */
                 (r = journal_add_match_pair(j, "_SYSTEMD_UNIT", unit)) ||
 
-                /* Look for messages from PID 1 about this service */
+                /* Look for messages from PID 1 about this service. Note that the actual match is placed
+                 * on init.scope rather than _PID=1, as we want to match messages from helper processes
+                 * forked off by init too. */
                 (r = sd_journal_add_disjunction(j)) ||
-                (r = sd_journal_add_match(j, "_PID=1", SIZE_MAX)) ||
+                (r = sd_journal_add_match(j, "_SYSTEMD_CGROUP=/init.scope", SIZE_MAX)) ||
                 (r = journal_add_match_pair(j, "UNIT", unit)) ||
 
                 /* Look for messages from authorized daemons about this service */