diff options
author | brian <brian@FreeBSD.org> | 1999-08-17 14:59:05 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1999-08-17 14:59:05 +0000 |
commit | 56bc7b51a617f91916f0e2e1a3808598dde4e673 (patch) | |
tree | f5a3f5ea4721b3b8c2cac01e84cb57d4de400ef4 /usr.sbin/ppp/command.c | |
parent | f580fbe343df0c71ec99a2c627e7ac6f60abeb74 (diff) | |
download | FreeBSD-src-56bc7b51a617f91916f0e2e1a3808598dde4e673.zip FreeBSD-src-56bc7b51a617f91916f0e2e1a3808598dde4e673.tar.gz |
Set the close-on-exec flag for all unused descriptors when
exec()ing other programs.
Diffstat (limited to 'usr.sbin/ppp/command.c')
-rw-r--r-- | usr.sbin/ppp/command.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index a10cc6b..6c37b10 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.204 1999/08/02 21:45:35 brian Exp $ + * $Id: command.c,v 1.205 1999/08/05 10:32:09 brian Exp $ * */ #include <sys/param.h> @@ -144,7 +144,7 @@ #define NEG_VJCOMP 53 const char Version[] = "2.23"; -const char VersionDate[] = "$Date: 1999/08/02 21:45:35 $"; +const char VersionDate[] = "$Date: 1999/08/05 10:32:09 $"; static int ShowCommand(struct cmdargs const *); static int TerminalCommand(struct cmdargs const *); @@ -478,10 +478,11 @@ ShellCommand(struct cmdargs const *arg, int bg) _PATH_DEVNULL, strerror(errno)); exit(1); } - for (i = 0; i < 3; i++) - dup2(fd, i); - - fcntl(3, F_SETFD, 1); /* Set close-on-exec flag */ + dup2(fd, STDIN_FILENO); + dup2(fd, STDOUT_FILENO); + dup2(fd, STDERR_FILENO); + for (i = getdtablesize(); i > STDERR_FILENO; i--) + fcntl(i, F_SETFD, 1); setuid(geteuid()); if (arg->argc > arg->argn) { @@ -515,7 +516,7 @@ ShellCommand(struct cmdargs const *arg, int bg) log_Printf(LogWARN, "exec() of %s failed: %s\n", arg->argc > arg->argn ? arg->argv[arg->argn] : shell, strerror(errno)); - exit(255); + _exit(255); } if (shpid == (pid_t) - 1) |