]> git.ipfire.org Git - people/ms/dma.git/commitdiff
dma: add FULLBOUNCE config option
authorSimon Schubert <simon.schubert@epfl.ch>
Thu, 9 Jul 2009 19:19:40 +0000 (21:19 +0200)
committerSimon Schubert <corecode@dragonflybsd.org>
Thu, 16 Jul 2009 14:13:05 +0000 (16:13 +0200)
FULLBOUNCE will include the full message in the bounce

Submitted-by: Peter Pentchev <roam@ringlet.net>
conf.c
dma.8
dma.c
dma.h

diff --git a/conf.c b/conf.c
index 91560637459a56d1f1d7cdffe2e08b29715f2956..161edcd08fcd467fadc4ab9797389949e9c74633 100644 (file)
--- a/conf.c
+++ b/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/dma.8 b/dma.8
index f4db47b010a0d593daf0dc412d44efad195624b9..0a1330c162b2cbb5a87b199ebab23abb22c7f6e8 100644 (file)
--- a/dma.8
+++ b/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/dma.c b/dma.c
index a9a316444dc05dfa2bc3170f14792daed512f7ed..44a49c5cc4ad808ab0cf7b5e4046a6e1200c3a5d 100644 (file)
--- a/dma.c
+++ b/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/dma.h b/dma.h
index 581bf8e8a1c3f17e70d1f45b00c35df7bf857d53..ff472028501be7e255d9bd7382feb40113a959d9 100644 (file)
--- a/dma.h
+++ b/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 */