From 6d8f6846628c043d27bae7deab1246029df1a6f3 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Tue, 7 Jul 2009 13:29:02 +0000 Subject: [PATCH] - Fix a race condition in the multiple recipient delivery code which can cause message corruption PR: 136304 Submitted by: Daniel Roethlisberger (maintainer) --- mail/dma/Makefile | 2 +- mail/dma/files/patch-libexec_dma_dma.c | 38 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 mail/dma/files/patch-libexec_dma_dma.c diff --git a/mail/dma/Makefile b/mail/dma/Makefile index c6061f04fc48..86fdfccd7a3a 100644 --- a/mail/dma/Makefile +++ b/mail/dma/Makefile @@ -7,7 +7,7 @@ PORTNAME= dma PORTVERSION= 20090208 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= mail ipv6 MASTER_SITES= http://mirror.roe.ch/dist/dma/ diff --git a/mail/dma/files/patch-libexec_dma_dma.c b/mail/dma/files/patch-libexec_dma_dma.c new file mode 100644 index 000000000000..8361f7613744 --- /dev/null +++ b/mail/dma/files/patch-libexec_dma_dma.c @@ -0,0 +1,38 @@ +--- libexec/dma/dma.c.orig 2009-02-09 01:36:50.000000000 +0100 ++++ libexec/dma/dma.c 2009-07-04 00:12:53.000000000 +0200 +@@ -612,6 +612,7 @@ + const char *errmsg = "unknown bounce reason"; + struct timeval now; + struct stat st; ++ struct flock fl; + + syslog(LOG_INFO, "%s: mail from=<%s> to=<%s>", + it->queueid, it->sender, it->addr); +@@ -620,11 +621,27 @@ + syslog(LOG_INFO, "%s: trying delivery", + it->queueid); + ++ bzero(&fl, sizeof(fl)); ++ fl.l_type = F_WRLCK; ++ fl.l_whence = SEEK_SET; ++ if (fcntl(fileno(it->queuef), F_SETLKW, &fl) == -1) { ++ syslog(LOG_ERR, "%s: failed to lock queue file: %m", ++ it->queueid); ++ } ++ + if (it->remote) + error = deliver_remote(it, &errmsg); + else + error = deliver_local(it, &errmsg); + ++ bzero(&fl, sizeof(fl)); ++ fl.l_type = F_UNLCK; ++ fl.l_whence = SEEK_SET; ++ if (fcntl(fileno(it->queuef), F_SETLKW, &fl) == -1) { ++ syslog(LOG_ERR, "%s: failed to unlock queue file: %m", ++ it->queueid); ++ } ++ + switch (error) { + case 0: + unlink(it->queuefn);