summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-12-15 22:03:33 +0900
committerGitHub <noreply@github.com>2022-12-15 22:03:33 +0900
commitb3f1afc08910044f2f55188c266264738a538d10 (patch)
tree6ecceab84c81fb20f9544bb85c1409947d609670 /src/shared
parent0969bb4246acdac8ef91ad99515ae75fe3da734b (diff)
parent1c9c6fc7dfdaa8fa29d1adeeacafc2450cc86e30 (diff)
downloadsystemd-b3f1afc08910044f2f55188c266264738a538d10.tar.gz
Merge pull request #24058 from qdeslandes/journald_regex_filtering
Allow for journald logs filtering on a per-unit basis
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/bus-unit-util.c10
-rw-r--r--src/shared/pcre2-util.c9
-rw-r--r--src/shared/pcre2-util.h3
3 files changed, 22 insertions, 0 deletions
diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c
index 7d136df2d9..7154c9b4c0 100644
--- a/src/shared/bus-unit-util.c
+++ b/src/shared/bus-unit-util.c
@@ -1218,6 +1218,16 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
return 1;
}
+ if (streq(field, "LogFilterPatterns")) {
+ r = sd_bus_message_append(m, "(sv)", "LogFilterPatterns", "a(bs)", 1,
+ eq[0] != '~',
+ eq[0] != '~' ? eq : eq + 1);
+ if (r < 0)
+ return bus_log_create_error(r);
+
+ return 1;
+ }
+
if (STR_IN_SET(field, "StandardInput",
"StandardOutput",
"StandardError")) {
diff --git a/src/shared/pcre2-util.c b/src/shared/pcre2-util.c
index 998dab0491..a2c8687cf9 100644
--- a/src/shared/pcre2-util.c
+++ b/src/shared/pcre2-util.c
@@ -14,6 +14,15 @@ pcre2_code* (*sym_pcre2_compile)(PCRE2_SPTR, PCRE2_SIZE, uint32_t, int *, PCRE2_
int (*sym_pcre2_get_error_message)(int, PCRE2_UCHAR *, PCRE2_SIZE);
int (*sym_pcre2_match)(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, uint32_t, pcre2_match_data *, pcre2_match_context *);
PCRE2_SIZE* (*sym_pcre2_get_ovector_pointer)(pcre2_match_data *);
+
+DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(
+ pcre2_code_hash_ops_free,
+ pcre2_code,
+ (void (*)(const pcre2_code *, struct siphash*))trivial_hash_func,
+ (int (*)(const pcre2_code *, const pcre2_code*))trivial_compare_func,
+ sym_pcre2_code_free);
+#else
+const struct hash_ops pcre2_code_hash_ops_free = {};
#endif
int dlopen_pcre2(void) {
diff --git a/src/shared/pcre2-util.h b/src/shared/pcre2-util.h
index 11f1d77f4f..f1e744d577 100644
--- a/src/shared/pcre2-util.h
+++ b/src/shared/pcre2-util.h
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "hash-funcs.h"
#include "macro.h"
#if HAVE_PCRE2
@@ -24,6 +25,8 @@ typedef struct {} pcre2_code;
#endif
+extern const struct hash_ops pcre2_code_hash_ops_free;
+
typedef enum {
PATTERN_COMPILE_CASE_AUTO,
PATTERN_COMPILE_CASE_SENSITIVE,