diff options
author | Jan Klötzke <Jan.Kloetzke@preh.de> | 2018-01-10 10:36:14 +0100 |
---|---|---|
committer | Jan Klötzke <Jan.Kloetzke@preh.de> | 2018-01-10 10:54:40 +0100 |
commit | 9ce1759311c6734deb69aa7253bf7297536a55d9 (patch) | |
tree | 92c674bc360c3ec8703461273efd34db4e9b7968 /src/basic/util.c | |
parent | 27c34f732e7767b5cdc90fe7ad03ae0ea625671c (diff) | |
download | systemd-9ce1759311c6734deb69aa7253bf7297536a55d9.tar.gz |
tree-wide: introduce disable_core_dumps helper and port existing users
Changes the core_pattern to prevent any core dumps by the kernel. Does
nothing if we're in a container environment as this is system wide
setting.
Diffstat (limited to 'src/basic/util.c')
-rw-r--r-- | src/basic/util.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/basic/util.c b/src/basic/util.c index 2a39ff2b53..b1e6f5002e 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -61,6 +61,7 @@ #include "umask-util.h" #include "user-util.h" #include "util.h" +#include "virt.h" int saved_argc = 0; char **saved_argv = NULL; @@ -615,3 +616,9 @@ int str_verscmp(const char *s1, const char *s2) { return strcmp(os1, os2); } + +/* Turn off core dumps but only if we're running outside of a container. */ +void disable_core_dumps(void) { + if (detect_container() <= 0) + (void) write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", 0); +} |