dovecot-2.2: lib-lda: When non-RCPT/DATA command fails permanent...

dovecot at dovecot.org dovecot at dovecot.org
Fri Apr 25 13:15:53 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/c03076e03250
changeset: 17268:c03076e03250
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Apr 25 16:15:20 2014 +0300
description:
lib-lda: When non-RCPT/DATA command fails permanently, translate it internally to temporary failure.
We shouldn't be answering permanent failures to RCPT/DATA command when the
failure really had nothing to do with the recipient/content itself. Most
likely it's just some server misconfiguration, which should be treated as
temporary error.

diffstat:

 src/lib-lda/lmtp-client.c |  33 ++++++++++++++++++++++++---------
 1 files changed, 24 insertions(+), 9 deletions(-)

diffs (67 lines):

diff -r dc5ba8637aa7 -r c03076e03250 src/lib-lda/lmtp-client.c
--- a/src/lib-lda/lmtp-client.c	Fri Apr 25 15:57:03 2014 +0300
+++ b/src/lib-lda/lmtp-client.c	Fri Apr 25 16:15:20 2014 +0300
@@ -458,39 +458,54 @@
 					     client->input_multiline)) <= 0) {
 		if (ret == 0)
 			return 0;
-		lmtp_client_fail(client, line);
+		lmtp_client_fail(client, t_strdup_printf(
+			"451 4.5.0 Received invalid input: %s", line));
 		return -1;
 	}
 
 	switch (client->input_state) {
 	case LMTP_INPUT_STATE_GREET:
+		if (reply_code != 220) {
+			lmtp_client_fail(client, t_strdup_printf(
+				"451 4.5.0 Received invalid greeting: %s", line));
+			return -1;
+		}
+		lmtp_client_send_handshake(client);
+		client->input_state = LMTP_INPUT_STATE_LHLO;
+		break;
 	case LMTP_INPUT_STATE_XCLIENT:
 		if (reply_code != 220) {
-			lmtp_client_fail(client, line);
+			lmtp_client_fail(client, t_strdup_printf(
+				"451 4.5.0 XCLIENT failed: %s", line));
 			return -1;
 		}
 		lmtp_client_send_handshake(client);
 		client->input_state = LMTP_INPUT_STATE_LHLO;
 		break;
 	case LMTP_INPUT_STATE_LHLO:
-	case LMTP_INPUT_STATE_MAIL_FROM:
 		if (reply_code != 250) {
+			lmtp_client_fail(client, t_strdup_printf(
+				"451 4.5.0 LHLO failed: %s", line));
 			lmtp_client_fail(client, line);
 			return -1;
 		}
 		str_append(client->input_multiline, line);
 		lmtp_client_parse_capabilities(client,
 			str_c(client->input_multiline));
-		if (client->input_state == LMTP_INPUT_STATE_LHLO &&
-		    lmtp_client_send_xclient(client)) {
+		if (lmtp_client_send_xclient(client)) {
 			client->input_state = LMTP_INPUT_STATE_XCLIENT;
 			client->xclient_sent = TRUE;
 			break;
 		}
-		if (client->input_state == LMTP_INPUT_STATE_LHLO) {
-			o_stream_nsend_str(client->output,
-				t_strdup_printf("MAIL FROM:%s\r\n",
-						client->set.mail_from));
+		o_stream_nsend_str(client->output, t_strdup_printf(
+			"MAIL FROM:%s\r\n", client->set.mail_from));
+		client->input_state++;
+		break;
+	case LMTP_INPUT_STATE_MAIL_FROM:
+		if (reply_code != 250) {
+			lmtp_client_fail(client, t_strdup_printf(
+				"451 4.5.0 MAIL FROM failed: %s", line));
+			return -1;
 		}
 		client->input_state++;
 		lmtp_client_send_rcpts(client);


More information about the dovecot-cvs mailing list