summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2004-07-23 21:00:08 +0000
committerStef Walter <stef@memberwebs.com>2004-07-23 21:00:08 +0000
commitcede6399f63a6dc8ab2ad195b24848b7733bf8e1 (patch)
treed910ad26efd10b89565d73268c1bd2842b528a25
parent505c12f698117db99428091285779be7609f5347 (diff)
- Always announce self as 'clamsmtp'
-rw-r--r--ChangeLog3
-rw-r--r--common/smtppass.c21
-rw-r--r--configure.in4
-rw-r--r--src/clamsmtpd.c21
4 files changed, 23 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 4052241..ec08ecd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+0.5
+ - Announce ourselves as 'clamsmtp' in banner to prevent loop warnings
+
0.4
- Option for quarantining files with viruses
- Fixed problem with returning wrong SMTP error code
diff --git a/common/smtppass.c b/common/smtppass.c
index f021a8b..600f31c 100644
--- a/common/smtppass.c
+++ b/common/smtppass.c
@@ -90,7 +90,7 @@ clamsmtp_thread_t;
#define SMTP_OK "250 Ok" CRLF
#define SMTP_DATA "DATA" CRLF
-#define SMTP_START "220 "
+#define SMTP_BANNER "220 clamsmtp" CRLF
#define SMTP_DELIMS "\r\n\t :"
#define HELO_CMD "HELO"
@@ -768,6 +768,13 @@ static int smtp_passthru(clamsmtp_context_t* ctx)
* We intercept the first response we get from the server.
* This allows us to change header so that it doesn't look
* to the client server that we're in a wierd loop.
+ *
+ * In different situations using the local hostname or
+ * 'localhost' don't work because the receiving mail server
+ * expects one of those to be its own name. We use 'clamsmtp'
+ * instead. No properly configured server would have this
+ * as their domain name, and RFC 2821 allows us to use
+ * an arbitrary but identifying string.
*/
if(first_rsp)
{
@@ -777,17 +784,7 @@ static int smtp_passthru(clamsmtp_context_t* ctx)
{
messagex(ctx, LOG_DEBUG, "intercepting initial response");
- strlcpy(ctx->line, SMTP_START, LINE_LENGTH);
-
- r = KL(SMTP_START);
-
- if(gethostname(ctx->line + r, LINE_LENGTH - r) == -1)
- strlcat(ctx->line, "clamsmtp", LINE_LENGTH);
-
- strlcat(ctx->line, CRLF, LINE_LENGTH);
- ctx->line[LINE_LENGTH - 1] = 0;
-
- if(write_data(ctx, &(ctx->client), ctx->line) == -1)
+ if(write_data(ctx, &(ctx->client), SMTP_BANNER) == -1)
RETURN(-1);
/* Command handled */
diff --git a/configure.in b/configure.in
index 4bb2fc3..155e6b3 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.4, nielsen@memberwebs.com)
-AM_INIT_AUTOMAKE(clamsmtp, 0.4)
+AC_INIT(clamsmtp, 0.5, nielsen@memberwebs.com)
+AM_INIT_AUTOMAKE(clamsmtp, 0.5)
LDFLAGS="$LDFLAGS -L/usr/local/lib"
CFLAGS="$CFLAGS -I/usr/local/include"
diff --git a/src/clamsmtpd.c b/src/clamsmtpd.c
index f021a8b..600f31c 100644
--- a/src/clamsmtpd.c
+++ b/src/clamsmtpd.c
@@ -90,7 +90,7 @@ clamsmtp_thread_t;
#define SMTP_OK "250 Ok" CRLF
#define SMTP_DATA "DATA" CRLF
-#define SMTP_START "220 "
+#define SMTP_BANNER "220 clamsmtp" CRLF
#define SMTP_DELIMS "\r\n\t :"
#define HELO_CMD "HELO"
@@ -768,6 +768,13 @@ static int smtp_passthru(clamsmtp_context_t* ctx)
* We intercept the first response we get from the server.
* This allows us to change header so that it doesn't look
* to the client server that we're in a wierd loop.
+ *
+ * In different situations using the local hostname or
+ * 'localhost' don't work because the receiving mail server
+ * expects one of those to be its own name. We use 'clamsmtp'
+ * instead. No properly configured server would have this
+ * as their domain name, and RFC 2821 allows us to use
+ * an arbitrary but identifying string.
*/
if(first_rsp)
{
@@ -777,17 +784,7 @@ static int smtp_passthru(clamsmtp_context_t* ctx)
{
messagex(ctx, LOG_DEBUG, "intercepting initial response");
- strlcpy(ctx->line, SMTP_START, LINE_LENGTH);
-
- r = KL(SMTP_START);
-
- if(gethostname(ctx->line + r, LINE_LENGTH - r) == -1)
- strlcat(ctx->line, "clamsmtp", LINE_LENGTH);
-
- strlcat(ctx->line, CRLF, LINE_LENGTH);
- ctx->line[LINE_LENGTH - 1] = 0;
-
- if(write_data(ctx, &(ctx->client), ctx->line) == -1)
+ if(write_data(ctx, &(ctx->client), SMTP_BANNER) == -1)
RETURN(-1);
/* Command handled */