summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/smtpd.c
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2016-09-06 16:34:30 +0000
committerEric Faurot <eric@cvs.openbsd.org>2016-09-06 16:34:30 +0000
commite4fd32021c8d2c63e6636ebbbf8cf2f63f851e91 (patch)
tree9b7a0b2972cf7398a7af5277ad7a6ed641240cb6 /usr.sbin/smtpd/smtpd.c
parent2f9ea9c3f89db9f841be2fcf42edc87c49233efc (diff)
use closefrom() before reexec to make sure the new process only gets
the imsg socket. ok gilles@ sunil@
Diffstat (limited to 'usr.sbin/smtpd/smtpd.c')
-rw-r--r--usr.sbin/smtpd/smtpd.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c
index c638e043e8c..661915d935d 100644
--- a/usr.sbin/smtpd/smtpd.c
+++ b/usr.sbin/smtpd/smtpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.c,v 1.284 2016/09/04 16:10:31 eric Exp $ */
+/* $OpenBSD: smtpd.c,v 1.285 2016/09/06 16:34:29 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -810,11 +810,12 @@ start_child(int save_argc, char **save_argv, char *rexec)
return p;
}
- close(sp[1]);
-
if (dup2(sp[0], 3) == -1)
fatal("%s: dup2", rexec);
+ if (closefrom(4) == -1)
+ fatal("%s: closefrom", rexec);
+
for (argc = 0; argc < save_argc; argc++)
argv[argc] = save_argv[argc];
argv[argc++] = "-x";