talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 2df2dd438ffc7f89ea31cdc1b05dba93944bf2a4
parent 89d51acb79e8a84791f1eac0ff466c738fe21f96
Author: Colin Leroy <colin@colino.net>
Date:   Fri, 16 May 2008 07:00:57 +0000

2008-05-16 [colin]	3.4.0cvs44

	* configure.ac
	* src/ldapupdate.c
		Fix ldap deprecated calls. Patch by
		Michael Rasmussen

Diffstat:
MChangeLog | 7+++++++
MPATCHSETS | 1+
Mconfigure.ac | 25++++++++++++++++++++++++-
Msrc/ldapupdate.c | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
4 files changed, 96 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,10 @@ +2008-05-16 [colin] 3.4.0cvs44 + + * configure.ac + * src/ldapupdate.c + Fix ldap deprecated calls. Patch by + Michael Rasmussen + 2008-05-16 [paul] 3.4.0cvs43 * manual/de/account.xml diff --git a/PATCHSETS b/PATCHSETS @@ -3339,3 +3339,4 @@ ( cvs diff -u -r 1.9.2.21 -r 1.9.2.22 src/gtk/sslcertwindow.c; ) > 3.4.0cvs41.patchset ( cvs diff -u -r 1.9.2.22 -r 1.9.2.23 src/gtk/sslcertwindow.c; ) > 3.4.0cvs42.patchset ( diff -u /dev/null manual/de/account.xml; diff -u /dev/null manual/it/account.xml; diff -u /dev/null manual/it/ack.xml; diff -u /dev/null manual/it/addrbook.xml; diff -u /dev/null manual/it/claws-mail-manual.xml; diff -u /dev/null manual/it/gpl.xml; diff -u /dev/null manual/it/intro.xml; diff -u /dev/null manual/it/starting.xml; ) > 3.4.0cvs43.patchset +( cvs diff -u -r 1.654.2.3400 -r 1.654.2.3401 configure.ac; cvs diff -u -r 1.1.2.19 -r 1.1.2.20 src/ldapupdate.c; ) > 3.4.0cvs44.patchset diff --git a/configure.ac b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=4 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=43 +EXTRA_VERSION=44 EXTRA_RELEASE= EXTRA_GTK2_VERSION= @@ -660,6 +660,29 @@ else if test "$ac_cv_have_tls" = yes; then AC_DEFINE(USE_LDAP_TLS, 1, Define if you want LDAP TLS support in addressbook.) fi + dnl As of OpenLDAP API version 3000 a number of functions has + dnl been deprecated. As Claws-mail compiles and runs on many + dnl platforms and many versions of OpenLDAP we need to be able + dnl to switch between the old and new API because new API has + dnl added new functions replacing old ones and at the same time + dnl old functions has been changed. + dnl If cross-compiling defaults to enable deprecated features + dnl for maximum portability + AC_MSG_CHECKING([The API version of OpenLDAP]) + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [#include <ldap.h>], + [if (LDAP_API_VERSION >= 3000) + return 1 + ])], + [AC_MSG_RESULT([version < 3000]) + AC_DEFINE(OPEN_LDAP_API_AT_LEAST_3000, 0, Define if OpenLDAP API is at least version 3000.)], + [AC_MSG_RESULT([version >= 3000]) + AC_DEFINE(OPEN_LDAP_API_AT_LEAST_3000, 1, Define if OpenLDAP API is at least version 3000.)], + [AC_MSG_RESULT([Enabling deprecated features in OpenLDAP]) + AC_DEFINE(OPEN_LDAP_API_AT_LEAST_3000, 0, Define if OpenLDAP API is at least version 3000.) + AC_DEFINE(LDAP_DEPRECATED, 1, Define to activate deprecated features in OpenLDAP)] + ) fi fi diff --git a/src/ldapupdate.c b/src/ldapupdate.c @@ -39,8 +39,6 @@ #ifdef USE_LDAP -#define LDAP_DEPRECATED 1 - #include <glib.h> #include <glib/gi18n.h> #include <sys/time.h> @@ -710,13 +708,33 @@ void ldapsvr_print_ldapmod(LDAPMod *mods[]) { */ void ldapsvr_compare_attr(LDAP *ld, gchar *dn, gint cnt, LDAPMod *mods[]) { int i, rc; - + +#ifdef OPEN_LDAP_API_AT_LEAST_3000 + + struct berval val; + +#endif + g_return_if_fail(ld != NULL || dn != NULL || cnt >= 0 || mods != NULL); for (i = 0; i < cnt; i++) { gchar *value = g_strdup(mods[i]->mod_vals.modv_strvals[0]); if (!value || strcmp(value, "") == 0) value = g_strdup("thisisonlyadummy"); + +#ifdef OPEN_LDAP_API_AT_LEAST_3000 + + val.bv_val = value; + val.bv_len = strlen(value); + + rc = ldap_compare_ext_s(ld, dn, mods[i]->mod_type, &val, NULL, NULL); + +#else + + /* This is deprecated as of OpenLDAP-2.3.0 */ rc = ldap_compare_s(ld, dn, mods[i]->mod_type, value); + +#endif + g_printerr("ldap_compare for (%s:%s)\" failed[0x%x]: %s\n", mods[i]->mod_type, value, rc, ldap_err2string(rc)); g_free(value); @@ -752,7 +770,18 @@ int ldapsvr_compare_manual_attr(LDAP *ld, LdapServer *server, gchar *dn, char *a filter = g_strdup_printf("(&(mail=%s)(%s=*))", mail->value, attr); attrkeyvalue_free(mail); if (ctl) { - rc = ldap_search_s(ld, ctl->baseDN, /*LDAP_SCOPE_SUBTREE*/LDAP_SCOPE_ONELEVEL, filter, NULL, 0, &res); + +#ifdef OPEN_LDAP_API_AT_LEAST_3000 + + rc = ldap_search_ext_s(ld, ctl->baseDN, LDAP_SCOPE_ONELEVEL, filter, NULL, 0, NULL, NULL, NULL, 0, &res); + +#else + + /* This is deprecated as of OpenLDAP-2.3.0 */ + rc = ldap_search_s(ld, ctl->baseDN, LDAP_SCOPE_ONELEVEL, filter, NULL, 0, &res); + +#endif + if (rc) { g_printerr("ldap_search for attr=%s\" failed[0x%x]: %s\n",attr, rc, ldap_err2string(rc)); retVal = -2; @@ -817,6 +846,12 @@ int ldapsvr_deside_operation(LDAP *ld, LdapServer *server, char *dn, char *attr, int rc; gboolean dummy = FALSE; +#ifdef OPEN_LDAP_API_AT_LEAST_3000 + + struct berval val; + +#endif + g_return_val_if_fail(ld != NULL || server != NULL || dn != NULL || attr != NULL, -1); if (value == NULL) return -1; @@ -827,7 +862,21 @@ int ldapsvr_deside_operation(LDAP *ld, LdapServer *server, char *dn, char *attr, value = g_strdup("thisisonlyadummy"); dummy = TRUE; } + +#ifdef OPEN_LDAP_API_AT_LEAST_3000 + + val.bv_val = value; + val.bv_len = strlen(value); + + rc = ldap_compare_ext_s(ld, dn, attr, &val, NULL, NULL); + +#else + + /* This is deprecated as of OpenLDAP-2.3.0 */ rc = ldap_compare_s(ld, dn, attr, value); + +#endif + debug_print("ldap_compare for (%s:%s)\" error_code[0x%x]: %s\n", attr, value, rc, ldap_err2string(rc)); switch (rc) { @@ -1162,7 +1211,18 @@ void ldapsvr_update_contact(LdapServer *server, GHashTable *contact) { if (NoRemove) { /* We are trying to change RDN */ gchar *newRdn = g_strdup_printf("%s=%s", NoRemove->attribute, NoRemove->value); + +#ifdef OPEN_LDAP_API_AT_LEAST_3000 + + int rc = ldap_rename_s(ld, dn, newRdn, NULL, 1, NULL, NULL); + +#else + + /* This is deprecated as of OpenLDAP-2.3.0 */ int rc = ldap_modrdn2_s(ld, dn, newRdn, 1); + +#endif + if(rc != LDAP_SUCCESS) { if (rc == LDAP_ALREADY_EXISTS) { /* We are messing with a contact with more than one listed email