From bceba1f2ed34f5195c5a772e14b51f888507dc6c Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Thu, 24 Mar 2022 14:18:45 +0800 Subject: [PATCH] Only set soft core limit not hard limit Otherwise child shells can't enable coredumps if desired. Fixes #145 on github --- dbutil.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dbutil.c b/dbutil.c index 1bd753c..8876cd1 100644 --- a/dbutil.c +++ b/dbutil.c @@ -599,9 +599,14 @@ void setnonblocking(int fd) { } void disallow_core() { - struct rlimit lim; - lim.rlim_cur = lim.rlim_max = 0; - setrlimit(RLIMIT_CORE, &lim); + struct rlimit lim = {0}; + if (getrlimit(RLIMIT_CORE, &lim) < 0) { + TRACE(("getrlimit(RLIMIT_CORE) failed")); + } + lim.rlim_cur = 0; + if (setrlimit(RLIMIT_CORE, &lim) < 0) { + TRACE(("setrlimit(RLIMIT_CORE) failed")); + } } /* Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE, with the result in *val */