summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2022-03-24 14:18:45 +0800
committerMatt Johnston <matt@ucc.asn.au>2022-03-24 14:18:45 +0800
commit08efce06f113ca3f410e2c2a5f5c4163328d4010 (patch)
treee0c985506bf433cb909ac886e274d5586ecd9d41
parent5af2b90518cc0a7014467e29da6f3f9efbc7dfe1 (diff)
downloaddropbear-08efce06f113ca3f410e2c2a5f5c4163328d4010.tar.gz
Only set soft core limit not hard limit
Otherwise child shells can't enable coredumps if desired. Fixes #145 on github
-rw-r--r--dbutil.c11
1 files 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 */