2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 06:15:37 +00:00

Stash coredumpsize resource limit and retsore it before the exec()

Otherwise the child ends up with a coredumpsize of 0.
This commit is contained in:
Todd C. Miller
2000-02-28 23:58:17 +00:00
parent f7fa520540
commit 24f8ee8807

17
sudo.c
View File

@@ -121,11 +121,14 @@ int NewArgc = 0;
char **NewArgv = NULL;
struct sudo_user sudo_user;
FILE *sudoers_fp = NULL;
static char *runas_homedir = NULL; /* XXX */
struct interface *interfaces;
int num_interfaces;
int tgetpass_flags;
extern int errorlineno;
static char *runas_homedir = NULL; /* XXX */
#if defined(RLIMIT_CORE) && !defined(SUDO_DEVEL)
static struct rlimit corelimit;
#endif /* RLIMIT_CORE */
/*
* Table of "bad" envariables to remove and len for strncmp()
@@ -332,9 +335,6 @@ main(argc, argv)
exit(0);
}
/* Become specified user or root. */
set_perms(PERM_RUNAS, sudo_mode);
/* Set $HOME for `sudo -H' */
if ((sudo_mode & MODE_RESET_HOME) && runas_homedir)
(void) sudo_setenv("HOME", runas_homedir);
@@ -369,6 +369,14 @@ main(argc, argv)
exit(1);
}
/* Restore coredumpsize resource limit. */
#if defined(RLIMIT_CORE) && !defined(SUDO_DEVEL)
(void) setrlimit(RLIMIT_CORE, &corelimit);
#endif /* RLIMIT_CORE */
/* Become specified user or root. */
set_perms(PERM_RUNAS, sudo_mode);
#ifndef PROFILING
if ((sudo_mode & MODE_BACKGROUND) && fork() > 0)
exit(0);
@@ -1009,6 +1017,7 @@ initial_setup()
/*
* Turn off core dumps.
*/
(void) getrlimit(RLIMIT_CORE, &corelimit);
rl.rlim_cur = rl.rlim_max = 0;
(void) setrlimit(RLIMIT_CORE, &rl);
#endif /* RLIMIT_CORE */