diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-04-04 16:43:25 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-04-09 14:08:48 +0200 |
commit | ad21e542b20f0fb292d1958d3a759bf3403522c2 (patch) | |
tree | ed9dfb77fb223672ccdbf33bd64d88542a5d3d92 /src/shared/coredump-util.c | |
parent | Add parser and printer for coredump filter mask (diff) | |
download | systemd-ad21e542b20f0fb292d1958d3a759bf3403522c2.tar.xz systemd-ad21e542b20f0fb292d1958d3a759bf3403522c2.zip |
manager: add CoredumpFilter= setting
Fixes #6685.
Diffstat (limited to 'src/shared/coredump-util.c')
-rw-r--r-- | src/shared/coredump-util.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/shared/coredump-util.c b/src/shared/coredump-util.c index 3fa8664051..67897414bc 100644 --- a/src/shared/coredump-util.c +++ b/src/shared/coredump-util.c @@ -2,6 +2,7 @@ #include "coredump-util.h" #include "extract-word.h" +#include "fileio.h" #include "string-table.h" static const char *const coredump_filter_table[_COREDUMP_FILTER_MAX] = { @@ -62,3 +63,12 @@ int coredump_filter_mask_from_string(const char *s, uint64_t *ret) { *ret = m; return 0; } + +int set_coredump_filter(uint64_t value) { + char t[STRLEN("0xFFFFFFFF")]; + + sprintf(t, "0x%"PRIx64, value); + + return write_string_file("/proc/self/coredump_filter", t, + WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_DISABLE_BUFFER); +} |