From 5ca28cf665ff986e6f1cc3a6f0ade276364c0c6c Mon Sep 17 00:00:00 2001 From: Simon Schubert Date: Thu, 9 Jul 2009 21:19:40 +0200 Subject: [PATCH] dma: add FULLBOUNCE config option FULLBOUNCE will include the full message in the bounce Submitted-by: Peter Pentchev --- etc/dma/dma.conf | 4 ++++ libexec/dma/conf.c | 2 ++ libexec/dma/dma.8 | 5 +++++ libexec/dma/dma.c | 28 +++++++++++++++++++--------- libexec/dma/dma.h | 1 + 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/etc/dma/dma.conf b/etc/dma/dma.conf index d4587adea0..5251df98eb 100644 --- a/etc/dma/dma.conf +++ b/etc/dma/dma.conf @@ -40,3 +40,7 @@ AUTHPATH /etc/dma/auth.conf # Uncomment if you want to defer your mails. This is useful if you are # behind a dialup line. You have to submit your mails manually with dma -q #DEFER + +# Uncomment if you want the bounce message to include the complete original +# message, not just the headers. +#FULLBOUNCE diff --git a/libexec/dma/conf.c b/libexec/dma/conf.c index 9156063745..161edcd08f 100644 --- a/libexec/dma/conf.c +++ b/libexec/dma/conf.c @@ -246,6 +246,8 @@ parse_conf(const char *config_path, struct config *config) config->features |= DEFER; else if (strcmp(word, "INSECURE") == 0) config->features |= INSECURE; + else if (strcmp(word, "FULLBOUNCE") == 0) + config->features |= FULLBOUNCE; } } diff --git a/libexec/dma/dma.8 b/libexec/dma/dma.8 index f4db47b010..0a1330c162 100644 --- a/libexec/dma/dma.8 +++ b/libexec/dma/dma.8 @@ -217,6 +217,11 @@ You have to flush your mail queue manually with the .Fl q option. This option is handy if you are behind a dialup line. +.It Ic FULLBOUNCE Xo +(boolean, default=commented) +.Xc +Uncomment if you want the bounce message to include the complete original +message, not just the headers. .El .Ss virtusertable The diff --git a/libexec/dma/dma.c b/libexec/dma/dma.c index a9a316444d..44a49c5cc4 100644 --- a/libexec/dma/dma.c +++ b/libexec/dma/dma.c @@ -463,6 +463,7 @@ bounce(struct qitem *it, char *reason) struct queue bounceq; struct qitem *bit; char line[1000]; + size_t pos; int error; /* Don't bounce bounced mails */ @@ -502,7 +503,7 @@ There was an error delivering your mail to <%s>.\n\ \n\ %s\n\ \n\ -Message headers follow.\n\ +%s\n\ \n\ ", bounceq.id, @@ -514,7 +515,9 @@ Message headers follow.\n\ rfc822date(), VERSION, hostname(), it->addr, - reason); + reason, + config->features & FULLBOUNCE? "Original message follows.": + "Message headers follow."); free(reason); if (error < 0) goto fail; @@ -523,13 +526,20 @@ Message headers follow.\n\ if (fseek(it->queuef, it->hdrlen, SEEK_SET) != 0) goto fail; - while (!feof(it->queuef)) { - if (fgets(line, sizeof(line), it->queuef) == NULL) - break; - if (line[0] == '\n') - break; - if ((size_t)write(bounceq.mailfd, line, strlen(line)) != strlen(line)) - goto fail; + if (config->features & FULLBOUNCE) { + while ((pos = fread(line, 1, sizeof(line), it->queuef)) > 0) { + if ((size_t)write(bounceq.mailfd, line, pos) != pos) + goto fail; + } + } else { + while (!feof(it->queuef)) { + if (fgets(line, sizeof(line), it->queuef) == NULL) + break; + if (line[0] == '\n') + break; + if ((size_t)write(bounceq.mailfd, line, strlen(line)) != strlen(line)) + goto fail; + } } if (fsync(bounceq.mailfd) != 0) goto fail; diff --git a/libexec/dma/dma.h b/libexec/dma/dma.h index 581bf8e8a1..ff47202850 100644 --- a/libexec/dma/dma.h +++ b/libexec/dma/dma.h @@ -72,6 +72,7 @@ #define NOSSL 0x008 /* Do not use SSL */ #define DEFER 0x010 /* Defer mails */ #define INSECURE 0x020 /* Allow plain login w/o encryption */ +#define FULLBOUNCE 0x040 /* Bounce the full message */ #define CONF_PATH "/etc/dma/dma.conf" /* Default path to dma.conf */ -- 2.41.0