Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 04 Jul 2009 00:39:39 +0200
From:      Daniel Roethlisberger <daniel@roe.ch>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        daniel@roe.ch
Subject:   ports/136304: [maintainer] mail/dma - fix message corruption
Message-ID:  <E1MMrPv-000AlZ-L1@calvin.ustdmz.roe.ch>
Resent-Message-ID: <200907032240.n63Me5c1074717@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         136304
>Category:       ports
>Synopsis:       [maintainer] mail/dma - fix message corruption
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 03 22:40:05 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Daniel Roethlisberger
>Release:        FreeBSD 7.2-RELEASE-p2 i386
>Organization:
>Environment:
System: FreeBSD marvin.ustcor.roe.ch 7.2-RELEASE-p2 FreeBSD 7.2-RELEASE-p2 #0: Wed Jun 24 00:57:44 UTC 2009 root@i386-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC i386
>Description:
Fix a race condition in the multiple recipient delivery code which
can cause message corruption, sometimes visibly, sometimes silently.
>How-To-Repeat:
$ dd if=/dev/urandom bs=1k count=100 | openssl base64 > /tmp/data
$ mail -s test your@email.com your_second@email.com < /tmp/data

Notice that dma(8) will bounce the message for some or all of the
recipients and/or that the received messages vastly differ in size
and content from /tmp/data.
>Fix:
--- dma-lock-delivery.diff begins here ---
diff -ruN dma.orig/Makefile dma/Makefile
--- dma.orig/Makefile	2009-02-13 21:19:04.000000000 +0100
+++ dma/Makefile	2009-07-03 21:58:59.000000000 +0200
@@ -7,7 +7,7 @@
 
 PORTNAME=	dma
 PORTVERSION=	20090208
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	mail ipv6
 MASTER_SITES=	http://mirror.roe.ch/dist/dma/
 
diff -ruN dma.orig/files/patch-libexec_dma_dma.c dma/files/patch-libexec_dma_dma.c
--- dma.orig/files/patch-libexec_dma_dma.c	1970-01-01 01:00:00.000000000 +0100
+++ dma/files/patch-libexec_dma_dma.c	2009-07-04 00:13:15.000000000 +0200
@@ -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);
--- dma-lock-delivery.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1MMrPv-000AlZ-L1>