From: <svn...@op...> - 2009-03-31 18:28:18
|
Author: scriptor Date: Tue Mar 31 20:28:14 2009 New Revision: 5494 URL: http://www.opensync.org/changeset/5494 Log: 1. Added/extended a workaround for buggy peers, that send an identifier which differs from what has been stored as value for the key attribute. The LDAP server does not accept such a discrepancy. 2. Extending error messages for a potential issue with either the one mentioned under 1. or with a new, possibly unrelated bug. 3. Preparation for debugging another bug: The format plugin gets sometimes called with an empty input (inpsize = 0). Here in ldap_plugin.c the size of the data is dumped to the trace files, that is to be delivered to osync_data_new(), whenever this function is about to be called, to prove which size of input is sent out by the LDAP plugin. The bug seems to be limited to objtypes event and todo. Probably an issue with the xmlformat plugin. Cf. test "osynctool_add_todo_xmlfile". Modified: plugins/ldap-sync/src/ldap_connect.c plugins/ldap-sync/src/ldap_plugin.c plugins/ldap-sync/src/ldap_plugin.h Modified: plugins/ldap-sync/src/ldap_connect.c ============================================================================== --- plugins/ldap-sync/src/ldap_connect.c Tue Mar 31 18:16:19 2009 (r5493) +++ plugins/ldap-sync/src/ldap_connect.c Tue Mar 31 20:28:14 2009 (r5494) @@ -3848,6 +3848,9 @@ if (!found_name) { osync_trace(TRACE_ERROR, "%s:%i: WARNING: Keyattribute \"%s\" could not be found.", __FILE__, __LINE__, sinkenv->keyattr); + ldap_plugin_printf("This happened with:"); + ldap_plugin_dump_ldap_attributes(entry); + ldap_plugin_printf("-------------"); } Modified: plugins/ldap-sync/src/ldap_plugin.c ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.c Tue Mar 31 18:16:19 2009 (r5493) +++ plugins/ldap-sync/src/ldap_plugin.c Tue Mar 31 20:28:14 2009 (r5494) @@ -1328,16 +1328,15 @@ to_be_reported->magic = "glist_container"; to_be_reported->list = list_to_be_reported; - - - - - - - - osync_assert(to_be_reported); + osync_trace(TRACE_INTERNAL, "%s:%i: sizeof(*to_be_reported) = %u", __FILE__, __LINE__, sizeof(*to_be_reported)); + if (sizeof(*to_be_reported) == 0) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sizeof(*to_be_reported) is 0.\n", __FILE__, __LINE__); + osync_change_unref(change); + goto error; + } + // HERE: From LDAP to "the framework": to_be_reported. odata = osync_data_new((char *)to_be_reported, sizeof(*to_be_reported), format_type, error); @@ -1515,6 +1514,8 @@ osync_objformat_set_validate_func(format, ldap_plugin_validate); + osync_trace(TRACE_INTERNAL, "%s:%i:%s(): osync_data_new() gets provided with NULL and size = 0, because this is OSYNC_CHANGE_TYPE_DELETED.", __FILE__, __LINE__, __func__); + OSyncData *odata = osync_data_new(NULL, 0, format, error); if (!odata) { if (!osync_error_is_set(error)) { @@ -2619,6 +2620,7 @@ + /** * @brief Prepare commitment of a to-be-deleted change struct. * Helper function for ldap_plugin_commit_change(). @@ -2675,8 +2677,7 @@ id = g_strdup((gchar*)osync_change_get_uid(change)); dn = g_strdup_printf("%s=%s,%s", sinkenv->keyattr, id, sinkenv->storebase); - - + #ifdef DEBUG_ldapdata_to_server ldap_plugin_printf("About to commit deletion for: \ndn = \"%s\"", dn); #endif @@ -2926,6 +2927,16 @@ continue; } + + // Workaround for buggy peers, that send an identifier which differs + // from what has been stored as value for the key attribute. + if (!ldap_plugin_check_for_keyattribute(sinkenv, entry, error)) { + if (!osync_error_is_set(error)) + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_check_for_keyattribute() has failed."); + + goto error; + } + int rv = ldap_add_ext_s (sinkenv->ld, entry->dn, entry->mods, NULL, NULL); if (rv != LDAP_SUCCESS && rv != LDAP_ALREADY_EXISTS) { @@ -3114,6 +3125,8 @@ *dn_of_modified_entry = g_strdup(entry->dn); } + + if (*dn_of_modified_entry == NULL) { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: *dn_of_modified_entry = NULL.", __FILE__, __LINE__); goto error; @@ -3183,6 +3196,18 @@ goto error; } + + // Make sure that the key attribute is present in the LDAP entry. + // And that its value is identical to the one that builds + // the identifier. + if (!ldap_plugin_check_for_keyattribute(sinkenv, entry, error)) { + if (!osync_error_is_set(error)) + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_check_for_keyattribute() has failed."); + + goto error; + } + + // Add this particular entry to the DIT res = ldap_add_ext_s (sinkenv->ld, entry->dn, entry->mods, NULL, NULL); @@ -3255,7 +3280,7 @@ // Should actually be moved into the format plugin. // But there are id and dn unknown. - // Make that the key attribute is present in the LDAP entry. + // Make sure that the key attribute is present in the LDAP entry. // And that its value is identical to the one that builds // the identifier. if (!ldap_plugin_check_for_keyattribute(sinkenv, entry, error)) { @@ -3381,6 +3406,11 @@ } + + + + + #ifdef DEBUG_change_type_modified osync_trace(TRACE_INTERNAL, "\n\n\n\n%s:%i:%s():\n*dn_of_modified_entry = \"%s\"", __FILE__, __LINE__, __func__, *dn_of_modified_entry); Modified: plugins/ldap-sync/src/ldap_plugin.h ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.h Tue Mar 31 18:16:19 2009 (r5493) +++ plugins/ldap-sync/src/ldap_plugin.h Tue Mar 31 20:28:14 2009 (r5494) @@ -82,6 +82,7 @@ #define OPENSYNC_DEBUG_MODULES 1 // define DISABLE_SET_SLOWSYNC 1 // define NO_OUTPUT_TO_SCREEN 1 +// define CALL_ABORT 1 #define DEBUG_auth 1 #define DEBUG_configuration 1 |