dovecot-2.0: imap-login: Give a helpful error message if user tr...

dovecot at dovecot.org dovecot at dovecot.org
Tue Mar 9 21:22:08 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/70a861ba3115
changeset: 10885:70a861ba3115
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Mar 09 21:22:05 2010 +0200
description:
imap-login: Give a helpful error message if user tries to log in without giving command tag.

diffstat:

 src/imap-login/client.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (35 lines):

diff -r a38d597c5b59 -r 70a861ba3115 src/imap-login/client.c
--- a/src/imap-login/client.c	Tue Mar 09 19:40:33 2010 +0200
+++ b/src/imap-login/client.c	Tue Mar 09 21:22:05 2010 +0200
@@ -186,7 +186,7 @@
 	if (strcmp(cmd, "ENABLE") == 0)
 		return cmd_enable(client);
 
-	return -1;
+	return -2;
 }
 
 static bool client_handle_input(struct imap_client *client)
@@ -258,7 +258,12 @@
 		ret = client_command_execute(client, client->cmd_name, args);
 
 	client->cmd_finished = TRUE;
-	if (ret < 0) {
+	if (ret == -2 && strcasecmp(client->cmd_tag, "LOGIN") == 0) {
+		client_send_line(&client->common, CLIENT_CMD_REPLY_BAD,
+			"First parameter in line is IMAP's command tag, "
+			"not the command name. Add that before the command, "
+			"like: a login user pass");
+	} else if (ret < 0) {
 		if (*client->cmd_tag == '\0')
 			client->cmd_tag = "*";
 		if (++client->common.bad_counter >= CLIENT_MAX_BAD_COMMANDS) {
@@ -267,7 +272,7 @@
 			client_destroy(&client->common,
 				"Disconnected: Too many invalid commands");
 			return FALSE;
-		}  
+		}
 		client_send_line(&client->common, CLIENT_CMD_REPLY_BAD,
 			"Error in IMAP command received by server.");
 	}


More information about the dovecot-cvs mailing list