summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-03-10 18:44:29 +0000
committerJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-03-10 18:44:29 +0000
commit7360172a8ae56f50fdbfdad8721b6406e3314daf (patch)
treed20f855f89038a78da59ef143f22a222b14029a7
parent5c46f26fff7dee9de72a7eb20c36e15f8aff2a0e (diff)
- Use setsid(2) to create new process group for external mda.
- Unignore SIGPIPE, otherwise it remains ignored in forked mda. - Use closefrom(2) to close all descriptors apart from stdin/stdout/stderr. ok gilles@
-rw-r--r--usr.sbin/smtpd/smtpd.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c
index 59d89c252a9..200b66c3fe2 100644
--- a/usr.sbin/smtpd/smtpd.c
+++ b/usr.sbin/smtpd/smtpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.c,v 1.45 2009/03/10 13:05:05 jacekm Exp $ */
+/* $OpenBSD: smtpd.c,v 1.46 2009/03/10 18:44:28 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -1137,9 +1137,17 @@ parent_external_mda(char *path, struct passwd *pw, struct batch *batchp)
if (*word != '\0')
addargs(&args, "%s", word);
+ if (setsid() == -1)
+ fatal("setsid");
+
+ if (signal(SIGPIPE, SIG_DFL) == SIG_ERR)
+ fatal("signal");
+
if (dup2(pipefd[0], STDIN_FILENO) == -1)
fatal("dup2");
- close(pipefd[1]);
+
+ if (closefrom(STDERR_FILENO + 1) == -1)
+ fatal("closefrom");
execvp(args.list[0], args.list);
_exit(1);