dma(8): Fix race condition in multi-recipient delivery

Simon 'corecode' Schubert corecode at fs.ei.tum.de
Thu Jul 9 16:55:24 PDT 2009


Daniel Roethlisberger wrote:
Simon 'corecode' Schuber <corecode at fs.ei.tum.de> 2009-07-09:
--- a/libexec/dma/dma.c
+++ b/libexec/dma/dma.c
@@ -484,6 +484,7 @@ go_background(struct queue *queue)
 {
 	struct sigaction sa;
 	struct qitem *it;
+	FILE *newqf;
 	pid_t pid;
 
 	if (daemonize && daemon(0, 0) != 0) {
@@ -515,6 +516,17 @@ go_background(struct queue *queue)
 			 *
 			 * return and deliver mail
 			 */
+			/*
+			 * We have to prevent sharing of fds between children, so
+			 * we have to dup the queue fd.
+			 */
+			newqf = fdopen(fileno(it->queuef), "r");
Actually, fdopen() will not dup() the file descriptors, just
create a new FILE* handle operating on the same fd.
Uh.  I ment to add a dup() there, but I moved a lot of code, so I 
forgot...  What about the attached patch?

cheers
  simon
--
  <3 the future  +++  RENT this banner advert  +++   ASCII Ribbon   /"\
  rock the past  +++  space for low CHF NOW!1  +++     Campaign     \ /
Party Enjoy Relax   |   http://dragonflybsd.org      Against  HTML   \
Dude 2c 2 the max   !   http://golden-apple.biz       Mail + News   / \


More information about the Submit mailing list