From: Zbigniew Jędrzejewski-Szmek Date: Thu, 17 May 2018 14:59:21 +0000 (+0200) Subject: coredump: properly treat Storage=none as disabled storage X-Git-Tag: v239~248^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ee0449fd7a5d4755d133cf0ddba8ddadc07f057e;p=thirdparty%2Fsystemd.git coredump: properly treat Storage=none as disabled storage Also don't attempt to create /var/lib/systemd/coredump if storage limit is set to 0 and coredump processing is disabled. --- diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index 423a1c21a41..c1f396b1ac7 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -141,7 +141,12 @@ static int parse_config(void) { } static inline uint64_t storage_size_max(void) { - return arg_storage == COREDUMP_STORAGE_EXTERNAL ? arg_external_size_max : arg_journal_size_max; + if (arg_storage == COREDUMP_STORAGE_EXTERNAL) + return arg_external_size_max; + if (arg_storage == COREDUMP_STORAGE_JOURNAL) + return arg_journal_size_max; + assert(arg_storage == COREDUMP_STORAGE_NONE); + return 0; } static int fix_acl(int fd, uid_t uid) { @@ -323,7 +328,7 @@ static int save_external_coredump( _cleanup_free_ char *fn = NULL, *tmp = NULL; _cleanup_close_ int fd = -1; - uint64_t rlimit, max_size; + uint64_t rlimit, process_limit, max_size; struct stat st; uid_t uid; int r; @@ -350,8 +355,14 @@ static int save_external_coredump( return -EBADSLT; } + process_limit = MAX(arg_process_size_max, storage_size_max()); + if (process_limit == 0) { + log_debug("Limits for coredump processing and storage are both 0, not dumping core."); + return -EBADSLT; + } + /* Never store more than the process configured, or than we actually shall keep or process */ - max_size = MIN(rlimit, MAX(arg_process_size_max, storage_size_max())); + max_size = MIN(rlimit, process_limit); r = make_filename(context, &fn); if (r < 0)