From: Todd C. Miller Date: Wed, 9 Apr 2003 20:13:04 +0000 (+0000) Subject: Don't change rl.rlim_max for RLIMIT_CORE. We need only set rl.rlim_cur X-Git-Tag: SUDO_1_6_8~337 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e15de8443d5cea3f968a270e1018112d74748a20;p=sudo Don't change rl.rlim_max for RLIMIT_CORE. We need only set rl.rlim_cur to 0 to turn off core dumps. This may be needed for the RLIMIT_CORE restoration on some OSes. --- diff --git a/sudo.c b/sudo.c index 315a24589..f00beb752 100644 --- a/sudo.c +++ b/sudo.c @@ -138,7 +138,7 @@ uid_t timestamp_uid; extern int errorlineno; #if defined(RLIMIT_CORE) && !defined(SUDO_DEVEL) static struct rlimit corelimit; -#endif /* RLIMIT_CORE */ +#endif /* RLIMIT_CORE && !SUDO_DEVEL */ #ifdef HAVE_LOGIN_CAP_H login_cap_t *lc; #endif /* HAVE_LOGIN_CAP_H */ @@ -391,7 +391,7 @@ main(argc, argv, envp) /* Restore coredumpsize resource limit. */ #if defined(RLIMIT_CORE) && !defined(SUDO_DEVEL) (void) setrlimit(RLIMIT_CORE, &corelimit); -#endif /* RLIMIT_CORE */ +#endif /* RLIMIT_CORE && !SUDO_DEVEL */ /* Become specified user or root. */ set_perms(PERM_RUNAS); @@ -862,9 +862,10 @@ initial_setup() * Turn off core dumps. */ (void) getrlimit(RLIMIT_CORE, &corelimit); - rl.rlim_cur = rl.rlim_max = 0; + memcpy(&rl, &corelimit, sizeof(struct rlimit)); + rl.rlim_cur = 0; (void) setrlimit(RLIMIT_CORE, &rl); -#endif /* RLIMIT_CORE */ +#endif /* RLIMIT_CORE && !SUDO_DEVEL */ /* * Close any open fd's other than stdin, stdout and stderr.