PROGS = @PROGS@
-SRCS = alloc.c alloca.c check.c def_data.c defaults.c env.c err.c fileops.c \
- find_path.c fnmatch.c getcwd.c getprogname.c getspwuid.c goodpath.c \
- interfaces.c lex.yy.c lsearch.c logging.c parse.c parse.lex \
+SRCS = alloc.c alloca.c check.c closefrom.c def_data.c defaults.c env.c err.c \
+ fileops.c find_path.c fnmatch.c getcwd.c getprogname.c getspwuid.c \
+ goodpath.c interfaces.c lex.yy.c lsearch.c logging.c parse.c parse.lex \
parse.yacc set_perms.c sigaction.c snprintf.c strcasecmp.c strerror.c \
strlcat.c strlcpy.c sudo.c sudo.tab.c testsudoers.c tgetpass.c utime.c \
visudo.c zero_bytes.c $(AUTH_SRCS)
# Dependencies (not counting auth functions)
alloc.o: alloc.c $(SUDODEP)
check.o: check.c $(SUDODEP)
+closefrom.o: closefrom.c config.h
env.o: env.c $(SUDODEP)
err.o: err.c config.h compat.h emul/err.h
fileops.o: fileops.c $(SUDODEP)
/* Define if you use BSD authentication. */
#undef HAVE_BSD_AUTH_H
+/* Define to 1 if you have the `closefrom' function. */
+#undef HAVE_CLOSEFROM
+
/* Define if you use OSF DCE. */
#undef HAVE_DCE
-for ac_func in strerror strcasecmp sigaction strlcpy strlcat
+
+for ac_func in strerror strcasecmp sigaction strlcpy strlcat closefrom
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
AC_CHECK_FUNCS(utime, [SUDO_FUNC_UTIME_POSIX], [AC_LIBOBJ(utime)])
SUDO_FUNC_FNMATCH(AC_DEFINE(HAVE_FNMATCH, 1, [Define if you have the `fnmatch' function.]), AC_LIBOBJ(fnmatch))
SUDO_FUNC_ISBLANK
-AC_REPLACE_FUNCS(strerror strcasecmp sigaction strlcpy strlcat)
+AC_REPLACE_FUNCS(strerror strcasecmp sigaction strlcpy strlcat closefrom)
AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf, , [NEED_SNPRINTF=1])
dnl
dnl If NEED_SNPRINTF is set, add snprintf.c to LIBOBJS
static void
initial_setup()
{
- int fd, maxfd;
-#ifdef HAVE_SETRLIMIT
+#if defined(RLIMIT_CORE) && !defined(SUDO_DEVEL)
struct rlimit rl;
-#endif
-#if defined(RLIMIT_CORE) && !defined(SUDO_DEVEL)
/*
* Turn off core dumps.
*/
(void) setrlimit(RLIMIT_CORE, &rl);
#endif /* RLIMIT_CORE && !SUDO_DEVEL */
- /*
- * 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);
+ closefrom(STDERR_FILENO + 1);
/*
* Make set_perms point to the correct function.
*/
#define YY_DECL int yylex __P((void))
+#ifndef HAVE_CLOSEFROM
+void closefrom __P((int));
+#endif
#ifndef HAVE_GETCWD
char *getcwd __P((char *, size_t size));
#endif