summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/exec.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-08-17 14:59:05 +0000
committerbrian <brian@FreeBSD.org>1999-08-17 14:59:05 +0000
commit56bc7b51a617f91916f0e2e1a3808598dde4e673 (patch)
treef5a3f5ea4721b3b8c2cac01e84cb57d4de400ef4 /usr.sbin/ppp/exec.c
parentf580fbe343df0c71ec99a2c627e7ac6f60abeb74 (diff)
downloadFreeBSD-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/exec.c')
-rw-r--r--usr.sbin/ppp/exec.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.sbin/ppp/exec.c b/usr.sbin/ppp/exec.c
index c838800..19e74bd 100644
--- a/usr.sbin/ppp/exec.c
+++ b/usr.sbin/ppp/exec.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: exec.c,v 1.6 1999/06/09 08:47:36 brian Exp $
+ * $Id: exec.c,v 1.7 1999/08/06 20:04:03 brian Exp $
*/
#include <sys/param.h>
@@ -103,7 +103,7 @@ exec_Create(struct physical *p)
log_Printf(LogPHASE, "Unable to create pipe for line exec: %s\n",
strerror(errno));
else {
- int stat, argc;
+ int stat, argc, i;
pid_t pid, realpid;
char *argv[MAXARGS];
@@ -135,17 +135,19 @@ exec_Create(struct physical *p)
_exit(127);
}
- fids[1] = fcntl(fids[1], F_DUPFD, 3);
+ log_Printf(LogDEBUG, "Exec'ing ``%s''\n", p->name.base);
+
dup2(fids[1], STDIN_FILENO);
dup2(fids[1], STDOUT_FILENO);
dup2(fids[1], STDERR_FILENO);
+ for (i = getdtablesize(); i > STDERR_FILENO; i--)
+ fcntl(i, F_SETFD, 1);
- log_Printf(LogDEBUG, "Exec'ing ``%s''\n", p->name.base);
argc = MakeArgs(p->name.base, argv, VECSIZE(argv));
command_Expand(argv, argc, (char const *const *)argv,
p->dl->bundle, 0, realpid);
execvp(*argv, argv);
- fprintf(stderr, "execvp failed: %s: %s\r\n", *argv, strerror(errno));
+ printf("execvp failed: %s: %s\r\n", *argv, strerror(errno));
_exit(127);
break;
OpenPOWER on IntegriCloud