diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-04-21 09:50:21 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-04-21 09:50:21 +0000 |
commit | af130503bdad65b41bd9e40d6cd142b3b864c18a (patch) | |
tree | 336ace72c63b3a2fdc006a4562eb828fc3c5ed6e /etc | |
parent | c2f52c26e298299d9c2e54f212aa96be99201dcb (diff) | |
download | mailfromd-af130503bdad65b41bd9e40d6cd142b3b864c18a.tar.gz mailfromd-af130503bdad65b41bd9e40d6cd142b3b864c18a.tar.bz2 |
Provide a patch for Sendmail to honor extended codes and textual messages returned by the connect handler.
git-svn-id: file:///svnroot/mailfromd/trunk@1370 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'etc')
-rw-r--r-- | etc/Makefile.am | 2 | ||||
-rw-r--r-- | etc/sendmail-8.13.7.connect.diff | 98 |
2 files changed, 99 insertions, 1 deletions
diff --git a/etc/Makefile.am b/etc/Makefile.am index 52b9f964..0c887035 100644 --- a/etc/Makefile.am +++ b/etc/Makefile.am @@ -16,7 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301 USA -EXTRA_DIST = mailfromd.rc rc.in +EXTRA_DIST = mailfromd.rc rc.in sendmail-8.13.7.connect.diff noinst_SCRIPTS = rc.mailfromd DEFAULT_PIDFILE = $(DEFAULT_STATE_DIR)/mailfromd.pid diff --git a/etc/sendmail-8.13.7.connect.diff b/etc/sendmail-8.13.7.connect.diff new file mode 100644 index 00000000..5da59ebd --- /dev/null +++ b/etc/sendmail-8.13.7.connect.diff @@ -0,0 +1,98 @@ +Index: sendmail/milter.c +diff -pur sendmail-8.13.7-orig/sendmail/milter.c sendmail-8.13.7/sendmail/milter.c +--- sendmail-8.13.7-orig/sendmail/milter.c 2005-08-06 00:49:04.000000000 +0300 ++++ sendmail-8.13.7/sendmail/milter.c 2007-04-19 20:33:12.000000000 +0300 +@@ -3417,29 +3437,30 @@ milter_connect(hostname, addr, e, state) + milter_per_connection_check(e); + + /* ++ * There used to be the following comment here: ++ * + ** SMFIR_REPLYCODE can't work with connect due to + ** the requirements of SMTP. Therefore, ignore the + ** reply code text but keep the state it would reflect. ++ * ++ * However, this is wrong. RFC2821, section 3.9 states, that: ++ * ++ * "An SMTP server MUST NOT intentionally close the connection except: ++ * [...] ++ * - After detecting the need to shut down the SMTP service and ++ * returning a 421 response code. This response code can be issued ++ * after the server receives any command or, if necessary, ++ * asynchronously from command receipt (on the assumption that the ++ * client will receive it after the next command is issued)." ++ * ++ * I see no reason why a milter cannot supply its own textual ++ * explanation in xxfi_connect. So, instead of blindly filtering ++ * out the user-supllied response, I return it to smtp(). The latter ++ * is crafted so that it will graciously abort the connection, if ++ * the response begins with 421, giving the user-supplied textual ++ * message, and will proceed with nullserver otherwise. ++ * --gray + */ +- +- if (*state == SMFIR_REPLYCODE) +- { +- if (response != NULL && +- *response == '4') +- { +- if (strncmp(response, "421 ", 4) == 0) +- *state = SMFIR_SHUTDOWN; +- else +- *state = SMFIR_TEMPFAIL; +- } +- else +- *state = SMFIR_REJECT; +- if (response != NULL) +- { +- sm_free(response); /* XXX */ +- response = NULL; +- } +- } + return response; + } + /* +Index: sendmail/srvrsmtp.c +diff -pur sendmail-8.13.7-orig/sendmail/srvrsmtp.c sendmail-8.13.7/sendmail/srvrsmtp.c +--- sendmail-8.13.7-orig/sendmail/srvrsmtp.c 2006-05-31 23:56:37.000000000 +0300 ++++ sendmail-8.13.7/sendmail/srvrsmtp.c 2007-04-19 20:34:01.000000000 +0300 +@@ -850,12 +850,38 @@ smtp(nullserver, d_flags, e) + { + char state; + char *response; +- ++ static char greetcodebuf[4]; ++ size_t len; ++ + response = milter_connect(peerhostname, RealHostAddr, + e, &state); + switch (state) + { + case SMFIR_REPLYCODE: /* REPLYCODE shouldn't happen */ ++ if (MilterLogLevel > 3) ++ sm_syslog(LOG_INFO, e->e_id, ++ "Milter: connect: host=%s, addr=%s, reject=%s", ++ peerhostname, ++ anynet_ntoa(&RealHostAddr), ++ response); ++ len = strlen(response); ++ if (len >= 3) { ++ /* RFC 2821, Section 3.9 */ ++ if (memcmp(response, "421", 3) == 0) { ++ message(response); ++ /* arrange to ignore send list */ ++ e->e_sendqueue = NULL; ++ goto doquit; ++ } else { ++ nullserver = newstr(response); ++ memcpy(greetcodebuf, response, 3); ++ greetcodebuf[3] = 0; ++ greetcode = greetcodebuf; ++ break; ++ } ++ } ++ /* FALL THROUGH */ ++ + case SMFIR_REJECT: + if (MilterLogLevel > 3) + sm_syslog(LOG_INFO, e->e_id, |