version 1.21, 2003/12/23 02:19:51 |
version 1.22, 2004/01/12 19:13:21 |
|
|
static void |
static void |
initial_setup() |
initial_setup() |
{ |
{ |
int fd, maxfd; |
#if defined(RLIMIT_CORE) && !defined(SUDO_DEVEL) |
#ifdef HAVE_SETRLIMIT |
|
struct rlimit rl; |
struct rlimit rl; |
#endif |
|
|
|
#if defined(RLIMIT_CORE) && !defined(SUDO_DEVEL) |
|
/* |
/* |
* Turn off core dumps. |
* Turn off core dumps. |
*/ |
*/ |
|
|
(void) setrlimit(RLIMIT_CORE, &rl); |
(void) setrlimit(RLIMIT_CORE, &rl); |
#endif /* RLIMIT_CORE && !SUDO_DEVEL */ |
#endif /* RLIMIT_CORE && !SUDO_DEVEL */ |
|
|
/* |
closefrom(STDERR_FILENO + 1); |
* Close any open fd's other than stdin, stdout and stderr. |
|
*/ |
|
#ifdef HAVE_SYSCONF |
|
maxfd = sysconf(_SC_OPEN_MAX) - 1; |
|
#else |
|
maxfd = getdtablesize() - 1; |
|
#endif /* HAVE_SYSCONF */ |
|
#ifdef RLIMIT_NOFILE |
|
if (getrlimit(RLIMIT_NOFILE, &rl) == 0) { |
|
if (rl.rlim_max != RLIM_INFINITY && rl.rlim_max <= maxfd) |
|
maxfd = rl.rlim_max - 1; |
|
} |
|
#endif /* RLIMIT_NOFILE */ |
|
|
|
for (fd = maxfd; fd > STDERR_FILENO; fd--) |
|
(void) close(fd); |
|
|
|
/* |
/* |
* Make set_perms point to the correct function. |
* Make set_perms point to the correct function. |