[systemd-devel] [PATCH] coredump: vacuum - fix MaxUse and KeepFree default handling

Mike Winter mike.winter at vecima.com
Wed Apr 29 13:31:51 PDT 2015


When max_use and keep_free are set to the defaults in coredump.conf for 
use in non-journal cores, systemd-coredump ignores the settings 
altogether and proceeds to fill up all available disk space with coredumps.

'-1 'is used internally inside of coredump.c and coredump-vacuum.c to 
denote default values, but coredump_vacuum() itself throws away all 
negative values as a bounds check, causing the error.


---
  src/journal/coredump-vacuum.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/journal/coredump-vacuum.c b/src/journal/coredump-vacuum.c
index 9b73795..74bfbbc 100644
--- a/src/journal/coredump-vacuum.c
+++ b/src/journal/coredump-vacuum.c
@@ -135,8 +135,11 @@ int coredump_vacuum(int exclude_fd, off_t 
keep_free, off_t max_use) {
          struct stat exclude_st;
          int r;

-        if (keep_free <= 0 && max_use <= 0)
-                return 0;
+        /* Set nonsense values to the defaults. */
+        if (keep_free <= 0)
+                keep_free = -1;
+        if (max_use <= 0)
+                max_use = -1;

          if (exclude_fd >= 0) {
                  if (fstat(exclude_fd, &exclude_st) < 0)
-- 
1.9.1


More information about the systemd-devel mailing list