From: Simon Schubert Date: Thu, 9 Jul 2009 12:37:16 +0000 (+0200) Subject: dma: lock temp files on creation X-Git-Tag: v2.4.0~414^2~25 X-Git-Url: http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/855166cab18c755f280c77646aea8d1295931627 dma: lock temp files on creation Lock the temporary files after creating them to protect from a "dma -q" run at just the wrong time causing a double delivery attempt for the same message. Submitted-by: Peter Pentchev --- diff --git a/libexec/dma/dma.c b/libexec/dma/dma.c index 3ca9826..6599635 100644 --- a/libexec/dma/dma.c +++ b/libexec/dma/dma.c @@ -223,6 +223,8 @@ gentempf(struct queue *queue) fd = mkstemp(fn); if (fd < 0) return (-1); + if (flock(fd, LOCK_EX) == -1) + return (-1); queue->mailfd = fd; queue->tmpf = strdup(fn); if (queue->tmpf == NULL) {