summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2004-08-27 16:11:15 +0000
committerStef Walter <stef@memberwebs.com>2004-08-27 16:11:15 +0000
commit100f692245931aee67d07905104188ef9465b334 (patch)
treebb11b37d8ac1685615c8e8b5ec014858a045ddff
parent9cdab7f42125f4d59c8cb86fcf4d866dc1e07ee2 (diff)
- Fix loopback problems with Postfix 1.x
-rw-r--r--AUTHORS4
-rw-r--r--ChangeLog5
-rw-r--r--common/smtppass.c36
-rw-r--r--configure.in4
-rw-r--r--src/clamsmtpd.c36
5 files changed, 71 insertions, 14 deletions
diff --git a/AUTHORS b/AUTHORS
index 82374c0..a80252d 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,9 +1,11 @@
AUTHOR:
Nate Nielsen <nielsen@memberwebs.com>
+CONTRIBUTORS:
+Andreas Steinmetz <ast@domdv.de>
+
PATCHES:
Berk D. Demir <demir@meteksan.net.tr>
João Carlos Mendes Luís <jcmendes@int.gov.br>
Jasper Slits <jasper@insiders.nl>
-Andreas Steinmetz <ast@domdv.de>
Yamamoto Takao <takao@oakat.org>
diff --git a/ChangeLog b/ChangeLog
index 7c49094..ee9ecc3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
0.7
- Added support for ESMTP [Andreas Steinmetz]
- - Fixed other bugs
+ - Fixed crash when too many connections established
+ - Announce ourselves as 'clamsmtp' in EHLO/HELO responses which fixes 'loopback'
+ problems with certain versions of Postfix 1.x
+ - Fixed other minor bugs
0.6
- Proper adding of customized header [Berk D. Demir]
diff --git a/common/smtppass.c b/common/smtppass.c
index 984744d..a0e59cf 100644
--- a/common/smtppass.c
+++ b/common/smtppass.c
@@ -91,6 +91,7 @@ clamsmtp_thread_t;
#define SMTP_DATA "DATA" CRLF
#define SMTP_BANNER "220 clamsmtp" CRLF
+#define SMTP_HELO_RSP "250 clamsmtp" CRLF
#define SMTP_DELIMS "\r\n\t :-"
#define ESMTP_PIPELINE "PIPELINING"
@@ -674,11 +675,13 @@ static int smtp_passthru(clamsmtp_context_t* ctx)
{
char logline[LINE_LENGTH];
int r, ret = 0;
- int first_rsp = 1;
- int filter_ehlo = 0;
fd_set mask;
int neterror = 0;
+ int first_rsp = 1; /* The first 220 response from server to be filtered */
+ int filter_ehlo = 0; /* Filtering parts of an EHLO extensions response */
+ int filter_host = 0; /* Next response is 250 hostname, which we change */
+
ASSERT(ctx->clam != -1 && ctx->server != -1);
logline[0] = 0;
@@ -720,9 +723,9 @@ static int smtp_passthru(clamsmtp_context_t* ctx)
continue;
}
- /* Only valid after an EHLO command */
- if(filter_ehlo)
- filter_ehlo = 0;
+ /* Only valid after EHLO or HELO commands */
+ filter_ehlo = 0;
+ filter_host = 0;
/* Handle the DATA section via our AV checker */
if(is_first_word(ctx->line, DATA_CMD, KL(DATA_CMD)))
@@ -757,6 +760,7 @@ static int smtp_passthru(clamsmtp_context_t* ctx)
{
messagex(ctx, LOG_DEBUG, "filtering EHLO response");
filter_ehlo = 1;
+ filter_host = 1;
/* A new message */
logline[0] = 0;
@@ -768,6 +772,8 @@ static int smtp_passthru(clamsmtp_context_t* ctx)
*/
else if(is_first_word(ctx->line, HELO_CMD, KL(HELO_CMD)))
{
+ filter_host = 1;
+
/* A new message line */
logline[0] = 0;
}
@@ -849,6 +855,26 @@ static int smtp_passthru(clamsmtp_context_t* ctx)
}
/*
+ * Certain mail servers (Postfix 1.x in particular) do a loop check
+ * on the 250 response after a EHLO or HELO. This is where we
+ * filter that to prevent loopback errors.
+ */
+ if(filter_host)
+ {
+ filter_host = 0;
+
+ if(check_first_word(ctx->line, OK_RSP, KL(OK_RSP), SMTP_DELIMS) > 0)
+ {
+ messagex(ctx, LOG_DEBUG, "intercepting host response");
+
+ if(write_data(ctx, &(ctx->client), SMTP_HELO_RSP) == -1)
+ RETURN(-1);
+
+ continue;
+ }
+ }
+
+ /*
* Filter out any EHLO responses that we can't or don't want
* to support. For example pipelining or TLS.
*/
diff --git a/configure.in b/configure.in
index f87c179..8087d2b 100644
--- a/configure.in
+++ b/configure.in
@@ -36,8 +36,8 @@ dnl Nate Nielsen <nielsen@memberwebs.com>
dnl
dnl Process this file with autoconf to produce a configure script.
-AC_INIT(clamsmtp, 0.6.90, nielsen@memberwebs.com)
-AM_INIT_AUTOMAKE(clamsmtp, 0.6.90)
+AC_INIT(clamsmtp, 0.6.91, nielsen@memberwebs.com)
+AM_INIT_AUTOMAKE(clamsmtp, 0.6.91)
LDFLAGS="$LDFLAGS -L/usr/local/lib"
CFLAGS="$CFLAGS -I/usr/local/include"
diff --git a/src/clamsmtpd.c b/src/clamsmtpd.c
index 984744d..a0e59cf 100644
--- a/src/clamsmtpd.c
+++ b/src/clamsmtpd.c
@@ -91,6 +91,7 @@ clamsmtp_thread_t;
#define SMTP_DATA "DATA" CRLF
#define SMTP_BANNER "220 clamsmtp" CRLF
+#define SMTP_HELO_RSP "250 clamsmtp" CRLF
#define SMTP_DELIMS "\r\n\t :-"
#define ESMTP_PIPELINE "PIPELINING"
@@ -674,11 +675,13 @@ static int smtp_passthru(clamsmtp_context_t* ctx)
{
char logline[LINE_LENGTH];
int r, ret = 0;
- int first_rsp = 1;
- int filter_ehlo = 0;
fd_set mask;
int neterror = 0;
+ int first_rsp = 1; /* The first 220 response from server to be filtered */
+ int filter_ehlo = 0; /* Filtering parts of an EHLO extensions response */
+ int filter_host = 0; /* Next response is 250 hostname, which we change */
+
ASSERT(ctx->clam != -1 && ctx->server != -1);
logline[0] = 0;
@@ -720,9 +723,9 @@ static int smtp_passthru(clamsmtp_context_t* ctx)
continue;
}
- /* Only valid after an EHLO command */
- if(filter_ehlo)
- filter_ehlo = 0;
+ /* Only valid after EHLO or HELO commands */
+ filter_ehlo = 0;
+ filter_host = 0;
/* Handle the DATA section via our AV checker */
if(is_first_word(ctx->line, DATA_CMD, KL(DATA_CMD)))
@@ -757,6 +760,7 @@ static int smtp_passthru(clamsmtp_context_t* ctx)
{
messagex(ctx, LOG_DEBUG, "filtering EHLO response");
filter_ehlo = 1;
+ filter_host = 1;
/* A new message */
logline[0] = 0;
@@ -768,6 +772,8 @@ static int smtp_passthru(clamsmtp_context_t* ctx)
*/
else if(is_first_word(ctx->line, HELO_CMD, KL(HELO_CMD)))
{
+ filter_host = 1;
+
/* A new message line */
logline[0] = 0;
}
@@ -849,6 +855,26 @@ static int smtp_passthru(clamsmtp_context_t* ctx)
}
/*
+ * Certain mail servers (Postfix 1.x in particular) do a loop check
+ * on the 250 response after a EHLO or HELO. This is where we
+ * filter that to prevent loopback errors.
+ */
+ if(filter_host)
+ {
+ filter_host = 0;
+
+ if(check_first_word(ctx->line, OK_RSP, KL(OK_RSP), SMTP_DELIMS) > 0)
+ {
+ messagex(ctx, LOG_DEBUG, "intercepting host response");
+
+ if(write_data(ctx, &(ctx->client), SMTP_HELO_RSP) == -1)
+ RETURN(-1);
+
+ continue;
+ }
+ }
+
+ /*
* Filter out any EHLO responses that we can't or don't want
* to support. For example pipelining or TLS.
*/