qmail.st-reject-code.patch (20050323) http://toribio.apollinare.org/qmail (c) 2003-2005 Salvatore Toribio for this mini patch (toribio - pusc.it) This mini patch for qmail (http://cr.yp.to/software/qmail-1.03.tar.gz) comes with NO WARRANTY, you can redistribute and modify it freely. You can use this patch with qmail-scanner st patch (http://toribio.apollinare.org/qmail-scanner/), it adds the reject code "553 We have reasons to believe this mail is spam (#5.7.1)" for mails rejected by qmail-scanner st patch as spam, and logs it. It also logs mail rejectedby BLFs (http://cr.yp.to/docs/smtplf.html) that are logged by qmail-scanner as 'no sender and no recipient'. TO APPLY THE PATCH You can apply it to the original source of qmail, to qmail already patched with qmailqueue-patch from Bruce Guenter or to netqmail. This is a 'p0' patch tar xzf qmail-1.03.tar.gz -C /var/tmp cp qmail.st-reject-code.patch /var/tmp/ cd /var/tmp patch -p0 < qmail.st-reject-code.patch Salvatore Toribio 20050323 diff -Naur qmail-1.03.orig/qmail-smtpd.c qmail-1.03/qmail-smtpd.c --- qmail-1.03.orig/qmail-smtpd.c Mon Jun 15 12:53:16 1998 +++ qmail-1.03/qmail-smtpd.c Wed Mar 23 17:30:06 2005 @@ -42,12 +42,30 @@ void flush() { substdio_flush(&ssout); } void out(s) char *s; { substdio_puts(&ssout,s); } +/* st: log some information */ +char strnum[FMT_ULONG]; + +static char llogbuf[1]; +static struct substdio llog = SUBSTDIO_FDBUF(write,2,llogbuf,1); + +void log2(s1,s2) char *s1; char *s2; { + substdio_putsflush(&llog,s1); + substdio_putsflush(&llog,s2); } + +void log4(s1,s2,s3,s4) char *s1; char *s2; char *s3; char *s4; { + substdio_putsflush(&llog,s1); + substdio_putsflush(&llog,s2); + substdio_putsflush(&llog,s3); + substdio_putsflush(&llog,s4); } + void die_read() { _exit(1); } void die_alarm() { out("451 timeout (#4.4.2)\r\n"); flush(); _exit(1); } void die_nomem() { out("421 out of memory (#4.3.0)\r\n"); flush(); _exit(1); } void die_control() { out("421 unable to read controls (#4.3.0)\r\n"); flush(); _exit(1); } void die_ipme() { out("421 unable to figure out my IP addresses (#4.3.0)\r\n"); flush(); _exit(1); } -void straynewline() { out("451 See http://pobox.com/~djb/docs/smtplf.html.\r\n"); flush(); _exit(1); } +void straynewline() { + log2(strnum," smtpd: Bare LFs in SMTP, rejecting (451)\n"); + out("451 See http://cr.yp.to/docs/smtplf.html (#4.5.4)\r\n"); flush(); _exit(1); } void err_bmf() { out("553 sorry, your envelope sender is in my badmailfrom list (#5.7.1)\r\n"); } void err_nogateway() { out("553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)\r\n"); } @@ -389,6 +407,11 @@ if (!*qqx) { acceptmessage(qp); return; } if (hops) { out("554 too many hops, this message is looping (#5.4.6)\r\n"); return; } if (databytes) if (!bytestooverflow) { out("552 sorry, that message size exceeds my databytes limit (#5.3.4)\r\n"); return; } + if (*qqx == 'G') { + out("553 "); + log4(strnum," smtpd: qq error - ",qqx + 1," (553)\n"); + out(qqx + 1); out("\r\n"); flush(); _exit(1); + } if (*qqx == 'D') out("554 "); else out("451 "); out(qqx + 1); out("\r\n"); @@ -410,6 +433,8 @@ void main() { + /* st: getpid for the log */ + strnum[fmt_ulong(strnum,getpid())] = 0; sig_pipeignore(); if (chdir(auto_qmail) == -1) die_control(); setup(); diff -Naur qmail-1.03.orig/qmail.c qmail-1.03/qmail.c --- qmail-1.03.orig/qmail.c Wed Mar 23 17:06:01 2005 +++ qmail-1.03/qmail.c Wed Mar 23 17:10:03 2005 @@ -107,7 +107,7 @@ switch(exitcode) { case 115: /* compatibility */ case 11: return "Denvelope address too long for qq (#5.1.3)"; - case 31: return "Dmail server permanently rejected message (#5.3.0)"; + case 31: return "GWe have reasons to believe this mail is spam (#5.7.1)"; case 51: return "Zqq out of memory (#4.3.0)"; case 52: return "Zqq timeout (#4.3.0)"; case 53: return "Zqq write error or disk full (#4.3.0)";