1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-23 09:10:43 +00:00

- Fix a race condition in the multiple recipient delivery code which can cause message corruption

PR:		136304
Submitted by:	Daniel Roethlisberger <daniel@roe.ch> (maintainer)
This commit is contained in:
Dmitry Marakasov 2009-07-07 13:29:02 +00:00
parent c1eba0ce96
commit 6d8f684662
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=237346
2 changed files with 39 additions and 1 deletions

View File

@ -7,7 +7,7 @@
PORTNAME= dma
PORTVERSION= 20090208
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= mail ipv6
MASTER_SITES= http://mirror.roe.ch/dist/dma/

View File

@ -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);