summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2016-08-22 07:24:02 +0000
committerbapt <bapt@FreeBSD.org>2016-08-22 07:24:02 +0000
commit1d8e5c9e86e339fa6efd19bd25b88ff6624c710d (patch)
treeaf277bcb84f4941bb300db8c9c4ad6bb48f003e5
parent57e9741f29bdc1c3b4354a48fc8c40f4454c2616 (diff)
downloadFreeBSD-src-1d8e5c9e86e339fa6efd19bd25b88ff6624c710d.zip
FreeBSD-src-1d8e5c9e86e339fa6efd19bd25b88ff6624c710d.tar.gz
Import Dragonfly Mail Agent snapshort from 20160806 aka v0.11+
Most important change being: dma - Fix security hole Affecting DragonFly 4.6 and earlier, Matt Dillon fixed this in base after finding out from BSDNow Episode 152. Comments following were from his commit which explains better than I. Just taking his change and putting it here as well. * dma makes an age-old mistake of not properly checking whether a file owned by a user is a symlink or not, a bug which the original mail.local also had. * Add O_NOFOLLOW to disallow symlinks. Thanks-to: BSDNow Episode 152, made me dive dma to check when they talked about the mail.local bug. Approved by: re (kib)
-rw-r--r--contrib/dma/VERSION2
-rw-r--r--contrib/dma/dma-mbox-create.c2
-rw-r--r--contrib/dma/dma.c4
-rw-r--r--contrib/dma/dma.h2
-rw-r--r--contrib/dma/dns.c1
-rw-r--r--contrib/dma/local.c2
-rw-r--r--contrib/dma/net.c9
-rw-r--r--libexec/dma/Makefile.inc2
8 files changed, 14 insertions, 10 deletions
diff --git a/contrib/dma/VERSION b/contrib/dma/VERSION
index 9097bf9..5416288 100644
--- a/contrib/dma/VERSION
+++ b/contrib/dma/VERSION
@@ -1 +1 @@
-v0.10
+v0.11
diff --git a/contrib/dma/dma-mbox-create.c b/contrib/dma/dma-mbox-create.c
index 532a7af..45a4792 100644
--- a/contrib/dma/dma-mbox-create.c
+++ b/contrib/dma/dma-mbox-create.c
@@ -142,7 +142,7 @@ main(int argc, char **argv)
logfail(EX_CANTCREAT, "cannot build mbox path for `%s/%s'", _PATH_MAILDIR, user);
}
- f = open(fn, O_RDONLY|O_CREAT, 0600);
+ f = open(fn, O_RDONLY|O_CREAT|O_NOFOLLOW, 0600);
if (f < 0)
logfail(EX_NOINPUT, "cannt open mbox `%s'", fn);
diff --git a/contrib/dma/dma.c b/contrib/dma/dma.c
index 684ab05..4f48f48 100644
--- a/contrib/dma/dma.c
+++ b/contrib/dma/dma.c
@@ -321,7 +321,7 @@ deliver(struct qitem *it)
snprintf(errmsg, sizeof(errmsg), "unknown bounce reason");
retry:
- syslog(LOG_INFO, "trying delivery");
+ syslog(LOG_INFO, "<%s> trying delivery", it->addr);
if (it->remote)
error = deliver_remote(it);
@@ -331,7 +331,7 @@ retry:
switch (error) {
case 0:
delqueue(it);
- syslog(LOG_INFO, "delivery successful");
+ syslog(LOG_INFO, "<%s> delivery successful", it->addr);
exit(EX_OK);
case 1:
diff --git a/contrib/dma/dma.h b/contrib/dma/dma.h
index acf5e44..59341761 100644
--- a/contrib/dma/dma.h
+++ b/contrib/dma/dma.h
@@ -49,7 +49,7 @@
#define VERSION "DragonFly Mail Agent " DMA_VERSION
#define BUF_SIZE 2048
-#define ERRMSG_SIZE 200
+#define ERRMSG_SIZE 1024
#define USERNAME_SIZE 50
#define MIN_RETRY 300 /* 5 minutes */
#define MAX_RETRY (3*60*60) /* retry at least every 3 hours */
diff --git a/contrib/dma/dns.c b/contrib/dma/dns.c
index dd9ebfc..bd28c4d 100644
--- a/contrib/dma/dns.c
+++ b/contrib/dma/dns.c
@@ -34,6 +34,7 @@
*/
#include <sys/types.h>
+#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
diff --git a/contrib/dma/local.c b/contrib/dma/local.c
index e3e0152..94e2179 100644
--- a/contrib/dma/local.c
+++ b/contrib/dma/local.c
@@ -196,7 +196,7 @@ retry:
goto out;
}
- error = snprintf(line, sizeof(line), "%sFrom %s\t%s", newline, sender, ctime(&now));
+ error = snprintf(line, sizeof(line), "%sFrom %s %s", newline, sender, ctime(&now));
if (error < 0 || (size_t)error >= sizeof(line)) {
syslog(LOG_NOTICE, "local delivery deferred: can not write header: %m");
goto out;
diff --git a/contrib/dma/net.c b/contrib/dma/net.c
index 26935a8..47ee928 100644
--- a/contrib/dma/net.c
+++ b/contrib/dma/net.c
@@ -372,11 +372,13 @@ deliver_to_host(struct qitem *it, struct mx_hostentry *host)
host->host, host->addr, c, neterr); \
snprintf(errmsg, sizeof(errmsg), "%s [%s] did not like our %s:\n%s", \
host->host, host->addr, c, neterr); \
- return (-1); \
+ error = -1; \
+ goto out; \
} else if (res != exp) { \
syslog(LOG_NOTICE, "remote delivery deferred: %s [%s] failed after %s: %s", \
host->host, host->addr, c, neterr); \
- return (1); \
+ error = 1; \
+ goto out; \
}
/* Check first reply from remote host */
@@ -426,7 +428,8 @@ deliver_to_host(struct qitem *it, struct mx_hostentry *host)
syslog(LOG_ERR, "remote delivery failed:"
" SMTP login failed: %m");
snprintf(errmsg, sizeof(errmsg), "SMTP login to %s failed", host->host);
- return (-1);
+ error = -1;
+ goto out;
}
/* SMTP login is not available, so try without */
else if (error > 0) {
diff --git a/libexec/dma/Makefile.inc b/libexec/dma/Makefile.inc
index ec5eba8..b24f85d 100644
--- a/libexec/dma/Makefile.inc
+++ b/libexec/dma/Makefile.inc
@@ -7,7 +7,7 @@ DMA_SOURCES= ${.CURDIR}/../../../contrib/dma
CFLAGS+= -I${DMA_SOURCES} \
-DHAVE_REALLOCF -DHAVE_STRLCPY -DHAVE_GETPROGNAME \
-DCONF_PATH='"/etc/dma"' \
- -DLIBEXEC_PATH='"/usr/libexec"' -DDMA_VERSION='"v0.10"' \
+ -DLIBEXEC_PATH='"/usr/libexec"' -DDMA_VERSION='"v0.11+"' \
-DDMA_ROOT_USER='"mailnull"' \
-DDMA_GROUP='"mail"'
BINGRP= mail
OpenPOWER on IntegriCloud