[Date Prev][Date Next] [Chronological] [Thread] [Top]

cyrus sasl callbacks patch (ITS#2926)



Full_Name: Igor Brezac
Version: 2.1.25
OS: Solaris 9
URL: 
Submission from: (NULL) (209.170.129.80)


Please consider the following patch for improved sasl handling.  The following
setup does not work: sasl client -> cyrus imapd -> ldap auxprop.  The previously
established sasl_client_init() session (imapd) prevents the setup of global
callbacks for openldap libs which breaks ldap auxprop.  This patch sets up per
session callbacks and the above setup works.  I suppose the global setup of the
same callbacks would not hurt anything.

--- cyrus.c.orig        Tue Jan 20 22:27:03 2004
+++ cyrus.c     Tue Jan 20 22:26:54 2004
@@ -44,18 +44,6 @@
        /* XXX not threadsafe */
        static int sasl_initialized = 0;
 
-       static sasl_callback_t client_callbacks[] = {
-#ifdef SASL_CB_GETREALM
-               { SASL_CB_GETREALM, NULL, NULL },
-#endif
-               { SASL_CB_USER, NULL, NULL },
-               { SASL_CB_AUTHNAME, NULL, NULL },
-               { SASL_CB_PASS, NULL, NULL },
-               { SASL_CB_ECHOPROMPT, NULL, NULL },
-               { SASL_CB_NOECHOPROMPT, NULL, NULL },
-               { SASL_CB_LIST_END, NULL, NULL }
-       };
-
 #ifdef HAVE_SASL_VERSION
 #define SASL_BUILD_VERSION ((SASL_VERSION_MAJOR << 24) |\
        (SASL_VERSION_MINOR << 16) | SASL_VERSION_STEP)
@@ -101,7 +89,7 @@
        ldap_pvt_thread_mutex_init( &ldap_int_sasl_mutex );
 #endif
 
-       if ( sasl_client_init( client_callbacks ) == SASL_OK ) {
+       if ( sasl_client_init( NULL ) == SASL_OK ) {
                sasl_initialized = 1;
                return 0;
        }
@@ -465,6 +453,18 @@
        int rc;
        sasl_conn_t *ctx;
 
+       static sasl_callback_t client_callbacks[] = {
+#ifdef SASL_CB_GETREALM
+               { SASL_CB_GETREALM, NULL, NULL },
+#endif
+               { SASL_CB_USER, NULL, NULL },
+               { SASL_CB_AUTHNAME, NULL, NULL },
+               { SASL_CB_PASS, NULL, NULL },
+               { SASL_CB_ECHOPROMPT, NULL, NULL },
+               { SASL_CB_NOECHOPROMPT, NULL, NULL },
+               { SASL_CB_LIST_END, NULL, NULL }
+       };
+
        assert( lc->lconn_sasl_ctx == NULL );
 
        if ( host == NULL ) {
@@ -474,7 +474,7 @@
 
 #if SASL_VERSION_MAJOR >= 2
        rc = sasl_client_new( "ldap", host, NULL, NULL,
-               NULL, 0, &ctx );
+               client_callbacks, 0, &ctx );
 #else
        rc = sasl_client_new( "ldap", host, NULL,
                SASL_SECURITY_LAYER, &ctx );