Sam Varshavchik wrote:
> Charles Fry writes:
>> Is there away to eliminate double bounces?
>>
>> I am specifically concerned with the following scenario: Spam sent to
>> inexistant local addresses is initially accepted by courier,
>
> Courier does not accept mail to nonexistent local addresses.
I sort of understand where Charles is coming from... Shorts story made
long: Having recently converted from sendmail to courier, I discovered a
need for a .courier-default file, namely delivering user+extra to user.
In an ideal world my subscribers would advise all correspondents who
knows them by user+extra to use user-extra, but then in an ideal world I
probably would have used courier to begin with. In this real world, at
least as a transition aid, I need to continue accepting user+extra.
Having installed a .courier-default that uses a small sed script to
translate user+extra to user, I find I am now inundated with double
bounces, just as Charles described. I've prepared a patch, which is
attached to this message, that suppresses double-bounces (this one's for
you, Charles.) You also need to add NODOUBLEBOUNCE=Y to etc/courierd to
suppress the bounces.
I'm not sure that this is the best way to achieve what I want. It
works, but I'd rather not receive email for obviously bogus addresses.
Is there a better way to achieve my goal?
diff -u courier-0.45.2/courier/module.dsn/dsn.c courier-0.45.2.rebel/courier/module.dsn/dsn.c
--- courier-0.45.2/courier/module.dsn/dsn.c 2004-04-14 10:29:39.000000000 +0930
+++ courier-0.45.2.rebel/courier/module.dsn/dsn.c 2004-04-15 03:43:13.000000000 +0930
@@ -107,6 +107,41 @@
ctlfile_appendv(ctf, iov, 3);
}
+static void dsn_sent(struct moduledel *p, struct ctlfile *ctf)
+{
+ time_t t;
+
+ time(&t);
+
+ /*
+ ** After sending a delayed DSN, mark the
+ ** message so it doesn't ever get sent again!
+ */
+
+ if (strcmp(p->host, "deferred") == 0)
+ {
+ char buf[MAXLONGSIZE+2];
+
+ buf[0]=COMCTLFILE_WARNINGSENT;
+ strcat(strcpy(buf+1,
+ strtimestamp(t)), "\n");
+ ctlfile_append(ctf, buf);
+ ctlfile_close(ctf);
+ }
+ else
+ {
+ /*
+ ** For PERMANENT dsns, it is my responsibility
+ ** to remove the original message when done!!!
+ */
+
+ ctlfile_close(ctf);
+ qmsgunlink(p->inum, t);
+ unlink(qmsgsdatname(p->inum));
+ unlink(qmsgsctlname(p->inum));
+ }
+}
+
int main(int argc, char **argv)
{
struct moduledel *p;
@@ -184,7 +219,6 @@
struct ctlfile ctf;
int rc;
- int isdeferred=strcmp(p->host, "deferred") == 0;
const char *sec_level_orig;
char *envp[4];
@@ -193,6 +227,12 @@
if (ctlfile_openi(p->inum, &ctf, 0))
clog_msg_errno();
+ if (!ctf.sender[0] && getenv("NODOUBLEBOUNCE"))
+ {
+ dsn_sent(p, &ctf);
+ exit(0);
+ }
+
sec_level_orig=ctlfile_security(&ctf);
if (sec_level_orig && *sec_level_orig)
{
@@ -285,39 +325,7 @@
}
if (rc == 0)
- {
- time_t t;
-
- time(&t);
-
- /*
- ** After sending a delayed DSN, mark the
- ** message so it doesn't ever get sent again!
- */
-
- if (isdeferred)
- {
- char buf[MAXLONGSIZE+2];
-
- buf[0]=COMCTLFILE_WARNINGSENT;
- strcat(strcpy(buf+1,
- strtimestamp(t)), "\n");
- ctlfile_append(&ctf, buf);
- ctlfile_close(&ctf);
- }
- else
- {
- /*
- ** For PERMANENT dsns, it is my responsibility
- ** to remove the original message when done!!!
- */
-
- ctlfile_close(&ctf);
- qmsgunlink(p->inum, t);
- unlink(qmsgsdatname(p->inum));
- unlink(qmsgsctlname(p->inum));
- }
- }
+ dsn_sent(p, &ctf);
else
{
defer(&ctf);
diff -u courier-0.45.2/courier/courierd.dist.in courier-0.45.2.rebel/courier/courierd.dist.in
--- courier-0.45.2/courier/courierd.dist.in 2004-04-15 03:28:24.000000000 +0930
+++ courier-0.45.2.rebel/courier/courierd.dist.in 2004-04-15 03:43:38.000000000 +0930
@@ -39,6 +39,13 @@
#
# DSNNOTIFY=N
+##NAME: NODOUBLEBOUNCE:0
+#
+# If you wish to supress all double bounces (bounce messages which we
+# can't deliver), uncomment the following:
+#
+# NODOUBLEBOUNCE=Y
+
##NAME: DYNAMICDELIVERIES:0
#
# If you would like to disable the ability to generate dynamic delivery