diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2004-01-12 19:13:22 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2004-01-12 19:13:22 +0000 |
commit | 206a6df6481eb4fe5c026ecbaed82d7f537ae071 (patch) | |
tree | 3255abe90c15221b9a9db798e481fbdc3b44d978 /usr.bin/sudo | |
parent | d536ad436ec94177cf155dd869cfb1ed387063f6 (diff) |
Use closefrom() if it exists; from the sudo cvs repo
Diffstat (limited to 'usr.bin/sudo')
-rw-r--r-- | usr.bin/sudo/Makefile.in | 7 | ||||
-rw-r--r-- | usr.bin/sudo/config.h.in | 3 | ||||
-rw-r--r-- | usr.bin/sudo/configure | 3 | ||||
-rw-r--r-- | usr.bin/sudo/configure.in | 2 | ||||
-rw-r--r-- | usr.bin/sudo/sudo.c | 23 | ||||
-rw-r--r-- | usr.bin/sudo/sudo.h | 3 |
6 files changed, 15 insertions, 26 deletions
diff --git a/usr.bin/sudo/Makefile.in b/usr.bin/sudo/Makefile.in index 0b099394891..d26a1c8a616 100644 --- a/usr.bin/sudo/Makefile.in +++ b/usr.bin/sudo/Makefile.in @@ -113,9 +113,9 @@ SHELL = /bin/sh 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) @@ -210,6 +210,7 @@ testsudoers: $(TESTOBJS) $(LIBOBJS) # 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) diff --git a/usr.bin/sudo/config.h.in b/usr.bin/sudo/config.h.in index 41735cf5f33..112c13093db 100644 --- a/usr.bin/sudo/config.h.in +++ b/usr.bin/sudo/config.h.in @@ -65,6 +65,9 @@ /* 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 diff --git a/usr.bin/sudo/configure b/usr.bin/sudo/configure index 6cbdc5a8b85..1bdb0cb74ac 100644 --- a/usr.bin/sudo/configure +++ b/usr.bin/sudo/configure @@ -11039,7 +11039,8 @@ _ACEOF -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 diff --git a/usr.bin/sudo/configure.in b/usr.bin/sudo/configure.in index ca72d574c97..0bb24cb6166 100644 --- a/usr.bin/sudo/configure.in +++ b/usr.bin/sudo/configure.in @@ -1660,7 +1660,7 @@ AC_CHECK_FUNCS(lsearch, , [AC_CHECK_LIB(compat, lsearch, AC_CHECK_HEADER(search. 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 diff --git a/usr.bin/sudo/sudo.c b/usr.bin/sudo/sudo.c index 26feb1f71a3..0e31b7aa89b 100644 --- a/usr.bin/sudo/sudo.c +++ b/usr.bin/sudo/sudo.c @@ -862,12 +862,9 @@ check_sudoers() 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. */ @@ -877,23 +874,7 @@ initial_setup() (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. diff --git a/usr.bin/sudo/sudo.h b/usr.bin/sudo/sudo.h index 07594d3c992..afc01c7cbc9 100644 --- a/usr.bin/sudo/sudo.h +++ b/usr.bin/sudo/sudo.h @@ -182,6 +182,9 @@ struct sudo_user { */ #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 |