Subject: "bad protocol / cancel" when using /ssl in mailbox naming

From: richard offer <[email-masked]>
Date: Sat, 17 Nov 2001 11:32:12 -0800

Hi,

I'm having a problem authenticating to my cyrus imap server if I add /ssl 
to the mailbox naming specification. The problem only appears in my 
(under-development) program and not (for example) when I use ifrom, so 
obviously its a "stupid user" problem.

It looks like my client is sending back a bad MD5 password, since in my 
client the debug output for the password is a shorter than ifrom reports. 
Adding a printf in mm_login() proves that the correct password is being 
copied to pwd.

With debugging on I get the output (hostname replaces real FQDN)

(sorry for any broken formatting, I _still_ haven't managed to get 
mulberry not to wrap)

[ richard@fey ] ./tilly
* OK hostname Cyrus IMAP4 v2.0.9 server ready
00000000 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 ACL QUOTA LITERAL+ NAMESPACE UIDPLUS ID 
NO_ATOMIC_RENAME UNSELECT MULTIAPPEND SORT THREAD=ORDEREDSUBJECT 
THREAD=REFERENCES IDLE STARTTLS AUTH=PLAIN AUTH=LOGIN AUTH=DIGEST-MD5 
AUTH=CRAM-MD5 X-NETSCAPE
00000000 OK Completed
00000001 AUTHENTICATE CRAM-MD5
+ PDMzMDE2NDQ5ODUuMTYxNjUwMTJAZXJpai53aGl0ZXF1ZWVuLmNvbT4=
IGMzMWUxOWY3N2MyZDQ0YjFiN2IyNmRhNGM5NzAxY2E3
00000001 NO bad protocol / cancel
WARN=Retrying CRAM-MD5 authentication after bad protocol / cancel

Using ifrom I see the following (the mailbox is identical to that in the 
previous example)

[ richard@fey ] ~/playdir/ifrom/ifrom 
{hostname/imap/ssl/novalidate-cert/readonly/debug/user=richard}
* OK hostname Cyrus IMAP4 v2.0.9 server ready
00000000 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 ACL QUOTA LITERAL+ NAMESPACE UIDPLUS ID 
NO_ATOMIC_RENAME UNSELECT MULTIAPPEND SORT THREAD=ORDEREDSUBJECT 
THREAD=REFERENCES IDLE STARTTLS AUTH=PLAIN AUTH=LOGIN AUTH=DIGEST-MD5 
AUTH=CRAM-MD5 X-NETSCAPE
00000000 OK Completed
00000001 AUTHENTICATE CRAM-MD5
+ PDYwOTU3Mzg4My4xNjE2NTA4OUBlcmlqLndoaXRlcXVlZW4uY29tPg==
{hostname/imap/user=richard} password:
cmljaGFyZCA5MjViOGM0Zjc0ZGU0OTVhOTg3Y2Y4MTc2Nzk2OTE0OQ==
00000001 OK Success (tls protection)

If I take the /ssl out and rely on STARTTLS it works okay. I'm not using 
the standard linkage.c, however I am linking in imap, auth_md5, auth_pla, 
auth_log and calling ssl_onceonlyinit() in that order.

Linkage.c also has mail_parameters(NIL,SET_DISABLEPLAINTEXT,(void *) 2) 
which for development purposes I haven't added to my code yet (I did but 
it made no difference).

This was originally seen with imap-2001.BETA.SNAP-0104262058, but I've 
just reproduced it with imap-2001a.

Any one want to take a swing with the clue stick ?

richard.
-- 
richard offer @ home                        DSS  3072/1024 0x8AFBBFA3
        84 FE 48 E4 74 D0 26 D4  31 8E B6 86 98 74 E2 7C  8A FB BF A3
_____________________________http://www.whitequeen.com/users/richard/

-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------

---

From: Mark Crispin <[email-masked]>
Date: Sat, 17 Nov 2001 12:11:33 -0800 (PST)

Here's what I recommend:

1) Do not link by hand.  Use linkage.c.  The linkage.c mechanism was created
   for a reason.  Although I don't think that your problem is caused by not
   using linkage.c, there have been people who sent me bug reports and wasted
   lots of my time before I discovered that the problem was that they lunk by
   hand and did it wrong.

2) Make sure that mm_login returns the user as well as the password.  You need
   something like:
	strcpy (user,*mb->user ? mb->user : prompt_for_user_name ());

---

From: richard offer <[email-masked]>
Date: Sat, 17 Nov 2001 12:53:01 -0800

* [email-masked] at '11/17/01 12:11:33 PM -0800'
*

* Here's what I recommend:
*
* 1) Do not link by hand.  Use linkage.c.  The linkage.c mechanism was
* created    for a reason.  Although I don't think that your problem is
* caused by not    using linkage.c, there have been people who sent me
* bug reports and wasted    lots of my time before I discovered that the
* problem was that they lunk by    hand and did it wrong.

Didn't fix anything, but I'll follow your advice.

*
* 2) Make sure that mm_login returns the user as well as the password.
* You need    something like:
* 	strcpy (user,*mb->user ? mb->user : prompt_for_user_name ());

That was it. I foolishly assumed that because I was supplying a user in 
the mailbox spec (and it was present in NETMBX) that I did't need to copy 
the user portion back.

Thanks.

richard.