2007-01-20 [colin] 2.7.1cvs38
authorColin Leroy <colin@colino.net>
Sat, 20 Jan 2007 15:52:18 +0000 (15:52 +0000)
committerColin Leroy <colin@colino.net>
Sat, 20 Jan 2007 15:52:18 +0000 (15:52 +0000)
* src/ldapquery.c
* src/ldaputil.c
* src/ldaputil.h
Fix bug 1102, 'claws-mail-2.7.1
makes use of deprecated ldap
functions'

ChangeLog
PATCHSETS
configure.ac
src/ldapquery.c
src/ldaputil.c
src/ldaputil.h

index 55550d20f2da410457fe5364432e89fe0da18976..2c2e61d381e942317c10ae1d14b3399fe89e5d95 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-01-20 [colin]     2.7.1cvs38
+
+       * src/ldapquery.c
+       * src/ldaputil.c
+       * src/ldaputil.h
+               Fix bug 1102, 'claws-mail-2.7.1 
+               makes use of deprecated ldap 
+               functions'
+
 2007-01-20 [colin]     2.7.1cvs37
 
        * src/mainwindow.c
index c0bf6b2b115a58372af9f250689393a943b3432c..84a385645ea8ff0974b8e7f38a4538944fe5a968 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.115.2.127 -r 1.115.2.128 src/main.c;  cvs diff -u -r 1.274.2.165 -r 1.274.2.166 src/mainwindow.c;  cvs diff -u -r 1.39.2.29 -r 1.39.2.30 src/mainwindow.h;  cvs diff -u -r 1.94.2.119 -r 1.94.2.120 src/messageview.c;  cvs diff -u -r 1.19.2.13 -r 1.19.2.14 src/messageview.h;  cvs diff -u -r 1.204.2.119 -r 1.204.2.120 src/prefs_common.c;  cvs diff -u -r 1.103.2.75 -r 1.103.2.76 src/prefs_common.h;  cvs diff -u -r 1.395.2.278 -r 1.395.2.279 src/summaryview.c;  cvs diff -u -r 1.68.2.32 -r 1.68.2.33 src/summaryview.h;  cvs diff -u -r 1.1.2.57 -r 1.1.2.58 src/gtk/quicksearch.c;  cvs diff -u -r 1.1.2.10 -r 1.1.2.11 src/gtk/quicksearch.h;  ) > 2.7.1cvs35.patchset
 ( cvs diff -u -r 1.96.2.165 -r 1.96.2.166 src/textview.c;  ) > 2.7.1cvs36.patchset
 ( cvs diff -u -r 1.274.2.166 -r 1.274.2.167 src/mainwindow.c;  cvs diff -u -r 1.39.2.30 -r 1.39.2.31 src/mainwindow.h;  cvs diff -u -r 1.395.2.279 -r 1.395.2.280 src/summaryview.c;  cvs diff -u -r 1.1.2.58 -r 1.1.2.59 src/gtk/quicksearch.c;  ) > 2.7.1cvs37.patchset
+( cvs diff -u -r 1.3.2.11 -r 1.3.2.12 src/ldapquery.c;  cvs diff -u -r 1.1.4.6 -r 1.1.4.7 src/ldaputil.c;  cvs diff -u -r 1.1.4.5 -r 1.1.4.6 src/ldaputil.h;  ) > 2.7.1cvs38.patchset
index c0e9d63d72efa409780c54f32b6e9cb355d731a5..1186b9e28062a5910d3f350176945316b0173849 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=7
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=37
+EXTRA_VERSION=38
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 5c99b917e8f464307b4e844a318b38b66c56bcb6..d70cbd6ddae8b2a3ebb5baa91fe67f40e10cfea2 100644 (file)
@@ -32,6 +32,7 @@
 #include <string.h>
 #include <lber.h>
 
+#include "ldaputil.h"
 #include "ldapquery.h"
 #include "ldapctrl.h"
 #include "mgutils.h"
@@ -39,8 +40,6 @@
 #include "addritem.h"
 #include "addrcache.h"
 
-#include "ldapquery.h"
-
 /*
  * Key for thread specific data.
  */
@@ -703,6 +702,7 @@ static gint ldapqry_connect( LdapQuery *qry ) {
        LDAP *ld = NULL;
        gint rc;
        gint version;
+       gchar *uri = NULL;
 
        /* Initialize connection */
        /* printf( "===ldapqry_connect===\n" ); */
@@ -714,14 +714,13 @@ static gint ldapqry_connect( LdapQuery *qry ) {
        qry->startTime = qry->touchTime;
        qry->elapsedTime = -1;
        ADDRQUERY_RETVAL(qry) = LDAPRC_INIT;
-       if (!ctl->enableSSL) {
-               ld = ldap_init( ctl->hostName, ctl->port );
-       } else {
-               gchar *uri = g_strdup_printf("ldaps://%s:%d",
+
+       uri = g_strdup_printf("ldap%s://%s:%d",
+                               ctl->enableSSL?"s":"",
                                ctl->hostName, ctl->port);
-               ldap_initialize(&ld, uri);
-               g_free(uri);
-       }
+       ldap_initialize(&ld, uri);
+       g_free(uri);
+
        if (ld == NULL)
                return ADDRQUERY_RETVAL(qry);
 
@@ -764,7 +763,7 @@ static gint ldapqry_connect( LdapQuery *qry ) {
        if( ctl->bindDN ) {
                if( * ctl->bindDN != '\0' ) {
                        /* printf( "binding...\n" ); */
-                       rc = ldap_simple_bind_s( ld, ctl->bindDN, ctl->bindPass );
+                       rc = claws_ldap_simple_bind_s( ld, ctl->bindDN, ctl->bindPass );
                        /* printf( "rc=%d\n", rc ); */
                        if( rc != LDAP_SUCCESS ) {
                                /*
@@ -793,7 +792,7 @@ static gint ldapqry_connect( LdapQuery *qry ) {
  */
 static gint ldapqry_disconnect( LdapQuery *qry ) {
        /* Disconnect */
-       if( qry->ldap ) ldap_unbind( qry->ldap );
+       if( qry->ldap ) ldap_unbind_ext( qry->ldap, NULL, NULL );
        qry->ldap = NULL;
 
        ldapqry_touch( qry );
index 27ec13904f8060704022d3a1232ea87edb04ee10..39e9ea1624a8f543fac83200cc236e647c6cbaf6 100644 (file)
@@ -192,6 +192,22 @@ static GList *ldaputil_test_v2( LDAP *ld, gint tov ) {
        return baseDN;
 }
 
+int claws_ldap_simple_bind_s( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *passwd )
+{
+       struct berval cred;
+
+       if ( passwd != NULL ) {
+               cred.bv_val = (char *) passwd;
+               cred.bv_len = strlen( passwd );
+       } else {
+               cred.bv_val = "";
+               cred.bv_len = 0;
+       }
+
+       return ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, &cred,
+               NULL, NULL, NULL );
+}
+
 /**
  * Attempt to discover the base DN for the server.
  * \param  host   Host name.
@@ -209,6 +225,7 @@ GList *ldaputil_read_basedn(
        GList *baseDN = NULL;
        LDAP *ld = NULL;
        gint rc;
+       gchar *uri = NULL;
 #ifdef USE_LDAP_TLS
        gint version;
 #endif
@@ -218,14 +235,12 @@ GList *ldaputil_read_basedn(
 
        /* Connect to server. */
 
-       if (!ssl) {
-               ld = ldap_init( host, port );
-       } else {
-               gchar *uri = g_strdup_printf("ldaps://%s:%d",
-                               host, port);
-               rc = ldap_initialize(&ld, uri);
-               g_free(uri);
-       }
+       uri = g_strdup_printf("ldap%s://%s:%d",
+                       ssl?"s":"",
+                       host, port);
+       rc = ldap_initialize(&ld, uri);
+       g_free(uri);
+       
        if( ld == NULL ) {
                return baseDN;
        }
@@ -235,12 +250,12 @@ GList *ldaputil_read_basedn(
                version = LDAP_VERSION3;
                rc = ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
                if( rc != LDAP_OPT_SUCCESS ) {
-                       ldap_unbind( ld );
+                       ldap_unbind_ext( ld, NULL, NULL );
                        return baseDN;
                }
                rc = ldap_start_tls_s( ld, NULL, NULL );
                if (rc != 0) {
-                       ldap_unbind( ld );
+                       ldap_unbind_ext( ld, NULL, NULL );
                        return baseDN;
                }
        }
@@ -249,9 +264,9 @@ GList *ldaputil_read_basedn(
        /* Bind to the server, if required */
        if( bindDN ) {
                if( *bindDN != '\0' ) {
-                       rc = ldap_simple_bind_s( ld, bindDN, bindPW );
+                       rc = claws_ldap_simple_bind_s( ld, bindDN, bindPW );
                        if( rc != LDAP_SUCCESS ) {
-                               ldap_unbind( ld );
+                               ldap_unbind_ext( ld, NULL, NULL );
                                return baseDN;
                        }
                }
@@ -264,7 +279,7 @@ GList *ldaputil_read_basedn(
                baseDN = ldaputil_test_v2( ld, tov );
        }
        if (ld && !LDAP_API_ERROR(rc))
-               ldap_unbind( ld );
+               ldap_unbind_ext( ld, NULL, NULL );
        
        return baseDN;
 }
@@ -283,16 +298,16 @@ gboolean ldaputil_test_connect( const gchar *host, const gint port, int ssl, int
        gint rc;
        gint version;
 #endif
+       gchar *uri = NULL;
+
        if( host == NULL ) return retVal;
        if( port < 1 ) return retVal;
-       if (!ssl) {
-               ld = ldap_open( host, port );
-       } else {
-               gchar *uri = g_strdup_printf("ldaps://%s:%d",
+       
+       uri = g_strdup_printf("ldap%s://%s:%d",
+                               ssl?"s":"",
                                host, port);
-               ldap_initialize(&ld, uri);
-               g_free(uri);
-       }
+       ldap_initialize(&ld, uri);
+       g_free(uri);
        if (ld == NULL)
                return FALSE;
 
@@ -310,19 +325,19 @@ gboolean ldaputil_test_connect( const gchar *host, const gint port, int ssl, int
                version = LDAP_VERSION3;
                rc = ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
                if( rc != LDAP_OPT_SUCCESS ) {
-                       ldap_unbind( ld );
+                       ldap_unbind_ext( ld, NULL, NULL );
                        return FALSE;
                }
 
                rc = ldap_start_tls_s( ld, NULL, NULL );
                if (rc != 0) {
-                       ldap_unbind( ld );
+                       ldap_unbind_ext( ld, NULL, NULL );
                        return FALSE;
                }
        }
 #endif
        if( ld != NULL ) {
-               ldap_unbind( ld );
+               ldap_unbind_ext( ld, NULL, NULL );
                retVal = TRUE;
        }
        return retVal;
index 2a5d24375ca11ff345651dc574ab993a7fcbb4b7..37590bf11a1d0023e01dec7ee1fda07d6f6c84e9 100644 (file)
 #ifdef USE_LDAP
 
 #include <glib.h>
-
+#include <ldap.h>
 /* Function Prototypes */
 GList *ldaputil_read_basedn    ( const gchar *host, const gint port,
                                  const gchar *bindDN, const gchar *bindPW,
                                  const gint tov, int ssl, int tls );
 gboolean ldaputil_test_connect ( const gchar *host, const gint port, int ssl, int tls);
 gboolean ldaputil_test_ldap_lib        ( void );
+int claws_ldap_simple_bind_s( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *passwd );
 
 #endif /* USE_LDAP */