help-gsasl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] ignore untagged responses during IMAP authentication


From: Enrico Scholz
Subject: [PATCH] ignore untagged responses during IMAP authentication
Date: Sat, 12 Nov 2011 23:35:17 +0100

Some IMAP server (e.g. dovecot) return new capabilities as untagged
response.  Old code expected only one line (e.g. the final '. OK')
which would be given out as part of the application data.  E.g. without
this patch, authentication to a dovecot server would look like:

| $ gsasl mailbox 143 --imap ...
| ...
| + BQQF/wAMAAAAAAAAIO4EoAH...
| BQQE/wAMAAAAAAAAII9BbgH...
| * CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ...
| Client authentication finished (server trusted)...
| Enter application data (EOF to finish):
| . OK Logged in

Patches changes it to

| + BQQF/wAMAAAAAAAAIX...
| BQQE/wAMAAAAAAAAK2...
| * CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ...
| . OK Logged in
| Client authentication finished (server trusted)...
| Enter application data (EOF to finish):

Dialog with cyrus-imapd is not changed and ends always with

| + BQQF/wAMAAAAAAAAPqx...
| BQQE/wAMAAAAAAAAL...
| . OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ...] Success (tls protection)
| Client authentication finished (server trusted)...
| Enter application data (EOF to finish):

Signed-off-by: Enrico Scholz <address@hidden>
---
 src/imap.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/imap.c b/src/imap.c
index c7bc3ed..7b043ab 100644
--- a/src/imap.c
+++ b/src/imap.c
@@ -179,8 +179,17 @@ imap_auth_finish (void)
 {
   char *in;
 
-  if (!readln (&in))
-    return 0;
+  for (;;)
+    {
+      if (!readln (&in))
+       return 0;
+
+      /* skip untagged responses which can be returned by the server after
+        authentication (e.g. dovecot returns new '* CAPABILITY' information
+        before the final '. OK'). */
+      if (in[0] != '*')
+       break;
+    }
 
   return 1;
 }
-- 
1.7.7.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]