summaryrefslogtreecommitdiffstats
path: root/src/journal/journald-context.c
diff options
context:
space:
mode:
authorQuentin Deslandes <qde@naccy.de>2022-09-13 17:15:13 +0200
committerQuentin Deslandes <qde@naccy.de>2022-12-15 10:57:39 +0100
commit87a13dabbd81c2e31fd5ac7b81cce61baf23e59c (patch)
tree83b4ddf0c6602b544ccf97a5110586760b1a5c25 /src/journal/journald-context.c
parentCreate hash_ops structure to free keys of type pcre2_code (diff)
downloadsystemd-87a13dabbd81c2e31fd5ac7b81cce61baf23e59c.tar.xz
systemd-87a13dabbd81c2e31fd5ac7b81cce61baf23e59c.zip
journal: filter log based on LogFilterPatterns
Use LogFilterPatterns from the unit's cgroup xattr in order to keep or discard log messages before writing them to the journal. When a log message is discarded, it won't be written to syslog, console... either. When a native, syslog, or standard output log message is received, systemd-journald will process it if it matches against at least one allowed pattern (if any) and none of the denied patterns (if any).
Diffstat (limited to 'src/journal/journald-context.c')
-rw-r--r--src/journal/journald-context.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/journal/journald-context.c b/src/journal/journald-context.c
index 222855ae60..55e657c7e1 100644
--- a/src/journal/journald-context.c
+++ b/src/journal/journald-context.c
@@ -14,6 +14,7 @@
#include "io-util.h"
#include "journal-internal.h"
#include "journal-util.h"
+#include "journald-client.h"
#include "journald-context.h"
#include "parse-util.h"
#include "path-util.h"
@@ -180,6 +181,9 @@ static void client_context_reset(Server *s, ClientContext *c) {
c->log_ratelimit_interval = s->ratelimit_interval;
c->log_ratelimit_burst = s->ratelimit_burst;
+
+ c->log_filter_allowed_patterns = set_free(c->log_filter_allowed_patterns);
+ c->log_filter_denied_patterns = set_free(c->log_filter_denied_patterns);
}
static ClientContext* client_context_free(Server *s, ClientContext *c) {
@@ -290,6 +294,8 @@ static int client_context_read_cgroup(Server *s, ClientContext *c, const char *u
return r;
}
+ (void) client_context_read_log_filter_patterns(c, t);
+
/* Let's shortcut this if the cgroup path didn't change */
if (streq_ptr(c->cgroup, t))
return 0;