From: Simon Schubert <2@0x2c.org> Date: Thu, 28 Oct 2010 15:27:10 +0000 (+0200) Subject: drop 11-double-bounce.patch: incorrect fix X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=df0ff9654b29f87adb57702f8f9e4e35618f107b;p=people%2Fms%2Fdma.git drop 11-double-bounce.patch: incorrect fix --- diff --git a/debian/README.Debian b/debian/README.Debian index 7031cdb..1e478c1 100644 --- a/debian/README.Debian +++ b/debian/README.Debian @@ -40,19 +40,4 @@ that handles the delivery should die for some reason, or the system should be restarted, the cron job will ensure that a new delivery process is spawned in due time and the message is not just left in the queue. -3. Double-bounce handling - -By default, the dma mail transfer agent does not attempt to handle double -bounces - it aborts the delivery with a critical syslog message. -This, combined with the Debian package's default of "flush the queue -every five minutes", may pose something of a strain on the mail server :) -Thus, the Debian version of dma adds a new feature - you may specify -an external program to handle double bounces with the DBOUNCEPROG -directive in the /etc/dma/dma.conf file. Also included is a sample -program, dbounce-simple-safecat, which uses the safecat utility to -copy the bounce message into a Maildir-structured storage, -/var/spool/mail/dma-bounces by default. For the present, the copied file -still has the dma internal format, which is plain text, but is not really -a mailbox :) - -- Peter Pentchev Tue, 27 Jul 2010 13:26:48 +0300 diff --git a/debian/config b/debian/config index e352fe4..2642df1 100755 --- a/debian/config +++ b/debian/config @@ -15,11 +15,6 @@ else fi fi -db_get dma/dbounceprog || true -if [ -z "$RET" ]; then - db_set dma/dbounceprog 'dbounce-simple-safecat' || true -fi - state=1 while [ "$state" -ge 1 -a "$state" -le 3 ]; do case "$state" in @@ -27,8 +22,6 @@ while [ "$state" -ge 1 -a "$state" -le 3 ]; do ;; 2) db_input high dma/relayhost || true ;; - 3) db_input medium dma/dbounceprog || true - ;; esac if db_go; then state=$(($state + 1)) diff --git a/debian/control b/debian/control index bdfd500..6eeea08 100644 --- a/debian/control +++ b/debian/control @@ -15,7 +15,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends} Provides: mail-transport-agent Conflicts: mail-transport-agent Replaces: mail-transport-agent -Recommends: dma-migrate, safecat +Recommends: dma-migrate Description: lightweight mail transport agent The DragonFly Mail Agent is a small Mail Transport Agent (MTA), designed for home and office use. It accepts mails from local Mail diff --git a/debian/dbounce-simple-safecat b/debian/dbounce-simple-safecat deleted file mode 100644 index 6c072c1..0000000 --- a/debian/dbounce-simple-safecat +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2009, 2010 Peter Pentchev -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. - -set -e - -usage() -{ - cat <&2 - exit 1 - esac -done - -if [ ! -r "$FILENAME" ]; then - echo "Nonexistent or unreadable bounce file $FILENAME" 1>&2 - exit 1 -fi - -bname=`basename "$FILENAME"` -dname=`dirname "$FILENAME"` -if expr "$bname" : 'Q' > /dev/null; then - qname="M${bname#Q}" - qfile="$dname/$qname" - if [ ! -r "$qfile" ]; then - echo "Nonexistent or unreadable bounce queue file $qfile" 1>&2 - exit 1 - fi -else - qfile='' -fi - -F=`cat "$FILENAME" ${qfile:+"$qfile"} | safecat "$BOUNCEDIR/tmp" "$BOUNCEDIR/new"` -OUTFILE="$BOUNCEDIR/new/$F" -if [ ! -f "$OUTFILE" ]; then - echo "safecat indicated success, but '$OUTFILE' does not exist" 1>&2 - exit 1 -fi -echo "Successfully written the message to $OUTFILE" diff --git a/debian/dbounce-simple-safecat.1 b/debian/dbounce-simple-safecat.1 deleted file mode 100644 index 6f8e5f7..0000000 --- a/debian/dbounce-simple-safecat.1 +++ /dev/null @@ -1,102 +0,0 @@ -.\" Copyright (c) 2009 Peter Pentchev -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd March 12, 2009 -.Dt DBOUNCE-SIMPLE-SAFECAT 1 -.Os -.Sh NAME -.Nm dbounce-simple-safecat -.Nd store double-bounced email messages into a Maildir -.Sh SYNOPSIS -.Nm -.Op Fl a Ar addr -.Op Fl d Ar dir -.Op Fl i Ar queueid -.Op Fl t Ar type -.Fl f Ar msg -.Sh DESCRIPTION -The -.Nm -utility reads an email message file from the local MTA's queue directory and -invokes the -.Xr safecat 1 -utility to store it into a Maildir-format directory for the administrator's -perusal. -It is intended to be used as a double-bounce handler by mail transfer agents -such as -.Xr dma 8 -(when dma's -.Va DBOUNCEPROG -configuration setting is specified). -.Pp -The -.Nm -utility accepts the following command-line options; only -.Fl f -is mandatory: -.Pp -.Bl -tag -width "-i queueid" -.It Fl a Ar addr -The recipient of the bounce message. -.It Fl d Ar dir -The bounce directory, -.Pa /var/spool/mail/dma-bounces -by default. -.It Fl f Ar msg -The full path to the bounced message to process. -.It Fl i Ar queueid -The ID of the bounce message in the local MTA's queue. -.It Fl t Ar type -The MTA type, currently unused. -.El -.Sh EXAMPLES -Copy a message from the local -.Xr dma 8 -queue into the default double-bounce Maildir: -.Pp -.Dl dbounce-simple-safecat -a roam@ringlet.net -i 40c1b8.882e250 -t dma -f /var/spool/dma/40c1b8.882e250 -.Pp -A minimal execution with only the mandatory parameters: -.Pp -.Dl dbounce-simple-safecat -f /var/spool/dma/40c1b8.882e250 -.Pp -Explicitly specify the destination directory: -.Pp -.Dl dbounce-simple-safecat -d /root/bounces -f /var/spool/dma/40c1b8.882e250 -.Sh EXIT STATUS -.Ex -std -.Sh SEE ALSO -.Xr safecat 1 , -.Xr dma 8 -.Sh HISTORY -The -.Nm -utility was written by Peter Pentchev in 2009. -.Sh AUTHORS -.An Peter Pentchev -.Aq roam@ringlet.net -.Sh BUGS -No, thank you :) -But if you should actually find any, please report them -to the author. diff --git a/debian/dma.install b/debian/dma.install deleted file mode 100644 index a1199a7..0000000 --- a/debian/dma.install +++ /dev/null @@ -1,2 +0,0 @@ -debian/dbounce-simple-safecat usr/bin -debian/dbounce-simple-safecat.1 usr/share/man/man1 diff --git a/debian/patches/11-double-bounce.patch b/debian/patches/11-double-bounce.patch deleted file mode 100644 index c95f979..0000000 --- a/debian/patches/11-double-bounce.patch +++ /dev/null @@ -1,218 +0,0 @@ -Description: Implement double-bounce handling via an external program. - Implement double-bounce handling via an external program, controlled - by the DBOUNCEPROG config parameter. - Enable this handling by default, using the dbounce-simple-safecat - helper installed by the package. - Unfortunately, Simon Schubert did not - accept this part of my changes to dma in issue 1321. -Origin: other: http://svn.ringlet.net/svn/ringlet/mail/dma/ -Bug: http://bugs.dragonflybsd.org/issue1321 -Author: Peter Pentchev -Last-Update: 2010-07-27 - ---- a/conf.c -+++ b/conf.c -@@ -256,6 +256,8 @@ - config.authpath= data; - else if (strcmp(word, "CERTFILE") == 0 && data != NULL) - config.certfile = data; -+ else if (strcmp(word, "DBOUNCEPROG") == 0 && data != NULL) -+ config.dbounceprog = data; - else if (strcmp(word, "MAILNAME") == 0 && data != NULL) - config.mailname = data; - else if (strcmp(word, "MAILNAMEFILE") == 0 && data != NULL) ---- a/dma.8 -+++ b/dma.8 -@@ -240,6 +240,26 @@ - .Fl q - option. - This option is handy if you are behind a dialup line. -+.It Ic DBOUNCEPROG Xo -+(string, default=dbounce-simple-safecat) -+.Xc -+Comment if you want the default behavior of -+.Nm -+upon double bounces - just abort the delivery. -+Otherwise, specify the name or full path to a program that will process -+the bounced bounce message. -+.Pp -+The program will be invoked with several command-line options: -+.Pp -+.Nm dbounce -+.Fl t -+.Ar dma -+.Fl a -+.Ar bounced@email.address -+.Fl i -+.Ar queueid -+.Fl f -+.Ar messagefile - .It Ic FULLBOUNCE Xo - (boolean, default=commented) - .Xc -@@ -270,6 +290,7 @@ - (e.g.\& user@localhost) so you have to rewrite your outgoing email - address to a valid address. - .Sh SEE ALSO -+.Xr dbounce-simple-safecat 1 , - .Xr mailaddr 7 , - .Xr mailwrapper 8 , - .Xr sendmail 8 ---- a/dma.h -+++ b/dma.h -@@ -111,6 +111,7 @@ - const char *authpath; - const char *certfile; - int features; -+ const char *dbounceprog; - const char *mailname; - const char *mailnamefile; - ---- a/dma.conf -+++ b/dma.conf -@@ -43,6 +43,12 @@ - # behind a dialup line. You have to submit your mails manually with dma -q - #DEFER - -+# The double-bounce handler program. Leave this blank if you like dma's -+# default behavior of simply aborting the delivery, or specify the name or -+# full path to a program that will process the double-bounce message. -+# NOTE: on Debian systems this is handled via debconf! -+DBOUNCEPROG dbounce-simple-safecat -+ - # Uncomment if you want the bounce message to include the complete original - # message, not just the headers. - #FULLBOUNCE ---- a/mail.c -+++ b/mail.c -@@ -32,7 +32,12 @@ - * SUCH DAMAGE. - */ - -+#include -+#include -+ -+#include - #include -+#include - #include - #include - -@@ -43,13 +48,114 @@ - { - struct queue bounceq; - char line[1000]; -- size_t pos; - int error; -+ int pipefd[2]; -+ pid_t child; -+ char *buf; -+ size_t i, pos, bufsize; -+ ssize_t n; -+ int status; -+ struct sigaction sa; - - /* Don't bounce bounced mails */ - if (it->sender[0] == 0) { -- syslog(LOG_INFO, "can not bounce a bounce message, discarding"); -- exit(1); -+ syslog(LOG_INFO, "%s: bounce delivery failed, double-bouncing", -+ it->queueid); -+ if (config.dbounceprog == NULL) { -+ syslog(LOG_CRIT, "%s: delivery panic: can't bounce a bounce and no double-bounce program defined in the config file", -+ it->queueid); -+ exit(1); -+ } -+ if (pipe(pipefd) == -1) { -+ syslog(LOG_ERR, "%s: double-bounce: cannot pipe for the double-bounce program: %m", -+ it->queueid); -+ exit(1); -+ } -+ bzero(&sa, sizeof(sa)); -+ sa.sa_flags = SA_NOCLDSTOP; -+ sa.sa_handler = SIG_DFL; -+ if (sigaction(SIGCHLD, &sa, NULL) == -1) { -+ syslog(LOG_ERR, "%s: double-bounce: cannot set signal action: %m", -+ it->queueid); -+ exit(1); -+ } -+ child = fork(); -+ if (child == -1) { -+ syslog(LOG_ERR, "%s: double-bounce: cannot fork for the double-bounce program: %m", -+ it->queueid); -+ exit(1); -+ } else if (child == 0) { -+ close(pipefd[0]); -+ dup2(pipefd[1], STDIN_FILENO); -+ dup2(pipefd[1], STDOUT_FILENO); -+ dup2(pipefd[1], STDERR_FILENO); -+ execlp(config.dbounceprog, config.dbounceprog, -+ "-t", "dma", "-a", it->addr, "-i", it->queueid, -+ "-f", it->queuefn, NULL); -+ err(1, "Could not execute %s", config.dbounceprog); -+ /* NOTREACHED */ -+ } -+ -+ close(pipefd[1]); -+ buf = NULL; -+ pos = bufsize = 0; -+ while (1) { -+ if (pos == bufsize) { -+ char *nbuf; -+ size_t nsize; -+ -+ nsize = bufsize + BUF_SIZE; -+ nbuf = realloc(buf, nsize); -+ if (nbuf == NULL) { -+ free(buf); -+ syslog(LOG_ERR, "%s: double-bounce failed: could not allocate %lu bytes of memory: %m", it->queueid, (unsigned long)nsize); -+ exit(1); -+ } -+ buf = nbuf; -+ bufsize = nsize; -+ } -+ n = read(pipefd[0], buf + pos, bufsize - pos); -+ if (n < 0) { -+ free(buf); -+ syslog(LOG_ERR, "%s: double-bounce failed: could not read the output of the double-bounce program: %m", it->queueid); -+ exit(1); -+ } else if (n == 0) { -+ break; -+ } else { -+ pos += n; -+ } -+ } -+ for (i = 0; i < pos; i++) -+ if (buf[i] < 32) -+ buf[i] = '_'; -+ /* -+ * The order of the reallocation and reading above -+ * guarantees that we have at least one more byte available -+ * in buf[] after pos. -+ */ -+ buf[pos] = '\0'; -+ -+ if (waitpid(child, &status, 0) == -1) { -+ syslog(LOG_ERR, "%s: double-bounce deferred: could not fetch the result from child process %ld: %m; child process output: %s", -+ it->queueid, (long)child, buf); -+ exit(1); -+ } else if (WIFSIGNALED(status)) { -+ syslog(LOG_ERR, "%s: double-bounce deferred: child process %ld died from signal %d; child process output: %s", -+ it->queueid, (long)child, WTERMSIG(status), buf); -+ exit(1); -+ } else if (!WIFEXITED(status)) { -+ syslog(LOG_ERR, "%s: double-bounce deferred: child process %ld got an unexpected waitpid code of %d; child process output: %s", -+ it->queueid, (long)child, status, buf); -+ exit(1); -+ } else if (WEXITSTATUS(status) != 0) { -+ syslog(LOG_ERR, "%s: double-bounce deferred: child process %ld exited with code %d; child process output: %s", -+ it->queueid, (long)child, (int)WEXITSTATUS(status), buf); -+ exit(1); -+ } -+ syslog(LOG_ERR, "%s: double-bounce succeeded, message passed to handler `%s': %s", -+ it->queueid, config.dbounceprog, buf); -+ delqueue(it); -+ exit(0); - } - - bzero(&bounceq, sizeof(bounceq)); diff --git a/debian/postinst b/debian/postinst index 6a651ca..e477682 100644 --- a/debian/postinst +++ b/debian/postinst @@ -20,13 +20,6 @@ case "$1" in sed -i -re 's@^[[:space:]]*(#+[[:space:]]*)?SMARTHOST([[:space:]]+.*)?$@#SMARTHOST@' /etc/dma/dma.conf fi - db_get dma/dbounceprog - if [ -n "$RET" ]; then - sed -i -re 's/^[[:space:]]*(#+[[:space:]]*)?DBOUNCEPROG([[:space:]]+.*)?$/DBOUNCEPROG '"$RET/" /etc/dma/dma.conf - else - sed -i -re 's/^[[:space:]]*(#+[[:space:]]*)?DBOUNCEPROG([[:space:]]+.*)?$/#DBOUNCEPROG/' /etc/dma/dma.conf - fi - if dpkg --compare-versions "$2" lt '0.0.2009.07.17-3'; then chown root:mail /etc/dma/* chmod 640 /etc/dma/* diff --git a/debian/templates b/debian/templates index 24ee5ff..36a84eb 100644 --- a/debian/templates +++ b/debian/templates @@ -16,11 +16,3 @@ _Description: Smarthost: Please enter the IP address or the host name of a mail server that this system should use as outgoing smarthost. If no smarthost is specified, dma will try to deliver all messages by itself. - -Template: dma/dbounceprog -Type: string -_Description: A program to handle double-bounces: - Please enter the name of a program that dma will invoke when a bounced - message bounces in its own right. Leave this blank to keep dma's - default behavior of simply aborting the delivery, or specify the name - or full path to a program that will process the double-bounce message.