Bug #16647 [Opn->Asn]: AUTHENTICATE command hangs
| From: | jan at horde dot org | Date: | Mon, 28 Sep 2009 10:04:27 +0000 |
| Subject: | Bug #16647 [Opn->Asn]: AUTHENTICATE command hangs | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-1754@lists.php.net to get a copy of this message | ||
Edit report at http://pear.php.net/bugs/bug.php?id=16647&edit=1
ID: 16647
Updated by: jan@horde.org
Reported By: speed47_pear at speed47 dot net
Summary: AUTHENTICATE command hangs
-Status: Open
+Status: Assigned
Type: Bug
Package: Net_Sieve
Operating System: Linux
Package Version: CVS
PHP Version: 5.2.5
-Assigned To:
+Assigned To: yunosh
Roadmap Versions:
New Comment:
-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: yunosh
Previous Comments:
------------------------------------------------------------------------
[2009-09-27 12:37:56] speed47
Added #patch
bug:16647;patch:fix-sieve-authenticate-challenge;revision:1254051476;.
------------------------------------------------------------------------
[2009-09-27 12:33:09] speed47
Description:
------------
I can't use the Net_Sieve to login to my managesieve dovecot server.
After some debugging and Wiresharking, I noticed that after the
AUTHENTICATE "CRAM-MD5" command, the server sends back a challenge, and
then sits waiting for an answer. Net_Sieve never sends any answer back
because it's still waiting for others data from the server, due to the
way the _doCmd() is written.
The code seems to support challenges, but only if the challenge length
is announced with a string-length indicator, as in :
C:AUTHENTICATE "CRAM-MD5"
S:{30}
S:abcdefghijklmnopqrstuvwxyz1234
But the ietf draft (see
http://tools.ietf.org/html/draft-ietf-sieve-managesieve-09)
also shows
that the server can send the challenge between quotes and without a
length-indicator, as in :
C:AUTHENTICATE "CRAM-MD5"
S:"abcdefghijklmnopqrstuvwxyz1234"
For some reason, my managesieve dovecot server uses the latter form. I
wrote a patch to add support for this form to Net_Sieve.php, and it now
works. This is done adding another state to the class :
NET_SIEVE_STATE_CONNECTED, which is set right after the TCP connection
is established, and until we set either state AUTHORISATION or
TRANSACTION, after establishing the TLS layer (if configured) and after
querying the capabilities. When the state AUTHORISATION state is active,
the _doCmd() function will wait for challenges from the server,
expecting either the form with the string-length indicator, or without.
The portion of the code that expects a challenge without a string-length
indicator is only active if the AUTHORISATION state is active, which is
why I added the CONNECTED state : to avoid taking an answer to
CAPABILITY or a server greeting for a challenge).
It has been tested with auth methods PLAIN, LOGIN, CRAM-MD5 and
DIGEST-MD5, with and without TLS.
The "bypass auth" case is however untested.
It should be also a good idea to test it with servers that use the
first form for challenges (apparently timsieved does).
The managesieve dovecot server version I use is 1.13, from Debian lenny
backports.
My actual version of PHP is 5.2.6 (it's absent from the listbox).
Test script:
---------------
<?php
include('Sieve.php');
$sieve = new Net_Sieve('user', 'pass', 'localhost' , 2000,
'', '',
true, false, false, null);
Expected result:
----------------
Successful login
Actual result:
--------------
S:"IMPLEMENTATION" "dovecot"
S:"SASL" "PLAIN LOGIN CRAM-MD5"
S:"SIEVE" "comparator-i;ascii-numeric fileinto reject vacation
imapflags notify include envelope body relational regex subaddress
copy"
S:"STARTTLS"
S:"RENAME"
S:OK "Dovecot ready."
C:CAPABILITY
S:"IMPLEMENTATION" "dovecot"
S:"SASL" "PLAIN LOGIN CRAM-MD5"
S:"SIEVE" "comparator-i;ascii-numeric fileinto reject vacation
imapflags notify include envelope body relational regex subaddress
copy"
S:"STARTTLS"
S:"RENAME"
S:OK "Capability completed."
C:AUTHENTICATE "CRAM-MD5"
S:"PDI2NzUxNTYyMTQ2OTgyODcuMTI1NDA0NjYzM0BtYWlsPg=="
// it then hangs here forever (_doCmd never returns)
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=16647&edit=1