changeset 1903:9382271da9ef

Only set soft core limit not hard limit Otherwise child shells can't enable coredumps if desired. Fixes #145 on github
author Matt Johnston <matt@ucc.asn.au>
date Thu, 24 Mar 2022 14:18:45 +0800
parents 4a6725ac957c
children be236878efcf
files dbutil.c
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/dbutil.c	Thu Mar 24 13:42:08 2022 +0800
+++ b/dbutil.c	Thu Mar 24 14:18:45 2022 +0800
@@ -599,9 +599,14 @@
 }
 
 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 */