chiark / gitweb /
tree-wide: introduce disable_core_dumps helper and port existing users
authorJan Klötzke <Jan.Kloetzke@preh.de>
Wed, 10 Jan 2018 09:36:14 +0000 (10:36 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:50:03 +0000 (07:50 +0200)
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.

src/basic/util.c
src/basic/util.h

index a7cc3ecfb9ef22ae16baffd9b8a79bb406b13411..f60f60b02cbc4c71e46349a20aff009d2884bfcf 100644 (file)
@@ -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;
@@ -625,3 +626,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);
+}
index f9432ebb58b89f17772e3e25ecd4abf86d7dfcce..643ce3bc4f87d031863cecfde5e3dd64c64846ca 100644 (file)
@@ -205,3 +205,5 @@ int version(void);
 #if 0 /// UNNEEDED by elogind
 #endif // 0
 int str_verscmp(const char *s1, const char *s2);
+
+void disable_core_dumps(void);