diff -ruN netqmail-1.05.orig/qmail-remote.c netqmail-1.05/qmail-remote.c --- netqmail-1.05.orig/qmail-remote.c 2009-12-19 00:34:25.000000000 +0200 +++ netqmail-1.05/qmail-remote.c 2009-12-19 00:32:23.000000000 +0200 @@ -587,15 +587,23 @@ substdio_flush(&smtpto); code = smtpcode(); if (code >= 500) { - out("h"); outhost(); out(" does not like recipient.\n"); + /* added by Endersys R&D Team */ + out("h "); outhost(); out(" does not like recipient.\n"); outsmtptext(); zero(); } else if (code >= 400) { - out("s"); outhost(); out(" does not like recipient.\n"); + /* added by Endersys R&D Team */ + out("s "); outhost(); out(" does not like recipient.\n"); outsmtptext(); zero(); } else { - out("r"); zero(); + /* + * James Raftery + * Log _real_ envelope recipient, post canonicalisation. + * and modified by Endersys R&D Team + */ + + out("r "); zero(); flagbother = 1; } } diff -ruN netqmail-1.05.orig/qmail-smtpd.c netqmail-1.05/qmail-smtpd.c --- netqmail-1.05.orig/qmail-smtpd.c 2009-12-19 00:34:25.000000000 +0200 +++ netqmail-1.05/qmail-smtpd.c 2009-12-19 00:33:38.000000000 +0200 @@ -9,6 +9,7 @@ * */ +#include #include "sig.h" #include "readwrite.h" #include "stralloc.h" @@ -664,6 +665,7 @@ } void smtp_rcpt(arg) char *arg; { + struct stat st; if (!seenmail) { err_wantmail(); return; } if (!addrparse(arg)) { err_syntax(); return; } if (flagbarfbhelo) { @@ -716,6 +718,21 @@ surblwhite = 1; } } + /* This small patch compare mail from value and smtp auth username. +* if they are not identical, the mail will not be relayed! +* This control will be ignored, if the remote IP is defined in tcp.smtp.cdb +* create/delete control/checksenderauth file to enable/disable this feature +* - Developed by Endersys Ltd R&D Team - http://www.endersys.com +*/ + if ((stat("control/checksenderauth",&st) == 0) && (remoteinfo)) { + + /* remoteinfo:username issued during the smtp auth state + * mailfrom.s: From value issued at mail from: state */ + if (str_diff(remoteinfo, mailfrom.s)) { + out("535 Mail From address and SMTP-AUTH username does not match (#5.7.1)\r\n"); + return; + } + } if (!stralloc_cats(&rcptto,"T")) die_nomem(); if (!stralloc_cats(&rcptto,addr.s)) die_nomem(); if (!stralloc_0(&rcptto)) die_nomem();