summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorQuentin Deslandes <qde@naccy.de>2023-01-26 19:44:10 +0100
committerQuentin Deslandes <qde@naccy.de>2023-02-08 16:52:51 +0100
commit41b7fcc5e8a66709ad5d6c7cdba1375539f7693d (patch)
tree6ebd54234139c497b121fddb16a2e91e11af5a60 /src/journal
parentee164216d38bc7ca51e040b90bdc96ed7518df37 (diff)
downloadsystemd-41b7fcc5e8a66709ad5d6c7cdba1375539f7693d.tar.gz
journald: fix ignored filtering patterns for delegated cgroups
If a service defines Delegate=yes, its subcgroup won't inherit the LogFilterPatterns= option, because the option is stored on the unit's cgroup attributes, not on the subcgroup. Fixed by using the unit's cgroup attributes instead.
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/journald-client.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/journal/journald-client.c b/src/journal/journald-client.c
index 22090aa93c..5aedf4e5b6 100644
--- a/src/journal/journald-client.c
+++ b/src/journal/journald-client.c
@@ -46,16 +46,20 @@ static int client_parse_log_filter_nulstr(const char *nulstr, size_t len, Set **
int client_context_read_log_filter_patterns(ClientContext *c, const char *cgroup) {
char *deny_list_xattr, *xattr_end;
- _cleanup_free_ char *xattr = NULL;
+ _cleanup_free_ char *xattr = NULL, *unit_cgroup = NULL;
_cleanup_set_free_ Set *allow_list = NULL, *deny_list = NULL;
int r;
assert(c);
- r = cg_get_xattr_malloc(SYSTEMD_CGROUP_CONTROLLER, cgroup, "user.journald_log_filter_patterns", &xattr);
+ r = cg_path_get_unit_path(cgroup, &unit_cgroup);
+ if (r < 0)
+ return log_debug_errno(r, "Failed to get the unit's cgroup path for %s: %m", cgroup);
+
+ r = cg_get_xattr_malloc(SYSTEMD_CGROUP_CONTROLLER, unit_cgroup, "user.journald_log_filter_patterns", &xattr);
if (r < 0) {
if (!ERRNO_IS_XATTR_ABSENT(r))
- return log_debug_errno(r, "Failed to get user.journald_log_filter_patterns xattr for %s: %m", cgroup);
+ return log_debug_errno(r, "Failed to get user.journald_log_filter_patterns xattr for %s: %m", unit_cgroup);
client_set_filtering_patterns(c, NULL, NULL);
return 0;