[Bug 146585] [PATCH] SASL Authentication fails if another client of sasl is loaded
Allen Winter <[email protected]>
| Newsgroups | gmane.comp.kde.devel.kmail,gmane.spam.detected |
|---|---|
| Message-ID | <[email protected]> |
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=146585
winter kde org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
------- Additional Comments From winter kde org 2007-06-13 17:05 -------
SVN commit 674932 by winterz:
Fix bug "SASL Authentication fails if another client of sasl is loaded"
Patch provided by Andreas. Thanks!
BUGS: 146585
M +13 -3 imap4/imapparser.cc
M +28 -28 sieve/sieve.cpp
--- branches/KDE/3.5/kdepim/kioslaves/imap4/imapparser.cc #674931:674932
@ -45,6 +45,16 @
extern "C" {
#include <sasl/sasl.h>
}
+static sasl_callback_t callbacks[] = {
+ { SASL_CB_ECHOPROMPT, NULL, NULL },
+ { SASL_CB_NOECHOPROMPT, NULL, NULL },
+ { SASL_CB_GETREALM, NULL, NULL },
+ { SASL_CB_USER, NULL, NULL },
+ { SASL_CB_AUTHNAME, NULL, NULL },
+ { SASL_CB_PASS, NULL, NULL },
+ { SASL_CB_CANON_USER, NULL, NULL },
+ { SASL_CB_LIST_END, NULL, NULL }
+};
#endif
#include <qregexp.h>
@ -222,7 +232,7 @
result = sasl_client_new( "imap", /* FIXME: with cyrus-imapd, even imaps' digest-uri
must be 'imap'. I don't know if it's good or bad. */
aFQDN.latin1(),
- 0, 0, 0, 0, &conn );
+ 0, 0, callbacks, 0, &conn );
if ( result != SASL_OK ) {
kdDebug(7116) << "sasl_client_new failed with: " << result << endl;
@ -1800,7 +1810,7 @
QString temp = (*it);
int pt = temp.find ('/');
- if (pt > 0)
+ if (pt > 0)
{
if (temp.findRev ('"', pt) == -1 || temp.find('"', pt) == -1)
{
@ -1832,7 +1842,7 @
if (!_box.isEmpty () && _box[_box.length () - 1] == '/')
_box.truncate(_box.length() - 1);
}
- kdDebug(7116) << "URL: box= " << _box << ", section= " << _section << ", type= "
+ kdDebug(7116) << "URL: box= " << _box << ", section= " << _section << ", type= "
<< _type << ", uid= " << _uid << ", validity= " << _validity << ", info= " << _info << endl;
}
--- branches/KDE/3.5/kdepim/kioslaves/sieve/sieve.cpp #674931:674932
@ -14,7 +14,7 @
* *
***************************************************************************/
-/**
+/**
* Portions adapted from the SMTP ioslave.
* Copyright (c) 2000, 2001 Alex Zepeda <jazepeda pacbell net>
* Copyright (c) 2001 Michael Häckel <Michael Haeckel Net>
@ -60,7 +60,7 @
#endif
#define SIEVE_DEFAULT_PORT 2000
-
+
static sasl_callback_t callbacks[] = {
{ SASL_CB_ECHOPROMPT, NULL, NULL },
{ SASL_CB_NOECHOPROMPT, NULL, NULL },
@ -81,7 +81,7 @
KDE_EXPORT int kdemain(int argc, char **argv)
{
KInstance instance("kio_sieve" );
-
+
ksDebug() << "*** Starting kio_sieve " << endl;
if (argc != 4) {
@ -230,17 +230,17 @
bool kio_sieveProtocol::parseCapabilities(bool requestCapabilities/* = false*/)
{
ksDebug() << k_funcinfo << endl;
-
+
// Setup...
bool ret = false;
-
+
if (requestCapabilities) {
sendData("CAPABILITY");
}
while (receiveData()) {
ksDebug() << "Looping receive" << endl;
-
+
if (r.getType() == kio_sieveResponse::ACTION) {
if ( r.getAction().contains("ok", false) != -1 ) {
ksDebug() << "Sieve server ready & awaiting authentication." << endl;
@ -271,12 +271,12 @
ksDebug() << "Server supports TLS" << endl;
m_supportsTLS = true;
setMetaData("tlsSupported", "true");
-
+
} else {
ksDebug() << "Unrecognised key " << r.getKey() << endl;
}
}
-
+
if (!m_supportsTLS) {
setMetaData("tlsSupported", "false");
}
@ -301,7 +301,7 @
if ( query.startsWith("?") ) query.remove( 0, 1 );
QStringList q = QStringList::split( ",", query );
QStringList::iterator it;
-
+
for ( it = q.begin(); it != q.end(); ++it ) {
if ( ( (*it).section('=',0,0) ).lower() == "x-mech" ) {
auth = ( (*it).section('=',1) ).upper();
@ -325,7 +325,7 @
bool kio_sieveProtocol::connect(bool useTLSIfAvailable)
{
ksDebug() << k_funcinfo << endl;
-
+
if (isConnectionValid()) return true;
infoMessage(i18n("Connecting to %1...").arg( m_sServer));
@ -334,7 +334,7 @
error(ERR_CONNECTION_BROKEN, i18n("The connection to the server was lost."));
return false;
}
-
+
setBlockConnection(true);
if (!connectToHost(m_sServer, m_iPort, true)) {
@ -406,7 +406,7 @
/*void kio_sieveProtocol::slave_status()
{
slaveStatus(isConnectionValid() ? m_sServer : "", isConnectionValid());
-
+
finished();
}*/
@ -600,7 +600,7 @
if (operationSuccessful())
ksDebug() << "Script upload complete." << endl;
-
+
else {
/* The managesieve server parses received scripts and rejects
* scripts which are not syntactically correct. Here we expect
@ -766,7 +766,7 @
}
infoMessage(i18n("Done."));
-
+
finished();
}
@ -783,7 +783,7 @
error(ERR_CANNOT_CHMOD, i18n("Cannot chmod to anything but 0700 (active) or 0600 (inactive script)."));
return;
}
-
+
finished();
}
@ -823,7 +823,7 @
while(receiveData()) {
if (r.getType() == kio_sieveResponse::ACTION) {
- if (r.getAction().contains("OK", false) == 1)
+ if (r.getAction().contains("OK", false) == 1)
// Script list completed
break;
@ -924,7 +924,7 @
//some mechanisms do not require username && pass, so it doesn't need a popup
//window for getting this info
for ( ; interact->id != SASL_CB_LIST_END; interact++ ) {
- if ( interact->id == SASL_CB_AUTHNAME ||
+ if ( interact->id == SASL_CB_AUTHNAME ||
interact->id == SASL_CB_PASS ) {
if (m_sUser.isEmpty() || m_sPass.isEmpty()) {
@ -938,7 +938,7 @
break;
}
}
-
+
interact = ( sasl_interact_t * ) in;
while( interact->id != SASL_CB_LIST_END ) {
ksDebug() << "SASL_INTERACT id: " << interact->id << endl;
@ -993,7 +993,7 @
result = sasl_client_new( "sieve",
m_sServer.latin1(),
- 0, 0, NULL, 0, &conn );
+ 0, 0, callbacks, 0, &conn );
if ( result != SASL_OK ) {
ksDebug() << "sasl_client_new failed with: " << result << endl;
@ -1013,7 +1013,7 @
result = sasl_client_start(conn, strList.join(" ").latin1(), &client_interact,
&out, &outlen, &mechusing);
- if (result == SASL_INTERACT)
+ if (result == SASL_INTERACT)
if ( !saslInteract( client_interact, ai ) ) {
sasl_dispose( &conn );
return false;
@ -1042,15 +1042,15 @
ksDebug() << "firstCommand: " << firstCommand << endl;
if (!sendData( firstCommand.latin1() ))
return false;
-
+
QCString command;
-
+
do {
receiveData();
-
+
if (operationResult() != OTHER)
break;
-
+
ksDebug() << "Challenge len " << r.getQuantity() << endl;
if (r.getType() != kio_sieveResponse::QUANTITY) {
@ -1085,7 +1085,7 @
&client_interact,
&out, &outlen);
- if (result == SASL_INTERACT)
+ if (result == SASL_INTERACT)
if ( !saslInteract( client_interact, ai ) ) {
sasl_dispose( &conn );
return false;
@ -1099,7 +1099,7 @
sasl_dispose( &conn );
return false;
}
-
+
tmp.setRawData( out, outlen );
KCodecs::base64Encode( tmp, challenge );
tmp.resetRawData( out, outlen );
@ -1110,7 +1110,7 @
ksDebug() << "Challenges finished." << endl;
sasl_dispose( &conn );
-
+
if (operationResult() == OK) {
// Authentication succeeded.
return true;
@ -1264,6 +1264,6 @
return BYE;
}
}
-
+
return OTHER;
}
_______________________________________________
KMail developers mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kmail-devel