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>
etc/dma/dma.conf
libexec/dma/conf.c
libexec/dma/dma.8
libexec/dma/dma.c
libexec/dma/dma.h

index d4587ad..5251df9 100644 (file)
@@ -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
index 9156063..161edcd 100644 (file)
@@ -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;
                }
        }
 
index f4db47b..0a1330c 100644 (file)
@@ -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
index a9a3164..44a49c5 100644 (file)
@@ -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;
index 581bf8e..ff47202 100644 (file)
@@ -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 */