Bug 146585 - [PATCH] SASL Authentication fails if another client of sasl is loaded
Summary: [PATCH] SASL Authentication fails if another client of sasl is loaded
Status: RESOLVED FIXED
Alias: None
Product: kio
Classification: Unmaintained
Component: imap (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-09 14:36 UTC by Andreas Roth
Modified: 2007-09-14 12:17 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Fix callbacks for IMAP and SIEVE kioslave (2.64 KB, patch)
2007-06-09 14:37 UTC, Andreas Roth
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Roth 2007-06-09 14:36:30 UTC
Version:            (using KDE KDE 3.5.7)
Installed from:    Ubuntu Packages
OS:                Linux

This error occurs, if another module (kio slave) already loaded the libsasl library and initialized the library. 
 
In smtp.cc the function sasl_client_init is called with a set of callback functions. If another user of libsasl already called this function before and specified a different set of callbacks (or NULL), the second set of callbacks is ignored an the first set is used. 
In the kio_imap the callbacks must be specified to work with SASL mechanism which require callbacks to get username and password. But if the callbacks aren't installed because someone before has specified another set of callbacks all SASL mechanism which require callbacks aren't working (which left me with only three mechanisms Clear-Text, EXTERNAL and ANONYMOUS). 
As a result i can only retrieve my mail using the Clear-Text authentification. 
 
I think this issue also occurs on every other kioslave which uses the libsasl for authentication (see also https://bugs.kde.org/show_bug.cgi?id=146582)
Comment 1 Andreas Roth 2007-06-09 14:37:38 UTC
Created attachment 20819 [details]
Fix callbacks for IMAP and SIEVE kioslave 

The patch fixes the SASL callbacks for the IMAP and SIEVE kioslaves. It simply 

 specifies the callbacks for every connection (in sasl_client_new) instead of 
 using the callbacks specified through sasl_client_init.
Comment 2 Allen Winter 2007-06-13 17:05:44 UTC
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