You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
(56) |
Apr
(109) |
May
(15) |
Jun
(3) |
Jul
(37) |
Aug
(96) |
Sep
(40) |
Oct
(4) |
Nov
(54) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(47) |
Feb
(30) |
Mar
(102) |
Apr
(120) |
May
(68) |
Jun
(54) |
Jul
(53) |
Aug
(122) |
Sep
(190) |
Oct
(71) |
Nov
(85) |
Dec
(108) |
2007 |
Jan
(72) |
Feb
(190) |
Mar
(53) |
Apr
(101) |
May
(145) |
Jun
(148) |
Jul
(167) |
Aug
(143) |
Sep
(23) |
Oct
(198) |
Nov
(223) |
Dec
(195) |
2008 |
Jan
(100) |
Feb
(129) |
Mar
(79) |
Apr
(77) |
May
(34) |
Jun
(95) |
Jul
(112) |
Aug
(160) |
Sep
(82) |
Oct
(124) |
Nov
(199) |
Dec
(355) |
2009 |
Jan
(436) |
Feb
(89) |
Mar
(298) |
Apr
(189) |
May
(33) |
Jun
(88) |
Jul
(105) |
Aug
(44) |
Sep
(181) |
Oct
(87) |
Nov
(75) |
Dec
(1) |
2010 |
Jan
(63) |
Feb
(21) |
Mar
(3) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(26) |
Aug
(37) |
Sep
(26) |
Oct
(15) |
Nov
(13) |
Dec
|
From: <svn...@op...> - 2010-01-10 18:56:33
|
Author: dgollub Date: Sun Jan 10 19:56:22 2010 New Revision: 5999 URL: http://www.opensync.org/changeset/5999 Log: Added some simple plugin configuration with resources configuration. Even that resources configuration is optional. Most plugin starts might want to start with hardcoded resources configuration. fixes #922 Modified: trunk/docs/examples/plugins/src/plugin-name Modified: trunk/docs/examples/plugins/src/plugin-name ============================================================================== --- trunk/docs/examples/plugins/src/plugin-name Sun Jan 10 19:50:28 2010 (r5998) +++ trunk/docs/examples/plugins/src/plugin-name Sun Jan 10 19:56:22 2010 (r5999) @@ -1 +1,14 @@ -This file will hold the default configuration options of your plugin. \ No newline at end of file +<?xml version="1.0"?> +<config version="1.0"> +<Resources> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name><objformat></Name> <!-- example: vcard21 --> + </Format> + </Formats> + <ObjType><objtype></ObjType> <!-- example: contact --> + </Resource> +</Resources> +</config> |
From: <svn...@op...> - 2010-01-10 18:50:39
|
Author: dgollub Date: Sun Jan 10 19:50:28 2010 New Revision: 5998 URL: http://www.opensync.org/changeset/5998 Log: Drop fail() calls which require libcheck linking. Drop libcheck link. This allows sane Debian packaging. fixes #833 Modified: trunk/tests/mock-plugin/CMakeLists.txt trunk/tests/mock-plugin/mock_sync.c Modified: trunk/tests/mock-plugin/CMakeLists.txt ============================================================================== --- trunk/tests/mock-plugin/CMakeLists.txt Sun Jan 10 19:38:05 2010 (r5997) +++ trunk/tests/mock-plugin/CMakeLists.txt Sun Jan 10 19:50:28 2010 (r5998) @@ -3,7 +3,7 @@ OPENSYNC_PLUGIN_ADD( mock-sync mock_sync.c ) OPENSYNC_FORMAT_ADD( mock-format mock_format.c ) -TARGET_LINK_LIBRARIES( mock-sync opensync ${CHECK_LIBRARIES} ) +TARGET_LINK_LIBRARIES( mock-sync opensync ) TARGET_LINK_LIBRARIES( mock-format opensync ) ###### INSTALL ################### Modified: trunk/tests/mock-plugin/mock_sync.c ============================================================================== --- trunk/tests/mock-plugin/mock_sync.c Sun Jan 10 19:38:05 2010 (r5997) +++ trunk/tests/mock-plugin/mock_sync.c Sun Jan 10 19:50:28 2010 (r5998) @@ -253,10 +253,10 @@ osync_assert(osync_file_write(filename, file->data, file->size, file->mode, &error)); break; case OSYNC_CHANGE_TYPE_UNMODIFIED: - fail("Unmodified in a change function?!"); + osync_assert_msg(FALSE, "Unmodified in a change function?!"); break; case OSYNC_CHANGE_TYPE_UNKNOWN: - fail("Unknown Change Type"); + osync_assert_msg(FALSE, "Unknown Change Type"); break; } |
From: <svn...@op...> - 2010-01-10 18:38:15
|
Author: dgollub Date: Sun Jan 10 19:38:05 2010 New Revision: 5997 URL: http://www.opensync.org/changeset/5997 Log: Avoid assert() if no mapping entry got found. This patch is orignally from scriptor, slightly adapted by dgollub. fixes #1093 Modified: trunk/opensync/engine/opensync_mapping_engine.c Modified: trunk/opensync/engine/opensync_mapping_engine.c ============================================================================== --- trunk/opensync/engine/opensync_mapping_engine.c Sun Jan 10 19:27:36 2010 (r5996) +++ trunk/opensync/engine/opensync_mapping_engine.c Sun Jan 10 19:38:05 2010 (r5997) @@ -599,6 +599,11 @@ osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, engine, change); entry = _osync_mapping_engine_find_entry(engine, change); + if (!entry) { + osync_trace(TRACE_ERROR, "%s(): ERROR: _osync_mapping_engine_find_entry() didn't find any entry. engine = %p, change = %p", __func__, engine, change); + osync_error_set(error, OSYNC_ERROR_GENERIC, "Couldn't find mapping entry for change \"%s\"", osync_change_get_uid(change)); + goto error; + } engine->conflict = FALSE; osync_mapping_engine_set_master(engine, entry); osync_status_update_mapping(engine->parent->parent, engine, OSYNC_ENGINE_MAPPING_EVENT_SOLVED, NULL); |
From: <svn...@op...> - 2010-01-10 18:27:51
|
Author: scriptor Date: Sun Jan 10 19:27:36 2010 New Revision: 5996 URL: http://www.opensync.org/changeset/5996 Log: I have added support for SSL/TLS when libldap60 from the Mozilla LDAP C SDK is used. In this case certain SSL/TLS related steps have to be taken from inside the LDAP plugin, whereas this is not necessary when the plugin is linked against libldap from openldap. When the LDAP server to be used is slapd from openldap, then it is better 1. to link the LDAP plugin against libldap from openldap and 2. to use the openssl utilities ( http://www.openssl.org/ ) for the configuration. Whereas, when is the LDAP server is ns-slapd (= 389 Directory Server = Fedora Directory Server), then it is better 1. to link the LDAP plugin against libldap60 from the Mozilla LDAP C SDK and 2. to use certutil etc. from the "Network Security Services (NSS)" ("nss-tools" package under fedora/redhat) for configuration purposes. At least, as far as SSL/TLS is concerned, it seems, that it is not possible, to cross this line by intermixing the different libraries and certificates/keys. With the NSS libraries talking to an openldap LDAP server, protocol errors occur. Whereas with the openldap libraries talking to ns-slapd (389-ds = fedora-ds), the protocol seems to be ok, but the configuration is difficult. The openssl certificates do not seem to be accepted by the NSS side ("Bad certificate"). However, my last word on this has not been spoken, yet. Added: plugins/ldap-sync/src/ldap_ssl.c Modified: plugins/ldap-sync/src/ldap-sync plugins/ldap-sync/src/ldap_connect.c plugins/ldap-sync/src/ldap_plugin.c plugins/ldap-sync/src/ldap_plugin.h plugins/ldap-sync/src/ldap_sasl.c Modified: plugins/ldap-sync/src/ldap-sync ============================================================================== --- plugins/ldap-sync/src/ldap-sync Sun Jan 10 19:26:47 2010 (r5995) +++ plugins/ldap-sync/src/ldap-sync Sun Jan 10 19:27:36 2010 (r5996) @@ -33,6 +33,36 @@ </AdvancedOption> <AdvancedOption> + <Name>mozldap_tls_certdb</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + + <AdvancedOption> + <Name>mozldap_tls_certnickname</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + + <AdvancedOption> + <Name>mozldap_tls_keydb</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + + <AdvancedOption> + <Name>mozldap_tls_keynickname</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + + <AdvancedOption> + <Name>mozldap_tls_keypassword</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + + <AdvancedOption> <!-- Anonymous bind --> <Name>anonymous</Name> <Type>string</Type> Modified: plugins/ldap-sync/src/ldap_connect.c ============================================================================== --- plugins/ldap-sync/src/ldap_connect.c Sun Jan 10 19:26:47 2010 (r5995) +++ plugins/ldap-sync/src/ldap_connect.c Sun Jan 10 19:27:36 2010 (r5996) @@ -147,7 +147,17 @@ ldap_initialize(&(sinkenv->ld), sinkenv->servername); #else # ifdef USE_MOZLDAP - sinkenv->ld = ldap_init(sinkenv->servername, sinkenv->serverport); + if (sinkenv->encryption == TRUE) { + if (!ldap_plugin_prepare_mozldap_ssl(ctx, sinkenv, error)) { + if (!osync_error_is_set(error)) { + osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: ldap_plugin_prepare_mozldap_ssl() has failed.\n", __FILE__, __LINE__); + } + + goto error; + } + } else { + sinkenv->ld = ldap_init(sinkenv->servername, sinkenv->serverport); + } // if (sinkenv->encryption == TRUE) # else sinkenv->ld = NULL; # endif @@ -158,15 +168,10 @@ goto error; } - } else { - - if (sinkenv->encryption == FALSE) { - sinkenv->url = g_strdup_printf("%s://%s:%i", sinkenv->protocol, sinkenv->servername, sinkenv->serverport); - - } else { - sinkenv->url = g_strdup_printf("%s://%s:%i", sinkenv->protocol, sinkenv->servername, sinkenv->serverport); - } + + } else { // if (ldap_is_ldap_url) + sinkenv->url = g_strdup_printf("%s://%s:%i", sinkenv->protocol, sinkenv->servername, sinkenv->serverport); osync_trace(TRACE_INTERNAL, "%s:%i: INFO: url = \"%s\"\n", __FILE__, __LINE__, sinkenv->url); @@ -175,17 +180,28 @@ ldap_initialize(&(sinkenv->ld), sinkenv->url); #else # ifdef USE_MOZLDAP - sinkenv->ld = ldap_init(sinkenv->servername, sinkenv->serverport); + if (sinkenv->encryption == TRUE) { + + if (!ldap_plugin_prepare_mozldap_ssl(ctx, sinkenv, error)) { + if (!osync_error_is_set(error)) { + osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: ldap_plugin_check_ldap_schema_support() has failed.\n", __FILE__, __LINE__); + } + + goto error; + } + } else { + sinkenv->ld = ldap_init(sinkenv->servername, sinkenv->serverport); + } # else sinkenv->ld = NULL; -#endif +# endif #endif if (sinkenv->ld == NULL ) { - osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "Could not connect to \"%s\"", sinkenv->url); + osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: ERROR: Could not connect to \"%s\"", __FILE__, __LINE__, sinkenv->url); goto error; } } @@ -195,11 +211,9 @@ error: - if (!osync_error_is_set(error)) osync_error_set(error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); - osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return FALSE; } @@ -474,21 +488,16 @@ // Set LDAP version on created connection - ldap_plugin_set_ldap_protocol(ctx, info, sinkenv, &error); + ldap_plugin_set_ldap_protocol(ctx, sinkenv, &error); - // Set encryption on the LDAP connection, if requested, - // provided that the protocol chosen does NOT contain this - // information, yet; i.e., it MUST NOT be equal to "ldaps": if (sinkenv->encryption) { - if (strcmp(sinkenv->protocol, "ldaps")) { - if (!ldap_plugin_encrypt_connection(ctx, sinkenv, &error)) { - if (!osync_error_is_set(&error)) { - osync_error_set(&error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: ERROR: Could not start encryption.\n", __FILE__, __LINE__); - } - - goto error; + if (!ldap_plugin_setup_encryption(ctx, sinkenv, &error)) { + if (!osync_error_is_set(&error)) { + osync_error_set(&error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: ldap_plugin_setup_encryption() has failed.", __FILE__, __LINE__); } + + goto error; } } @@ -505,6 +514,9 @@ + // The hash values for the opensync database are based on the + // entryCSN attribute. If it cannot be found we will fall back to + // the modifyTimestamp attribute. if (!ldap_plugin_check_for_entryCSN(ctx, sinkenv, &error)) { if (!osync_error_is_set(&error)) { osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_check_for entryCSN() has failed.", __FILE__, __LINE__); @@ -700,11 +712,11 @@ * * @returns TRUE on success, FALSE on error */ -osync_bool ldap_plugin_set_ldap_protocol (OSyncContext *ctx, OSyncPluginInfo *info, sink_environment *sinkenv, OSyncError **error) +osync_bool ldap_plugin_set_ldap_protocol (OSyncContext *ctx, sink_environment *sinkenv, OSyncError **error) { int *ldap_protocol_version = NULL; - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, (void *)ctx, (void *)info, (void *)sinkenv, (void *)error); + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, (void *)ctx, (void *)sinkenv, (void *)error); if (ctx == NULL) { @@ -712,12 +724,6 @@ goto error; } - - if (info == NULL) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: info = NULL. Returning.\n", __FILE__, __LINE__); - goto error; - } - if (sinkenv == NULL) { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sinkenv = NULL. Returning.\n", __FILE__, __LINE__); goto error; @@ -772,65 +778,6 @@ -/** - * @brief Encrypts the connection to the LDAP server by using TLS/SSL. - * - * @param ctx The libopensync context. - * @param sinkenv The object type specific environment. - * @param error The libopensync error pointer. - * - * @returns TRUE on success, FALSE in case of any error. - */ - -osync_bool ldap_plugin_encrypt_connection (OSyncContext *ctx, sink_environment *sinkenv, OSyncError **error) -{ - int ldap_errno = 0; - - - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, (void *)ctx, (void *)sinkenv, (void *)error); - - - if (ctx == NULL) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ctx = NULL. Returning.\n", __FILE__, __LINE__); - goto error; - } - - - if (sinkenv == NULL) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sinkenv = NULL. Returning.\n", __FILE__, __LINE__); - goto error; - } - - - ldap_errno = ldap_start_tls_s(sinkenv->ld, NULL, NULL); - if (ldap_errno != LDAP_SUCCESS) { - char *ldap_error = ldap_plugin_report_ldap_error(sinkenv, __FILE__, __LINE__, ldap_errno); - - - if (ldap_error == NULL) { - osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: ERROR: ldap_start_tls_s() has failed. Could not establish a connection to the LDAP server \"%s\", therefore.\n", __FILE__, __LINE__, sinkenv->url ? sinkenv->url : sinkenv->servername); - } else { - osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: ERROR: ldap_start_tls_s() has failed. Could not establish a connection to the LDAP server \"%s\", therefore: \"%s\"\n", __FILE__, __LINE__, sinkenv->url ? sinkenv->url : sinkenv->servername, ldap_error); - } - - goto error; - } - - - osync_trace(TRACE_EXIT, "%s", __func__); - return TRUE; - - -error: - if (!osync_error_is_set(error)) - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); - - osync_context_report_osyncerror(ctx, *error); - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; -} - - /** @@ -962,6 +909,30 @@ tmp_authzid = g_strdup(authzid); tmp_realm = g_strdup(realm); + + if (tmp_authmech == NULL) { + osync_trace(TRACE_ERROR, "%s:%i: WARNING: tmp_authmech = NULL. Setting it to \"SIMPLE\".", __FILE__, __LINE__); + tmp_authmech = g_strdup("SIMPLE"); + + if (tmp_authmech == NULL) { + osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: ERROR: tmp_authmech is still NULL. Giving up.", __FILE__, __LINE__); + rv = FALSE; + goto out1; + } + } + + if (tmp_authmech[0] == 0) { + osync_trace(TRACE_ERROR, "%s:%i: WARNING: tmp_authmech is a empty string. Setting it to \"SIMPLE\".", __FILE__, __LINE__); + g_free(tmp_authmech); + + tmp_authmech = g_strdup("SIMPLE"); + + if (tmp_authmech == NULL) { + osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: ERROR: tmp_authmech is still NULL. Giving up.", __FILE__, __LINE__); + rv = FALSE; + goto out1; + } + } // Load default parameters into a libldap specific struct defaults = ldap_plugin_lutil_sasl_defaults(sinkenv->ld, tmp_authmech, tmp_realm, tmp_authcid, passwd.bv_val, tmp_authzid); @@ -973,8 +944,61 @@ // Try and bind with the LDAP server +#ifdef USE_MOZLDAP + // Currently this is called in both cases: STARTTLS and LDAP over SSL. + + if (!strcmp(tmp_authmech, "EXTERNAL")) { +#ifdef DEBUG_ssl + ldap_plugin_printf("%s:%i: USE_MOZLDAP and EXTERNAL: Right before ldap_plugin_setup_mozldap_ssl_authentication()\n", __FILE__, __LINE__); +#endif + if (!ldap_plugin_setup_mozldap_ssl_authentication(ctx, sinkenv, error)) { + if (!osync_error_is_set(error)) + osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: ERROR: ldap_plugin_setup_mozldap_ssl_authentication() has failed.\n", __FILE__, __LINE__); + + rv = FALSE; + goto out1; + } + +#ifdef DEBUG_ssl + ldap_plugin_printf("%s:%i: USE_MOZLDAP and EXTERNAL: Right before ldap_sasl_bind_s\n", __FILE__, __LINE__); +#endif + + ldap_errno = ldap_sasl_bind_s(sinkenv->ld, NULL, LDAP_SASL_EXTERNAL, NULL, NULL, NULL, NULL); + +#ifdef DEBUG_ssl + ldap_plugin_printf("%s:%i: USE_MOZLDAP and EXTERNAL: Right after ldap_sasl_bind_s\n", __FILE__, __LINE__); +#endif + + } else { +#ifdef DEBUG_ssl + ldap_plugin_printf("%s:%i: USE_MOZLDAP: Right before ldap_sasl_interactive_bind_s\n", __FILE__, __LINE__); +#endif + + ldap_errno = ldap_sasl_interactive_bind_s(sinkenv->ld, NULL, tmp_authmech, NULL, NULL, sasl_flags, (LDAP_SASL_INTERACT_PROC *)ldap_plugin_lutil_sasl_interact, (void *)defaults); + + } + + + + +#else + +#ifdef DEBUG_ssl + ldap_plugin_printf("%s:%i: USE_OPENLDAP: Right before ldap_sasl_interactive_bind_s\n", __FILE__, __LINE__); +#endif + ldap_errno = ldap_sasl_interactive_bind_s(sinkenv->ld, NULL, tmp_authmech, NULL, NULL, sasl_flags, (LDAP_SASL_INTERACT_PROC *)ldap_plugin_lutil_sasl_interact, (void *)defaults); + // ldap_errno = ldap_sasl_bind_s(sinkenv->ld, NULL, tmp_authmech, NULL, NULL, NULL, NULL); + +#endif + + +#ifdef DEBUG_ssl + ldap_plugin_printf("%s:%i: ldap_errno = %i\n", __FILE__, __LINE__, ldap_errno); +#endif + + if (ldap_errno != LDAP_SUCCESS) { char *ldap_error = ldap_plugin_report_ldap_error(sinkenv, __FILE__, __LINE__, ldap_errno); @@ -1032,7 +1056,9 @@ } - if (passwd.bv_len == 0) { + // Give hint about empty password only for authentication mechanisms + // other than EXTERNAL + if (passwd.bv_len == 0 && strcmp(tmp_authmech, "EXTERNAL")) { if (ldap_error == NULL) { osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: Unable to connect and sasl bind with \"%s\" as \"%s\" with an empty password, using \"%s\" as authentication mechanism. Maybe the LDAP server does not allow an anonymous bind.", __FILE__, __LINE__, sinkenv->url ? sinkenv->url : sinkenv->servername, sinkenv->authcid, tmp_authmech); } else { @@ -1139,7 +1165,6 @@ if (!osync_error_is_set(error)) osync_error_set(error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); - osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); } @@ -1171,8 +1196,9 @@ { LDAPMessage *res = NULL, *res2 = NULL, *res3 = NULL, *res4 = NULL; int i = 0; - struct berval **ber = NULL, **ber2 = NULL; - char *search_base = NULL; + struct berval **ber = NULL, **ber2 = NULL; + BerElement *ber3 = NULL; + char *search_base = NULL, *attr = NULL; osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p)", __func__, (void *)ctx, (void *)sinkenv, (void *)ldap_schema, (void *)result, (void *)error); @@ -1209,7 +1235,12 @@ // Get the relevant search_base. It may differ from server to server. - if (!ldap_plugin_call_ldap_search(ctx, sinkenv->ld, "", "(objectClass=*)", LDAP_SCOPE_BASE, OPERATIONAL_ATTRIBUTES, sinkenv, TRUE, &res3, error)) { +#ifdef USE_MOZLDAP + if (!ldap_plugin_call_ldap_search(ctx, sinkenv->ld, "", "(objectClass=*)", LDAP_SCOPE_BASE, FEDORADSsubschemaSubentry, sinkenv, TRUE, &res3, error)) +#else + if (!ldap_plugin_call_ldap_search(ctx, sinkenv->ld, "", "(objectClass=*)", LDAP_SCOPE_BASE, OPERATIONAL_ATTRIBUTES, sinkenv, TRUE, &res3, error)) +#endif + { if (!osync_error_is_set(error)) { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_call_ldap_search() has failed.\n", __FILE__, __LINE__); } @@ -1228,31 +1259,87 @@ } - res4 = ldap_first_entry(sinkenv->ld, res3); - if (res4) { - ber2 = ldap_get_values_len(sinkenv->ld, res4, "subschemaSubentry"); - if (ber2) { - while (ber2[i]) { - if (ber2[i]->bv_val) { - search_base = g_strdup(ber2[i]->bv_val); - break; + for (res4 = ldap_first_entry(sinkenv->ld, res3); + res4 != NULL; + res4 = ldap_next_entry(sinkenv->ld, res3)) + { + if (res4) { +#ifdef DEBUG_subschema_discovery + char *dn = ldap_get_dn(sinkenv->ld, res4); + + + if (dn) { + ldap_plugin_printf("%s:%i: dn = \"%s\"\n", __FILE__, __LINE__, dn); + ldap_memfree(dn); + dn = NULL; + } +#endif + + for (attr = ldap_first_attribute(sinkenv->ld, res4, &ber3); + attr != NULL; + attr = ldap_next_attribute(sinkenv->ld, res4, ber3) + ) + { +#ifdef DEBUG_subschema_discovery + ldap_plugin_printf("%s:%i: %s: ", __FILE__, __LINE__, attr ? attr : "NULL."); +#endif + + if (strcmp(attr, "subschemaSubentry")) { +#ifdef DEBUG_subschema_discovery + ldap_plugin_printf("\n"); +#endif + continue; } - i++; - } - } - } + ber2 = ldap_get_values_len(sinkenv->ld, res4, attr); + if (ber2) { + i = 0; + while (ber2[i]) { + if (ber2[i]->bv_val) { +#ifdef DEBUG_subschema_discovery + ldap_plugin_printf("%s ", ber2[i]->bv_val); +#endif + search_base = g_strdup(ber2[i]->bv_val); + break; + } + i++; + } // while (ber2[i]) + +#ifdef DEBUG_subschema_discovery + ldap_plugin_printf("\n-------------------------\n"); +#endif + if (search_base != NULL && search_base[0] != 0) { + break; + } + } else { + ldap_plugin_printf("%s:%i: WARNING: ber2 = NULL.", __FILE__, __LINE__); + } + + ldap_memfree(attr); + } + + if (search_base != NULL && search_base[0] != 0) { + break; + } + } + } - // We haven't found the real search_base. So let's assume, it is - // "cn=Subschema". + + // We haven't found the real search_base, yet. So let's assume, it is + // "cn=Subschema" or "cn=schema" for ns-slapd. if (search_base == NULL) { - osync_trace(TRACE_INTERNAL, "%s:%i: WARNING: search_base = NULL. Setting it to \"cn=Subschema\".", __FILE__, __LINE__); +#ifdef USE_MOZLDAP + ldap_plugin_printf("%s:%i: WARNING: search_base = NULL. Setting it to \"cn=schema\".", __FILE__, __LINE__); + search_base = g_strdup("cn=schema"); +#else + ldap_plugin_printf("%s:%i: WARNING: search_base = NULL. Setting it to \"cn=Subschema\".", __FILE__, __LINE__); search_base = g_strdup("cn=Subschema"); +#endif } @@ -1277,8 +1364,10 @@ res2 = ldap_first_entry(sinkenv->ld, res); if (!res2) { /* No objectClass entries found */ - if (res) + if (res) { ldap_msgfree(res); + res = NULL; + } // Look for all the LDAP schemata (as used by ns-slapd from the // fedora directory server): @@ -1331,6 +1420,9 @@ if (res) ldap_msgfree(res); + if (res3) + ldap_msgfree(res3); + if (search_base) g_free(search_base); @@ -1346,6 +1438,9 @@ if (res) ldap_msgfree(res); + if (res3) + ldap_msgfree(res3); + if (search_base) g_free(search_base); @@ -1573,6 +1668,9 @@ const char *scope_str = NULL; const char *userattributes[2]; userattributes[1] = NULL; + char *msg = NULL; + int rv = 0; + if (results == NULL) { @@ -1588,8 +1686,12 @@ // openldap version userattributes[0] = LDAP_ALL_USER_ATTRIBUTES; #else +# ifdef LDAP_ALL_USER_ATTRS // mozldap version + userattributes[0] = LDAP_ALL_USER_ATTRS; +# else userattributes[0] = NULL; +# endif #endif break; @@ -1611,21 +1713,27 @@ userattributes[0] = "modifyTimestamp"; break; + case FEDORADSsubschemaSubentry: + userattributes[0] = "subschemaSubentry"; + break; + default: #ifdef LDAP_ALL_USER_ATTRIBUTES // openldap version userattributes[0] = LDAP_ALL_USER_ATTRIBUTES; #else - // xxx jl: TODO ??????????????? + +# ifdef LDAP_ALL_USER_ATTRS // mozldap version + userattributes[0] = LDAP_ALL_USER_ATTRS; +# else userattributes[0] = NULL; +# endif + #endif }; - char *msg = NULL; - int rv = 0; - if (ldap_handle == NULL) { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_handle = NULL.\n", __FILE__, __LINE__); Modified: plugins/ldap-sync/src/ldap_plugin.c ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.c Sun Jan 10 19:26:47 2010 (r5995) +++ plugins/ldap-sync/src/ldap_plugin.c Sun Jan 10 19:27:36 2010 (r5996) @@ -666,6 +666,10 @@ sinkenv->authcid = NULL; sinkenv->authzid = NULL; sinkenv->realm = NULL; + sinkenv->mozldap_tls_certdb = NULL; + sinkenv->mozldap_tls_certnickname = NULL; + sinkenv->mozldap_tls_keydb = NULL; + sinkenv->mozldap_tls_keynickname = NULL; // also known as "token name" sinkenv->searchbase = NULL; sinkenv->searchfilter = NULL; sinkenv->storebase = NULL; @@ -739,6 +743,21 @@ if (!strcmp(name, "realm")) sinkenv->realm = g_strdup(val); + if (!strcmp(name, "mozldap_tls_certdb")) + sinkenv->mozldap_tls_certdb = g_strdup(val); + + if (!strcmp(name, "mozldap_tls_certnickname")) + sinkenv->mozldap_tls_certnickname = g_strdup(val); + + if (!strcmp(name, "mozldap_tls_keydb")) + sinkenv->mozldap_tls_keydb = g_strdup(val); + + if (!strcmp(name, "mozldap_tls_keynickname")) + sinkenv->mozldap_tls_keynickname = g_strdup(val); + + if (!strcmp(name, "mozldap_tls_keypassword")) + sinkenv->mozldap_tls_keypassword = g_strdup(val); + if (!strcmp(name, "anonymous")) { #ifdef DEBUG_auth ldap_plugin_printf("%s:%i: Previous setting of anonymous was: %i", __FILE__, __LINE__, sinkenv->anonymous); Modified: plugins/ldap-sync/src/ldap_plugin.h ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.h Sun Jan 10 19:26:47 2010 (r5995) +++ plugins/ldap-sync/src/ldap_plugin.h Sun Jan 10 19:27:36 2010 (r5996) @@ -161,6 +161,8 @@ ///< ldap_format_do_detect_plain_as_ldap_format(). #define DEBUG_auth 1 +#define DEBUG_ssl 1 +#define DEBUG_subschema_discovery 1 #define DEBUG_configuration 1 #define DEBUG_detection 1 #define DEBUG_ldapdata_from_server 1 @@ -180,6 +182,8 @@ #undef DEBUG_auth +#undef DEBUG_ssl +#undef DEBUG_subschema_discovery #undef DEBUG_configuration #undef DEBUG_detection #undef DEBUG_ldapdata_from_server @@ -234,6 +238,7 @@ ///< LDAP_ALL_USER_ATTRIBUTES and ///< LDAP_ALL_OPERATIONAL_ATTRIBUTES. ///< This is sloppy. +#define FEDORADSsubschemaSubentry 5 ///< dto. @@ -394,6 +399,24 @@ ///< as one person, act as a different person. char *realm; ///< Name of a group of users; independend of the ///< domain name + char *mozldap_tls_certdb; ///< The TLS certificate database. For example: + ///< /home/user1/.netscape/cert8.db + ///< The NSS certificate and key database are + ///< part or the Network Security Services + ///< (= NSS), which is a set of libraries + ///< for SSL/TLS, as used by the Mozilla LDAP + ///< C SDK. + ///< + ///< Cf. http://www.mozilla.org/projects/security/pki/nss/ + ///< + char *mozldap_tls_certnickname; ///< The TLS certificate nick-name. For example: + ///< ldap_user + char *mozldap_tls_keydb; ///< The TLS key database. For example: + ///< /home/user1/.netscape/key3.db + char *mozldap_tls_keynickname; ///< Also known as "token name". For example: + ///< NSS Certificate DB + char *mozldap_tls_keypassword; ///< The password for the TLS key. For example: + ///< secret char *bindpwd; ///< Bind password char *searchbase; ///< Base DN for any searches char *searchfilter; ///< Search filter @@ -490,7 +513,6 @@ void ldap_plugin_disconnect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata); osync_bool ldap_plugin_do_connect (OSyncContext *ctx, sink_environment *sinkenv, OSyncError **error); osync_bool ldap_plugin_do_disconnect (OSyncContext *ctx, sink_environment *sinkenv, OSyncError **error); -osync_bool ldap_plugin_encrypt_connection (OSyncContext *ctx, sink_environment *sinkenv, OSyncError **error); void ldap_plugin_free_ldap_entry (ldap_entry *entry); void ldap_plugin_free_ldap_entries (GList *entrylist); void ldap_plugin_free_ldapmods_list(GList *ldapmods); @@ -506,7 +528,7 @@ char *ldap_plugin_hash_append(OSyncContext *ctx, char *hash, const sink_environment *sinkenv, const ldap_entry *entry, OSyncError **error); osync_bool ldap_plugin_makebind(OSyncContext *ctx, sink_environment *sinkenv, OSyncError **error); osync_bool ldap_plugin_rewrite_ldap_entry(ldap_entry *entry, GList *modifications, OSyncError **error); -osync_bool ldap_plugin_set_ldap_protocol (OSyncContext *ctx, OSyncPluginInfo *info, sink_environment *sinkenv, OSyncError **error); +osync_bool ldap_plugin_set_ldap_protocol (OSyncContext *ctx, sink_environment *sinkenv, OSyncError **error); @@ -573,5 +595,19 @@ #endif + + +// ldap_ssl.c: +osync_bool ldap_plugin_setup_encryption(OSyncContext *ctx, sink_environment *sinkenv, OSyncError **error); +#ifdef USE_MOZLDAP +osync_bool ldap_plugin_setup_mozldap_ssl_authentication(OSyncContext *ctx, sink_environment *sinkenv, OSyncError **error); +#endif +osync_bool ldap_plugin_starttls (OSyncContext *ctx, sink_environment *sinkenv, OSyncError **error); +#ifdef USE_MOZLDAP +osync_bool ldap_plugin_prepare_mozldap_ssl(OSyncContext *ctx, sink_environment *sinkenv, OSyncError **error); +#endif + + + #endif // #ifndef _LDAP_PLUGIN_H Modified: plugins/ldap-sync/src/ldap_sasl.c ============================================================================== --- plugins/ldap-sync/src/ldap_sasl.c Sun Jan 10 19:26:47 2010 (r5995) +++ plugins/ldap-sync/src/ldap_sasl.c Sun Jan 10 19:27:36 2010 (r5996) @@ -329,7 +329,7 @@ /** * @brief This function was intended to check which SASL authentication - * mechanism are supported by the LDAP server, i.e. by libldap. + * mechanism are supported by the LDAP server. * However, this question can better be answered by command line * tools: * Added: plugins/ldap-sync/src/ldap_ssl.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/src/ldap_ssl.c Sun Jan 10 19:27:36 2010 (r5996) @@ -0,0 +1,482 @@ +/* + * ldap-sync - A plugin for the opensync framework + * + * $Id$ + * Copyright (C) 2009 Juergen Leising <jle...@us...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + + + + +#include "ldap_plugin.h" + + + +/** + * @defgroup ssl Functions for setting up encryption in form of SSL/TLS. + * + * @brief While in libldap from openldap the SSL/TLS related work is mostly done by libldap itself, libldap60 from the Mozilla LDAP C SDK needs some preparation. + * + * LDAP and SSL/TLS work together in two forms: + * + * 1) LDAP over SSL/TLS: "ldaps://" (typically port 636 on the server side) + * + * 2) SSL/TLS inside of LDAP: "ldap://": STARTTLS (typicalls the usual port 389 on the server side) + * + * @ingroup ldap_sync + * + * @{ + */ + + + + +/** + * @brief This function decides whether or not to call STARTTLS. + * This function is used both with libldap from openldap and with + * libldap60 from the Mozilla LDAP C SDK. + * + * @param ctx The libopensync context. + * @param sinkenv The object type specific environment + * @param error The libopensync error pointer + * + * @returns TRUE on success, FALSE in case of any errors + + * + * + */ + +osync_bool +ldap_plugin_setup_encryption(OSyncContext *ctx, sink_environment *sinkenv, OSyncError **error) +{ + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, (void *)ctx, (void *)sinkenv, (void *)error); + + + if (ctx == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ctx = NULL. Returning.\n", __FILE__, __LINE__); + goto error; + } + + if (sinkenv == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sinkenv = NULL. Returning.\n", __FILE__, __LINE__); + goto error; + } + + + // Set encryption on the LDAP connection, if requested, + // provided that the protocol chosen does NOT contain this + // information, yet; i.e., it MUST NOT be equal to "ldaps": + + if (strcmp(sinkenv->protocol, "ldaps") && (strcmp(sinkenv->protocol, "LDAPS"))) { + // Then invoke STARTTLS, i.e. SSL/TLS inside of LDAP + if (!ldap_plugin_starttls(ctx, sinkenv, error)) { + if (!osync_error_is_set(error)) { + osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: ERROR: Could not start encryption.\n", __FILE__, __LINE__); + } + + goto error; + } + } + // otherwise it is already done by the LDAP library: LDAP over SSL/TLS. + // At least this is true for the libldap from openldap. + + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; + +error: + if (!osync_error_is_set(error)) + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); + + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + + return FALSE; +} + + + + + + + + + + +/** + * @brief This function is called only, when the plugin is linked against + * libldap60 from the Mozilla LDAP C SDK. It performs the + * initial setups with regard to SSL/TSL, which are necessary for + * this library (as opposed to libldap from openldap). + * Please note: + * 1) Encryption is one thing, + * 2) Authentication based on the contents of an SSL/TLS certificate + * is a different story. 1) does not necessarily lead to 2). + * See also ldap_plugin_setup_mozldap_ssl_authentication() + * + * + * @param ctx The libopensync context. + * @param sinkenv The object type specific environment + * @param error The libopensync error pointer + * + * @returns TRUE on success, FALSE in case of any errors + */ + + +#ifdef USE_MOZLDAP +osync_bool +ldap_plugin_prepare_mozldap_ssl(OSyncContext *ctx, sink_environment *sinkenv, OSyncError **error) +{ + char *certdb = NULL; + struct stat stat_buffer; + + + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, (void *)ctx, (void *)sinkenv, (void *)error); + + + if (ctx == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ctx = NULL. Returning.\n", __FILE__, __LINE__); + goto error; + } + + + if (sinkenv == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sinkenv = NULL. Returning.\n", __FILE__, __LINE__); + goto error; + } + + + if (sinkenv->servername == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sinkenv->servername = NULL. Returning.\n", __FILE__, __LINE__); + goto error; + } + + if (sinkenv->protocol == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sinkenv->protocol = NULL. Returning.\n", __FILE__, __LINE__); + goto error; + } + + + if (sinkenv->mozldap_tls_certdb) { + certdb = g_strdup(sinkenv->mozldap_tls_certdb); + } else { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sinkenv->mozldap_tls_certdb = NULL. Returning.\n", __FILE__, __LINE__); + goto error; + } + + + if (certdb == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: certdb = NULL. Returning.\n", __FILE__, __LINE__); + goto error; + } + + + + errno = 0; + if (stat(certdb, &stat_buffer)) { + osync_trace(TRACE_ERROR, "%s:%i: WARNING: \"%s\" could not be found: \"%s\"\n", __FILE__, __LINE__, certdb, strerror(errno)); + } + + +#ifdef DEBUG_ssl + ldap_plugin_printf("%s:%i: USE_MOZLDAP and encryption: Right before ldapssl_client_init().\n", __FILE__, __LINE__); +#endif + + // Initialize the client + if (ldapssl_client_init(certdb, NULL) < 0) { + osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: ERROR: ldapssl_clientauth_init() has failed. certdb = \"%s\"", __FILE__, __LINE__, certdb); + goto error; + } + + + if (certdb) { + g_free(certdb); + certdb = NULL; + } + + + + + // Get a handle to an LDAP connection + if (!strcmp(sinkenv->protocol, "ldaps") || (!strcmp(sinkenv->protocol, "LDAPS"))) { +#ifdef DEBUG_ssl + ldap_plugin_printf("%s:%i: USE_MOZLDAP and encryption: Right before ldapssl_init().\n", __FILE__, __LINE__); +#endif + + // For LDAP over SSL/TLS: + sinkenv->ld = ldapssl_init(sinkenv->servername, sinkenv->serverport, LDAPSSL_AUTH_CERT); + // Be careful: Setting LDAPSSL_AUTH_WEAK here has led to hangs with my tests. + // I don't know why. + // Cf. /usr/include/mozldap/ldap_ssl.h + } else { +#ifdef DEBUG_ssl + ldap_plugin_printf("%s:%i: USE_MOZLDAP and encryption: Right before ldap_init().\n", __FILE__, __LINE__); +#endif + + // For SSL/TLS inside LDAP, also known as STARTTLS: + sinkenv->ld = ldap_init(sinkenv->servername, sinkenv->serverport); + } + + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; + + +error: + if (certdb) { + g_free(certdb); + certdb = NULL; + } + + if (!osync_error_is_set(error)) + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); + + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; +} +#endif + + + + + + + +/** + * @brief This function is intended for libldap60 from the Mozilla LDAP C SDK, + * only. It performs authentication related steps in the course of + * setting up the SSL/TLS layer. Please note: + * 1) Encryption is one thing, + * 2) Authentication based on the contents of an SSL/TLS certificate + * is a different story. 1) does not necessarily lead to 2). + * See also ldap_plugin_prepare_mozldap_ssl() + * + * @param ctx The libopensync context. + * @param sinkenv The object type specific environment. + * @param error The libopensync error pointer. + * + * @returns TRUE on success, FALSE in case of any error. + */ + +#ifdef USE_MOZLDAP +osync_bool ldap_plugin_setup_mozldap_ssl_authentication(OSyncContext *ctx, sink_environment *sinkenv, OSyncError **error) +{ + int ldap_errno = 0; + char *ldap_error = NULL; + char *keynickname = NULL; + char *keypasswd = NULL; + char *certnickname = NULL; + + + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, (void *)ctx, (void *)sinkenv, (void *)error); + + + if (ctx == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ctx = NULL. Returning.\n", __FILE__, __LINE__); + goto error; + } + + + if (sinkenv == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sinkenv = NULL. Returning.\n", __FILE__, __LINE__); + goto error; + } + + if (sinkenv->ld == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sinkenv->ld = NULL. Returning.\n", __FILE__, __LINE__); + goto error; + } + + + + // The authentication is based on the SSL/TLS certificate only with + // the authentication mechanism "EXTERNAL". + if (!strcmp(sinkenv->authmech, "EXTERNAL")) { + + if (sinkenv->mozldap_tls_keynickname) { + keynickname = g_strdup(sinkenv->mozldap_tls_keynickname); + osync_trace(TRACE_INTERNAL, "%s:%i: keynickname = \"%s\"", __FILE__, __LINE__, keynickname); + } else { + osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: WARNING: sinkenv->mozldap_tls_keynickname = NULL.", __FILE__, __LINE__); + goto error; + } + + + if (sinkenv->mozldap_tls_keypassword) { + keypasswd = g_strdup(sinkenv->mozldap_tls_keypassword); + osync_trace(TRACE_SENSITIVE, "keypassword = \"%s\"", keypasswd); + } else { + osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: WARNING: sinkenv->mozldap_tls_keypassword = NULL.", __FILE__, __LINE__); + goto error; + } + + + if (sinkenv->mozldap_tls_certnickname) { + certnickname = g_strdup(sinkenv->mozldap_tls_certnickname); + osync_trace(TRACE_INTERNAL, "%s:%i: certnickname = \"%s\"", __FILE__, __LINE__, certnickname); + } else { + osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: WARNING: sinkenv->mozldap_tls_certnickname = NULL.", __FILE__, __LINE__); + goto error; + } + + + + if (keynickname == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: keynickname = NULL. Returning.\n", __FILE__, __LINE__); + goto error; + } + + if (keypasswd == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: keypasswd = NULL. Returning.\n", __FILE__, __LINE__); + goto error; + } + + if (certnickname == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: certnickname = NULL. Returning.\n", __FILE__, __LINE__); + goto error; + } + +#ifdef DEBUG_ssl + ldap_plugin_printf("%s:%i: USE_MOZLDAP and EXTERNAL: Right before ldapssl_enable_clientauth()\n", __FILE__, __LINE__); +#endif + + ldap_errno = ldapssl_enable_clientauth(sinkenv->ld, keynickname, keypasswd, certnickname); + + if (keynickname) { + g_free(keynickname); + keynickname = NULL; + } + + if (keypasswd) { + g_free(keypasswd); + keypasswd = NULL; + } + + if (certnickname) { + g_free(certnickname); + certnickname = NULL; + } + + if (ldap_errno != LDAP_SUCCESS) { + ldap_error = ldap_plugin_report_ldap_error(sinkenv, __FILE__, __LINE__, ldap_errno); + + + if (ldap_error == NULL) { + osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: ERROR: ldapssl_enable_clientauth() has failed. Could not establish a connection to the LDAP server \"%s\", therefore.\n", __FILE__, __LINE__, sinkenv->url ? sinkenv->url : sinkenv->servername); + } else { + osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: ERROR: ldapssl_enable_clientauth() has failed. Could not establish a connection to the LDAP server \"%s\", therefore: \"%s\"\n", __FILE__, __LINE__, sinkenv->url ? sinkenv->url : sinkenv->servername, ldap_error); + } + + goto error; + } + } // if (!strcmp(sinkenv->authmech, "EXTERNAL")) + + + + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; + + +error: + if (!osync_error_is_set(error)) + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); + + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; +} +#endif + + + + + + + +/** + * @brief Encrypts the connection to the LDAP server in form of + * STARTTLS, i.e. SSL/TLS inside of LDAP. + * + * @param ctx The libopensync context. + * @param sinkenv The object type specific environment. + * @param error The libopensync error pointer. + * + * @returns TRUE on success, FALSE in case of any error. + */ + +osync_bool ldap_plugin_starttls (OSyncContext *ctx, sink_environment *sinkenv, OSyncError **error) +{ + int ldap_errno = 0; + char *ldap_error = NULL; + + + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, (void *)ctx, (void *)sinkenv, (void *)error); + + + if (ctx == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ctx = NULL. Returning.\n", __FILE__, __LINE__); + goto error; + } + + if (sinkenv == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sinkenv = NULL. Returning.\n", __FILE__, __LINE__); + goto error; + } + + if (sinkenv->ld == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sinkenv->ld = NULL. Returning.\n", __FILE__, __LINE__); + goto error; + } + + +#ifdef DEBUG_ssl + ldap_plugin_printf("%s:%i: Right before ldap_start_tls_s()\n", __FILE__, __LINE__); +#endif + + ldap_errno = ldap_start_tls_s(sinkenv->ld, NULL, NULL); + + if (ldap_errno != LDAP_SUCCESS) { + ldap_error = ldap_plugin_report_ldap_error(sinkenv, __FILE__, __LINE__, ldap_errno); + + if (ldap_error == NULL) { + osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: ERROR: ldap_start_tls_s() has failed. Could not establish a connection to the LDAP server \"%s\", therefore.\n", __FILE__, __LINE__, sinkenv->url ? sinkenv->url : sinkenv->servername); + } else { + osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: ERROR: ldap_start_tls_s() has failed. Could not establish a connection to the LDAP server \"%s\", therefore: \"%s\"\n", __FILE__, __LINE__, sinkenv->url ? sinkenv->url : sinkenv->servername, ldap_error); + } + + + goto error; + } + + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; + + +error: + if (!osync_error_is_set(error)) + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); + + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; +} + + + + + +/* @} */ |
From: <svn...@op...> - 2010-01-10 18:26:57
|
Author: scriptor Date: Sun Jan 10 19:26:47 2010 New Revision: 5995 URL: http://www.opensync.org/changeset/5995 Log: The timeouts were too long... And my current guess is, that it is CTestConfig.cmake only, that has effects on the test timeouts, in the end. So no need to set the timeouts in any of the CMakeLists.txt. Modified: plugins/ldap-sync/CTestConfig.cmake Modified: plugins/ldap-sync/CTestConfig.cmake ============================================================================== --- plugins/ldap-sync/CTestConfig.cmake Sun Jan 10 19:26:33 2010 (r5994) +++ plugins/ldap-sync/CTestConfig.cmake Sun Jan 10 19:26:47 2010 (r5995) @@ -1,7 +1,7 @@ ## This file should be placed in the root directory of your project. ## Then modify the CMakeLists.txt file in the root directory of your ## project to incorporate the testing dashboard. -## # The following are required to uses Dart and the Cdash dashboard +## # The following ones are required to use Dart and the Cdash dashboard ## ENABLE_TESTING() ## INCLUDE(Dart) set(CTEST_PROJECT_NAME "ldap-sync") @@ -20,9 +20,9 @@ # DART_TESTING_TIMEOUT must be set in CTestConfig.cmake rather than here. # At least, it seems so... IF (RUN_LONG_TESTS) - SET ( TIMEOUT 3600 CACHE STRING "General timeout value." FORCE ) + SET ( TIMEOUT 600 CACHE STRING "General timeout value." FORCE ) ELSE(RUN_LONG_TESTS) - SET ( TIMEOUT 480 CACHE STRING "General timeout value." FORCE ) + SET ( TIMEOUT 90 CACHE STRING "General timeout value." FORCE ) ENDIF(RUN_LONG_TESTS) SET ( CTEST_TEST_TIMEOUT ${TIMEOUT} CACHE STRING "The most natural variable for a timeout setting does NOT work. Great!" FORCE ) |
From: <svn...@op...> - 2010-01-10 18:26:48
|
Author: scriptor Date: Sun Jan 10 19:26:33 2010 New Revision: 5994 URL: http://www.opensync.org/changeset/5994 Log: - Better distinction between libldap from openldap and libldap60 from the Mozilla LDAP C SDK in the build process. - New file ldap_ssl.c added to the build process. - Small fix in the CMakeLists.txt when libsasl2 has not been found. Modified: plugins/ldap-sync/CMakeLists.txt plugins/ldap-sync/src/CMakeLists.txt Modified: plugins/ldap-sync/CMakeLists.txt ============================================================================== --- plugins/ldap-sync/CMakeLists.txt Sun Jan 10 19:03:23 2010 (r5993) +++ plugins/ldap-sync/CMakeLists.txt Sun Jan 10 19:26:33 2010 (r5994) @@ -398,10 +398,10 @@ MESSAGE(STATUS "LDAP_PLUGIN_OPENSYNC_SCHEMASDIR = ${LDAP_PLUGIN_OPENSYNC_SCHEMASDIR}") IF ( USE_OPENLDAP ) - MESSAGE (STATUS "libldap from openldap will be used.") + MESSAGE (STATUS "The LDAP plugin will be linked against libldap from openldap ( http://www.openldap.org/ ).") ELSE ( USE_OPENLDAP ) IF ( USE_MOZLDAP ) - MESSAGE (STATUS "libldap60 from Mozilla will be used.") + MESSAGE (STATUS "The LDAP plugin will be linked against libldap60 from the Mozilla LDAP C SDK ( http://www.mozilla.org/directory/csdk.html ).") ELSE ( USE_MOZLDAP ) MESSAGE (FATAL_ERROR "Neither libldap from openldap nor libldap60 from Mozilla has been chosen. This is not possible. The LDAP plugin requires either of these libraries.") ENDIF ( USE_MOZLDAP ) Modified: plugins/ldap-sync/src/CMakeLists.txt ============================================================================== --- plugins/ldap-sync/src/CMakeLists.txt Sun Jan 10 19:03:23 2010 (r5993) +++ plugins/ldap-sync/src/CMakeLists.txt Sun Jan 10 19:26:33 2010 (r5994) @@ -41,12 +41,18 @@ MESSAGE( STATUS "_LDAP_LIBRARIES = \"${_LDAP_LIBRARIES}\"" ) ENDIF ( NOT _LDAP_LIBRARIES ) -LINK_DIRECTORIES( ${OPENSYNC_LIBRARY_DIRS} ${GLIB2_LIBRARY_DIRS} ${LIBXML2_LIBRARY_DIRS} ${LIBXSLT_LIBRARY_DIRS} ${_LDAP_LIBRARY_DIRS} ${SASL2_LIBRARY_DIRS} ${GSSAPIV2_LIBRARY_DIRS}) -INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${OPENSYNC_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIRS} ${LIBXSLT_INCLUDE_DIRS} ${_LDAP_INCLUDE_DIRS} ${SASL2_INCLUDE_DIRS} ${GSSAPIV2_INCLUDE_DIRS}) +IF (LIBSASL2_FOUND) + LINK_DIRECTORIES( ${OPENSYNC_LIBRARY_DIRS} ${GLIB2_LIBRARY_DIRS} ${LIBXML2_LIBRARY_DIRS} ${LIBXSLT_LIBRARY_DIRS} ${_LDAP_LIBRARY_DIRS} ${SASL2_LIBRARY_DIRS} ${GSSAPIV2_LIBRARY_DIRS}) + INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${OPENSYNC_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIRS} ${LIBXSLT_INCLUDE_DIRS} ${_LDAP_INCLUDE_DIRS} ${SASL2_INCLUDE_DIRS} ${GSSAPIV2_INCLUDE_DIRS}) +ELSE (LIBSASL2_FOUND) + LINK_DIRECTORIES( ${OPENSYNC_LIBRARY_DIRS} ${GLIB2_LIBRARY_DIRS} ${LIBXML2_LIBRARY_DIRS} ${LIBXSLT_LIBRARY_DIRS} ${_LDAP_LIBRARY_DIRS} ${GSSAPIV2_LIBRARY_DIRS}) + INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${OPENSYNC_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIRS} ${LIBXSLT_INCLUDE_DIRS} ${_LDAP_INCLUDE_DIRS} ${GSSAPIV2_INCLUDE_DIRS}) +ENDIF (LIBSASL2_FOUND) + INCLUDE( Compiler ) -OPENSYNC_PLUGIN_ADD( ldap-sync ldap_plugin.c ldap_connect.c ldap_sasl.c ldap_debug.c) +OPENSYNC_PLUGIN_ADD( ldap-sync ldap_plugin.c ldap_connect.c ldap_sasl.c ldap_ssl.c ldap_debug.c) OPENSYNC_FORMAT_ADD( ldap-format ldap_format.c ldap_debug.c) |
From: <svn...@op...> - 2010-01-10 18:03:35
|
Author: dgollub Date: Sun Jan 10 19:03:23 2010 New Revision: 5993 URL: http://www.opensync.org/changeset/5993 Log: Changed order of main_sink connect and sink connect calls. Adapted testsuite which verified correct order of plugin sink function calls. Testsuite patch by paule fixes #1198 Modified: trunk/opensync/engine/opensync_engine.c trunk/tests/engine-tests/check_engine.c Modified: trunk/opensync/engine/opensync_engine.c ============================================================================== --- trunk/opensync/engine/opensync_engine.c Sun Jan 10 18:34:33 2010 (r5992) +++ trunk/opensync/engine/opensync_engine.c Sun Jan 10 19:03:23 2010 (r5993) @@ -1845,7 +1845,14 @@ switch (command->cmd) { case OSYNC_ENGINE_COMMAND_CONNECT: - /* We first tell all object engines to connect */ + /* First we connect the main sinks */ + for (o = engine->proxies; o; o = o->next) { + OSyncClientProxy *proxy = o->data; + if (!osync_client_proxy_connect(proxy, _osync_engine_connect_callback, engine, NULL, FALSE, &locerror)) + goto error; + } + + /* Then we tell all object engines to connect */ for (o = engine->object_engines; o; o = o->next) { OSyncObjEngine *objengine = o->data; @@ -1856,12 +1863,6 @@ goto error; } - /* Then we connect the main sinks */ - for (o = engine->proxies; o; o = o->next) { - OSyncClientProxy *proxy = o->data; - if (!osync_client_proxy_connect(proxy, _osync_engine_connect_callback, engine, NULL, FALSE, &locerror)) - goto error; - } break; case OSYNC_ENGINE_COMMAND_CONNECT_DONE: case OSYNC_ENGINE_COMMAND_READ: Modified: trunk/tests/engine-tests/check_engine.c ============================================================================== --- trunk/tests/engine-tests/check_engine.c Sun Jan 10 18:34:33 2010 (r5992) +++ trunk/tests/engine-tests/check_engine.c Sun Jan 10 19:03:23 2010 (r5993) @@ -378,7 +378,7 @@ osync_assert(env->num_connect < 3); osync_assert(env->num_disconnect == 0); osync_assert(env->num_get_changes == 0); - osync_assert(env->main_connect == 0); + osync_assert(env->main_connect == 1); osync_assert(env->main_disconnect == 0); osync_assert(env->main_get_changes == 0); @@ -435,7 +435,7 @@ osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, ctx); osync_assert(env); - osync_assert(env->num_connect == 3); + osync_assert(env->num_connect == 0); osync_assert(env->num_disconnect == 0); osync_assert(env->num_get_changes == 0); osync_assert(env->main_connect == 0); @@ -700,12 +700,12 @@ osync_assert(env->num_connect < 3); osync_assert(env->num_disconnect == 0); osync_assert(env->num_get_changes == 0); - osync_assert(env->main_connect == 0); + osync_assert(env->main_connect == 1); osync_assert(env->main_disconnect == 0); osync_assert(env->main_get_changes == 0); env->ctx[env->num_connect] = ctx; - osync_context_ref(ctx); + osync_context_report_success(ctx); g_atomic_int_inc(&(env->num_connect)); @@ -785,7 +785,7 @@ osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, ctx); osync_assert(env); - osync_assert(env->num_connect == 3); + osync_assert(env->num_connect == 0); osync_assert(env->num_disconnect == 0); osync_assert(env->num_get_changes == 0); osync_assert(env->main_connect == 0); @@ -795,13 +795,6 @@ g_atomic_int_inc(&(env->main_connect)); osync_context_report_success(ctx); - osync_context_report_success(env->ctx[0]); - osync_context_report_success(env->ctx[1]); - osync_context_report_success(env->ctx[2]); - - osync_context_unref(env->ctx[0]); - osync_context_unref(env->ctx[1]); - osync_context_unref(env->ctx[2]); osync_trace(TRACE_EXIT, "%s", __func__); } |
From: <svn...@op...> - 2010-01-10 17:34:42
|
Author: dgollub Date: Sun Jan 10 18:34:33 2010 New Revision: 5992 URL: http://www.opensync.org/changeset/5992 Log: Introduce testcase to verify correct slow-sync once the hashtable gets deleted. fixes #960 Modified: trunk/tests/CMakeLists.txt trunk/tests/sync-tests/check_sync.c Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Sun Jan 10 18:34:06 2010 (r5991) +++ trunk/tests/CMakeLists.txt Sun Jan 10 18:34:33 2010 (r5992) @@ -332,6 +332,7 @@ OSYNC_TESTCASE( sync sync_slowsync_connect) OSYNC_TESTCASE( sync sync_slowsync_mainsink_connect) OSYNC_TESTCASE( sync sync_initial_slow_sync) +OSYNC_TESTCASE( sync sync_hashtable_deleted_slowsync) BUILD_CHECK_TEST( sync-error sync-tests/check_sync_error.c ${TEST_TARGET_LIBRARIES} ) OSYNC_TESTCASE(sync-error sync_error_single_init_error_noerror) Modified: trunk/tests/sync-tests/check_sync.c ============================================================================== --- trunk/tests/sync-tests/check_sync.c Sun Jan 10 18:34:06 2010 (r5991) +++ trunk/tests/sync-tests/check_sync.c Sun Jan 10 18:34:33 2010 (r5992) @@ -3367,6 +3367,152 @@ END_TEST +/* Test if slow-sync get triggerd if a new hashtable got created + * this can be due that the hashtable got deleted. + * Or hashtable got malformed? (TODO: validate that ..) + * + * See #960 + */ +START_TEST (sync_hashtable_deleted_slowsync) +{ + char *testbed = setup_testbed("sync"); + char *formatdir = g_strdup_printf("%s/formats", testbed); + char *plugindir = g_strdup_printf("%s/plugins", testbed); + + osync_testing_system_abort("cp testdata data1/testdata"); + + OSyncError *error = NULL; + OSyncGroup *group = osync_group_new(&error); + fail_unless(group != NULL, NULL); + fail_unless(error == NULL, NULL); + + osync_group_set_schemadir(group, testbed); + fail_unless(osync_group_load(group, "configs/group", &error), NULL); + fail_unless(error == NULL, NULL); + + OSyncEngine *engine = osync_engine_new(group, &error); + fail_unless(engine != NULL, NULL); + fail_unless(error == NULL, NULL); + + osync_engine_set_schemadir(engine, testbed); + osync_engine_set_plugindir(engine, plugindir); + osync_engine_set_formatdir(engine, formatdir); + + osync_engine_set_conflict_callback(engine, conflict_handler_choose_first, GINT_TO_POINTER(1)); + osync_engine_set_changestatus_callback(engine, entry_status, GINT_TO_POINTER(1)); + osync_engine_set_mappingstatus_callback(engine, mapping_status, GINT_TO_POINTER(1)); + osync_engine_set_enginestatus_callback(engine, engine_status, GINT_TO_POINTER(1)); + osync_engine_set_memberstatus_callback(engine, member_status, GINT_TO_POINTER(1)); + + + fail_unless(osync_engine_initialize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + + fail_unless(osync_engine_synchronize_and_block(engine, &error), NULL); + fail_unless(error == NULL, NULL); + + fail_unless(osync_engine_finalize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + + osync_engine_unref(engine); + + /* NOW we manipulate the group and delete the hashtable of one member. */ + + osync_testing_system_abort("rm configs/group/1/hashtable.db"); + + /*** end of hashtable manipulation ***/ + + engine = osync_engine_new(group, &error); + fail_unless(engine != NULL, NULL); + fail_unless(error == NULL, NULL); + osync_group_unref(group); + + osync_engine_set_schemadir(engine, testbed); + osync_engine_set_plugindir(engine, plugindir); + osync_engine_set_formatdir(engine, formatdir); + + osync_engine_set_conflict_callback(engine, conflict_handler_choose_first, GINT_TO_POINTER(1)); + osync_engine_set_changestatus_callback(engine, entry_status, GINT_TO_POINTER(1)); + osync_engine_set_mappingstatus_callback(engine, mapping_status, GINT_TO_POINTER(1)); + osync_engine_set_enginestatus_callback(engine, engine_status, GINT_TO_POINTER(1)); + osync_engine_set_memberstatus_callback(engine, member_status, GINT_TO_POINTER(1)); + + + fail_unless(osync_engine_initialize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + + fail_unless(synchronize_once(engine, &error), NULL); + fail_unless(error == NULL, NULL); + + fail_unless(osync_engine_finalize(engine, &error), NULL); + fail_unless(error == NULL, NULL); + + /* Change checks */ + fail_unless(num_change_written == 0, NULL); + fail_unless(num_change_error == 0, NULL); + + /* BOOoom! If hashtable-deleted slow-sync implementation is missing */ + fail_unless(num_change_read == 2, NULL); + + /* Client checks */ + fail_unless(num_client_connected == 2, NULL); + fail_unless(num_client_main_connected == 2, NULL); + fail_unless(num_client_read == 2, NULL); + fail_unless(num_client_main_read == 2, NULL); + fail_unless(num_client_written == 2, NULL); + fail_unless(num_client_main_written == 2, NULL); + fail_unless(num_client_disconnected == 2, NULL); + fail_unless(num_client_main_disconnected == 2, NULL); + fail_unless(num_client_errors == 0, NULL); + fail_unless(num_client_sync_done == 2, NULL); + fail_unless(num_client_main_sync_done == 2, NULL); + + /* Client checks */ + fail_unless(num_engine_connected == 1, NULL); + fail_unless(num_engine_errors == 0, NULL); + fail_unless(num_engine_read == 1, NULL); + fail_unless(num_engine_written == 1, NULL); + fail_unless(num_engine_sync_done == 1, NULL); + fail_unless(num_engine_disconnected == 1, NULL); + fail_unless(num_engine_successful == 1, NULL); + fail_unless(num_engine_end_conflicts == 1, NULL); + fail_unless(num_engine_prev_unclean == 0, NULL); + + /* Mapping checks */ + fail_unless(num_mapping_solved == 1, NULL); + //fail_unless(num_mapping_written == 1, NULL); + fail_unless(num_mapping_errors == 0, NULL); + fail_unless(num_mapping_conflicts == 0, NULL); + + fail_unless(osync_testing_diff("data1", "data2")); + + char *path = g_strdup_printf("%s/configs/group/archive.db", testbed); + OSyncMappingTable *maptable = mappingtable_load(path, "mockobjtype1", 1); + g_free(path); + check_mapping(maptable, 1, 1, 2, "testdata"); + check_mapping(maptable, 2, 1, 2, "testdata"); + osync_mapping_table_close(maptable); + osync_mapping_table_unref(maptable); + + path = g_strdup_printf("%s/configs/group/1/hashtable.db", testbed); + OSyncHashTable *table = hashtable_load(path, "mockobjtype1", 1); + g_free(path); + check_hash(table, "testdata"); + osync_hashtable_unref(table); + + path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed); + table = hashtable_load(path, "mockobjtype1", 1); + g_free(path); + check_hash(table, "testdata"); + osync_hashtable_unref(table); + + g_free(formatdir); + g_free(plugindir); + + destroy_testbed(testbed); +} +END_TEST + /* Testing mixed-objtype syncing (#992) * */ @@ -3498,6 +3644,7 @@ OSYNC_TESTCASE_ADD(sync_slowsync_connect) OSYNC_TESTCASE_ADD(sync_slowsync_mainsink_connect) OSYNC_TESTCASE_ADD(sync_initial_slow_sync) +OSYNC_TESTCASE_ADD(sync_hashtable_deleted_slowsync) OSYNC_TESTCASE_ADD(sync_mixed_objtype) /* TODO: stateless sync */ OSYNC_TESTCASE_END |
From: <svn...@op...> - 2010-01-10 17:34:15
|
Author: dgollub Date: Sun Jan 10 18:34:06 2010 New Revision: 5991 URL: http://www.opensync.org/changeset/5991 Log: Reset slow-sync set to allow multiple syncs (multi-sync) with one initialized OSyncEngine. Slow-sync reset was always unclean and only got reseted after the next connect() call. Since slow-syncs now can be triggered even before a connect (e.g. hashtable deletion) things needed to get cleaned up. Since sync-done() function is the very last plugin call in a multi-sync the slow-sync state get rested there for OSyncClientProxy and OSyncClient. refs #960 Modified: trunk/opensync/client/opensync_client.c trunk/opensync/client/opensync_client_proxy.c Modified: trunk/opensync/client/opensync_client.c ============================================================================== --- trunk/opensync/client/opensync_client.c Sun Jan 10 18:29:30 2010 (r5990) +++ trunk/opensync/client/opensync_client.c Sun Jan 10 18:34:06 2010 (r5991) @@ -1071,14 +1071,9 @@ osync_message_unref(reply); } else { - /* set slowsync. - otherwise disable slowsync - to avoid slowsyncs every time with the same initiliazed engine - without finalizing the engine the next sync with the same engine would be again a slow-sync. - (unittest: sync - testcases: sync_easy_new_del, sync_easy_new_mapping) */ + /* set slowsync. but never disable it */ if (slowsync) osync_objtype_sink_set_slowsync(sink, TRUE); - else - osync_objtype_sink_set_slowsync(sink, FALSE); context = _create_context(client, message, _osync_client_connect_callback, NULL, error); if (!context) @@ -1148,11 +1143,10 @@ goto error; /* set slowsync (again) if the slow-sync got requested during the connect() call - of a member - and not during frontend/engine itself (e.g. anchor mismatch). */ + of a member - and not during frontend/engine itself (e.g. anchor mismatch). + Never disable a slowsync.*/ if (slowsync) osync_objtype_sink_set_slowsync(sink, TRUE); - else - osync_objtype_sink_set_slowsync(sink, FALSE); osync_plugin_info_set_sink(client->plugin_info, sink); osync_objtype_sink_connect_done(sink, client->plugin_info, context); @@ -1498,6 +1492,10 @@ if (!osync_objtype_sink_save_hashtable(sink, error)) goto error; + + /* Reset slow-sync state. The sink is here over. + * Reset is requried for a multi-sync, without finalization.*/ + osync_objtype_sink_set_slowsync(sink, FALSE); } osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; Modified: trunk/opensync/client/opensync_client_proxy.c ============================================================================== --- trunk/opensync/client/opensync_client_proxy.c Sun Jan 10 18:29:30 2010 (r5990) +++ trunk/opensync/client/opensync_client_proxy.c Sun Jan 10 18:34:06 2010 (r5991) @@ -1900,9 +1900,15 @@ goto error; sink = osync_client_proxy_find_objtype_sink(proxy, objtype); - if (sink) + if (sink) { timeout = osync_objtype_sink_get_syncdone_timeout_or_default(sink); + /* Reset the slow-sync state in the client-proxy OSyncObjTypeSink object, since finalize might + * not get called in a multi-sync + */ + osync_objtype_sink_set_slowsync(sink, FALSE); + } + ctx->proxy = proxy; ctx->sync_done_callback = callback; ctx->sync_done_callback_data = userdata; |
From: <svn...@op...> - 2010-01-10 17:29:39
|
Author: dgollub Date: Sun Jan 10 18:29:30 2010 New Revision: 5990 URL: http://www.opensync.org/changeset/5990 Log: remove debugging statement/printf refs #960 Modified: trunk/opensync/ipc/opensync_serializer.c Modified: trunk/opensync/ipc/opensync_serializer.c ============================================================================== --- trunk/opensync/ipc/opensync_serializer.c Sun Jan 10 18:23:59 2010 (r5989) +++ trunk/opensync/ipc/opensync_serializer.c Sun Jan 10 18:29:30 2010 (r5990) @@ -459,8 +459,6 @@ goto error; osync_objtype_sink_set_slowsync(*sink, slowsync); - if (slowsync) - printf("SLOWSYNC marshled!\n"); /* timeouts */ if (!osync_message_read_int(message, &timeout, error)) |
From: <svn...@op...> - 2010-01-10 17:24:08
|
Author: dgollub Date: Sun Jan 10 18:23:59 2010 New Revision: 5989 URL: http://www.opensync.org/changeset/5989 Log: Fix build of test/support.o this got broken with previous commit when introducing a new parameter to osync_hashtable_new refs #960 Modified: trunk/tests/support.c Modified: trunk/tests/support.c ============================================================================== --- trunk/tests/support.c Sun Jan 10 18:07:53 2010 (r5988) +++ trunk/tests/support.c Sun Jan 10 18:23:59 2010 (r5989) @@ -299,7 +299,7 @@ OSyncHashTable *hashtable_load(const char *path, const char *objtype, unsigned int entries) { OSyncError *error = NULL; - OSyncHashTable *table = osync_hashtable_new(path, objtype, &error); + OSyncHashTable *table = osync_hashtable_new(path, objtype, NULL, &error); fail_unless(table != NULL, NULL); fail_unless(error == NULL, NULL); |
From: <svn...@op...> - 2010-01-10 17:08:01
|
Author: dgollub Date: Sun Jan 10 18:07:53 2010 New Revision: 5988 URL: http://www.opensync.org/changeset/5988 Log: Set slow-sync for ObjTypeSink if the hashtable got deleted. refs #960 Modified: trunk/opensync/plugin/opensync_objtype_sink.c Modified: trunk/opensync/plugin/opensync_objtype_sink.c ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.c Sun Jan 10 18:06:11 2010 (r5987) +++ trunk/opensync/plugin/opensync_objtype_sink.c Sun Jan 10 18:07:53 2010 (r5988) @@ -670,6 +670,7 @@ osync_bool osync_objtype_sink_load_hashtable(OSyncObjTypeSink *sink, OSyncPluginInfo *plugin_info, OSyncError **error) { + osync_bool new_hashtable; char *hashtablepath; osync_assert(sink); @@ -688,10 +689,15 @@ osync_plugin_info_get_configdir(plugin_info), G_DIR_SEPARATOR); - sink->hashtable = osync_hashtable_new(hashtablepath, sink->objtype, error); + sink->hashtable = osync_hashtable_new(hashtablepath, sink->objtype, &new_hashtable, error); if (!sink->hashtable) goto error; + if (new_hashtable && osync_objtype_sink_get_slowsync(sink) == FALSE) { + osync_objtype_sink_set_slowsync(sink, TRUE); + osync_trace(TRACE_INTERNAL, "SLOWSYNC: new_hashtable got created, maybe it got deleted or malformed?!"); + } + if (!osync_hashtable_load(sink->hashtable, error)) goto error_free_hashtable; |
From: <svn...@op...> - 2010-01-10 17:06:23
|
Author: dgollub Date: Sun Jan 10 18:06:11 2010 New Revision: 5987 URL: http://www.opensync.org/changeset/5987 Log: Add a parameter in osync_hashtable_new to allow to report that the hashtable got newly created. This helps to identify that the hashtable might got deleted. This is useful to report a slowsync in this case see #960 Modified: trunk/opensync/helper/opensync_hashtable.c trunk/opensync/helper/opensync_hashtable_internals.h trunk/tests/helper-tests/check_hash.c Modified: trunk/opensync/helper/opensync_hashtable.c ============================================================================== --- trunk/opensync/helper/opensync_hashtable.c Sun Jan 10 17:58:47 2010 (r5986) +++ trunk/opensync/helper/opensync_hashtable.c Sun Jan 10 18:06:11 2010 (r5987) @@ -123,12 +123,15 @@ /* end private api */ -OSyncHashTable *osync_hashtable_new(const char *path, const char *objtype, OSyncError **error) +OSyncHashTable *osync_hashtable_new(const char *path, const char *objtype, osync_bool *new_hashtable, OSyncError **error) { OSyncHashTable *table = NULL; int ret = 0; osync_trace(TRACE_ENTRY, "%s(%s, %p)", __func__, path, error); + if (new_hashtable) + *new_hashtable = FALSE; + table = osync_try_malloc0(sizeof(OSyncHashTable), error); if (!table) goto error; @@ -153,11 +156,15 @@ if (ret < 0) goto error; - else if (ret == 0) + else if (ret == 0) { /* if ret == 0 then table does not exist yet. contiune and create one. */ if (!osync_hashtable_create(table, error)) goto error; + if (new_hashtable) + *new_hashtable = TRUE; + } + osync_trace(TRACE_EXIT, "%s: %p", __func__, table); return table; Modified: trunk/opensync/helper/opensync_hashtable_internals.h ============================================================================== --- trunk/opensync/helper/opensync_hashtable_internals.h Sun Jan 10 17:58:47 2010 (r5986) +++ trunk/opensync/helper/opensync_hashtable_internals.h Sun Jan 10 18:06:11 2010 (r5987) @@ -52,11 +52,12 @@ * * @param path the full path and file name of the hashtable .db file to load from or create * @param objtype the object type of the hashtable + * @param new_hashtable pointer to a bool, which get set to TRUE if a new hashtable got created (e.g. first sync, got deleted, malformed, ...). Otherwise got set to FALSE. * @param error Pointer to an error struct * @returns A new hashtable, or NULL if an error occurred. * */ -OSYNC_TEST_EXPORT OSyncHashTable *osync_hashtable_new(const char *path, const char *objtype, OSyncError **error); +OSYNC_TEST_EXPORT OSyncHashTable *osync_hashtable_new(const char *path, const char *objtype, osync_bool *new_hashtable, OSyncError **error); /** @brief Increase the reference count of a hashtable object. * Modified: trunk/tests/helper-tests/check_hash.c ============================================================================== --- trunk/tests/helper-tests/check_hash.c Sun Jan 10 17:58:47 2010 (r5986) +++ trunk/tests/helper-tests/check_hash.c Sun Jan 10 18:06:11 2010 (r5987) @@ -21,13 +21,17 @@ OSyncError *error = NULL; char *testbed = setup_testbed(NULL); + + osync_bool new_hashtable = FALSE; + reset_hashtable_counters(); char *hashpath = g_strdup_printf("%s%chashtable.db", testbed, G_DIR_SEPARATOR); - OSyncHashTable *table = osync_hashtable_new(hashpath, "contact", &error); + OSyncHashTable *table = osync_hashtable_new(hashpath, "contact", &new_hashtable, &error); g_free(hashpath); fail_unless(!error, NULL); fail_unless(table != NULL, NULL); + fail_unless(new_hashtable != FALSE, NULL); /* Expecting a fresh/new hashtable */ /***** load */ fail_unless(osync_hashtable_load(table, &error), NULL); @@ -69,12 +73,15 @@ OSyncError *error = NULL; char *testbed = setup_testbed(NULL); + osync_bool new_hashtable = FALSE; + reset_hashtable_counters(); char *hashpath = g_strdup_printf("%s%chashtable.db", testbed, G_DIR_SEPARATOR); - OSyncHashTable *table = osync_hashtable_new(hashpath, "contact", &error); + OSyncHashTable *table = osync_hashtable_new(hashpath, "contact", &new_hashtable, &error); fail_unless(!error, NULL); fail_unless(table != NULL, NULL); + fail_unless(new_hashtable != FALSE, NULL); /* Expecting a new/fresh hastable */ /***** load */ fail_unless(osync_hashtable_load(table, &error), NULL); @@ -100,9 +107,10 @@ table = NULL; /** reload the hashtable */ - OSyncHashTable *newtable = osync_hashtable_new(hashpath, "contact", &error); + OSyncHashTable *newtable = osync_hashtable_new(hashpath, "contact", &new_hashtable, &error); fail_unless(!error, NULL); fail_unless(newtable != NULL, NULL); + fail_unless(new_hashtable != TRUE, NULL); /* We expect here no new hashtable */ /* 0 entries - since not loaded! */ fail_unless(osync_hashtable_num_entries(newtable) == 0, NULL); @@ -137,7 +145,7 @@ reset_hashtable_counters(); char *hashpath = g_strdup_printf("%s%chashtable.db", testbed, G_DIR_SEPARATOR); - OSyncHashTable *table = osync_hashtable_new(hashpath, "contact", &error); + OSyncHashTable *table = osync_hashtable_new(hashpath, "contact", NULL, &error); fail_unless(!error, NULL); fail_unless(table != NULL, NULL); @@ -171,7 +179,7 @@ table = NULL; /** reload the hashtable */ - OSyncHashTable *newtable = osync_hashtable_new(hashpath, "contact", &error); + OSyncHashTable *newtable = osync_hashtable_new(hashpath, "contact", NULL, &error); fail_unless(!error, NULL); fail_unless(newtable != NULL, NULL); |
From: <svn...@op...> - 2010-01-10 16:58:56
|
Author: dgollub Date: Sun Jan 10 17:58:47 2010 New Revision: 5986 URL: http://www.opensync.org/changeset/5986 Log: Marshal/Denmarshal the slow-sync attribute of a ObjtypeSink. This is required to trigger a slow-sync in the initailze state. This coudl happen in case the hashtable got deleted. see #960 Modified: trunk/opensync/ipc/opensync_serializer.c Modified: trunk/opensync/ipc/opensync_serializer.c ============================================================================== --- trunk/opensync/ipc/opensync_serializer.c Sun Jan 10 17:49:19 2010 (r5985) +++ trunk/opensync/ipc/opensync_serializer.c Sun Jan 10 17:58:47 2010 (r5986) @@ -355,6 +355,9 @@ /* enabled */ osync_message_write_int(message, osync_objtype_sink_is_enabled(sink), error); + /* slowsync */ + osync_message_write_int(message, osync_objtype_sink_get_slowsync(sink), error); + /* timeouts */ osync_message_write_int(message, osync_objtype_sink_get_connect_timeout(sink), error); osync_message_write_int(message, osync_objtype_sink_get_disconnect_timeout(sink), error); @@ -381,7 +384,7 @@ char *name = NULL; char *preferred_format = NULL; int num_formats = 0; - int enabled = 0, timeout = 0; + int enabled = 0, timeout = 0, slowsync = 0; int read = 0, get_changes = 0; int i = 0; @@ -396,6 +399,7 @@ * number of format sinks * format sink list (format sinks) * enabled (int) + * slowsync (bool) * timeout connect (int) * timeout disconnect (int) * timeout get_changes (int) @@ -450,6 +454,14 @@ osync_objtype_sink_set_enabled(*sink, enabled); + /* slowsync */ + if (!osync_message_read_int(message, &slowsync, error)) + goto error; + + osync_objtype_sink_set_slowsync(*sink, slowsync); + if (slowsync) + printf("SLOWSYNC marshled!\n"); + /* timeouts */ if (!osync_message_read_int(message, &timeout, error)) goto error; |
From: <svn...@op...> - 2010-01-10 16:49:29
|
Author: markellis Date: Sun Jan 10 17:49:19 2010 New Revision: 5985 URL: http://www.opensync.org/changeset/5985 Log: fix initialisation of sample plugin Modified: plugins/python-module/src/sample.py Modified: plugins/python-module/src/sample.py ============================================================================== --- plugins/python-module/src/sample.py Sun Jan 10 16:22:03 2010 (r5984) +++ plugins/python-module/src/sample.py Sun Jan 10 17:49:19 2010 (r5985) @@ -3,7 +3,7 @@ class DummySink(opensync.ObjTypeSinkCallbacks): def __init__(self, objtype): opensync.ObjTypeSinkCallbacks.__init__(self, objtype) - self.sink.add_objformat("file") + self.sink.add_objformat(opensync.ObjFormatSink("file")) def connect(self, info, ctx): print "Connect called!" |
From: <svn...@op...> - 2010-01-10 15:22:11
|
Author: dgollub Date: Sun Jan 10 16:22:03 2010 New Revision: 5984 URL: http://www.opensync.org/changeset/5984 Log: Introduced example plugin with static capabilities. fixes #1048 Added: trunk/docs/examples/plugins/src/simple_plugin_static_caps.c - copied, changed from r5970, trunk/docs/examples/plugins/src/simple_plugin.c trunk/docs/examples/plugins/src/simple_plugin_static_caps_capabilities.xml trunk/docs/examples/plugins/src/simple_plugin_static_caps_description.xml Modified: trunk/docs/examples/plugins/src/CMakeLists.txt Modified: trunk/docs/examples/plugins/src/CMakeLists.txt ============================================================================== --- trunk/docs/examples/plugins/src/CMakeLists.txt Sun Jan 10 16:17:04 2010 (r5983) +++ trunk/docs/examples/plugins/src/CMakeLists.txt Sun Jan 10 16:22:03 2010 (r5984) @@ -6,6 +6,14 @@ TARGET_LINK_LIBRARIES( example_simple_plugin ${OPENSYNC_LIBRARIES} ) OPENSYNC_PLUGIN_INSTALL( example_simple_plugin ) +### Simple Synchronization Plugin with Static Capabilities ######## +OPENSYNC_PLUGIN_ADD( example_simple_plugin_static_caps simple_plugin_static_caps.c ) +TARGET_LINK_LIBRARIES( example_simple_plugin_static_caps ${OPENSYNC_LIBRARIES} ) +OPENSYNC_PLUGIN_INSTALL( example_simple_plugin_static_caps ) + +OPENSYNC_PLUGIN_CAPABILITIES( simple_plugin_static_caps_capabilities.xml ) # install capabilites file +OPENSYNC_PLUGIN_DESCRIPTIONS( simple_plugin_static_caps_description.xml ) # install description file + ### Advanced Synchronization Plugin ###### OPENSYNC_PLUGIN_ADD( example_plugin plugin.c ) TARGET_LINK_LIBRARIES( example_plugin ${OPENSYNC_LIBRARIES} ) Copied and modified: trunk/docs/examples/plugins/src/simple_plugin_static_caps.c (from r5970, trunk/docs/examples/plugins/src/simple_plugin.c) ============================================================================== --- trunk/docs/examples/plugins/src/simple_plugin.c Mon Jan 4 22:10:37 2010 (r5970, copy source) +++ trunk/docs/examples/plugins/src/simple_plugin_static_caps.c Sun Jan 10 16:22:03 2010 (r5984) @@ -296,9 +296,8 @@ osync_objtype_sink_set_available(sink, TRUE); OSyncVersion *version = osync_version_new(error); - osync_version_set_plugin(version, "<your plugin-name>"); - //osync_version_set_version(version, "version"); - //osync_version_set_modelversion(version, "version"); + osync_version_set_plugin(version, "simple-plugin-static-caps"); + //osync_version_set_modelversion(version, "modelversion"); //osync_version_set_firmwareversion(version, "firmwareversion"); //osync_version_set_softwareversion(version, "softwareversion"); //osync_version_set_hardwareversion(version, "hardwareversion"); @@ -319,7 +318,7 @@ goto error; //Tell opensync something about your plugin - osync_plugin_set_name(plugin, "short name, maybe < 15 chars"); + osync_plugin_set_name(plugin, "simple-plugin-static-caps"); osync_plugin_set_longname(plugin, "long name. maybe < 50 chars"); osync_plugin_set_description(plugin, "A longer description. < 200 chars"); Added: trunk/docs/examples/plugins/src/simple_plugin_static_caps_capabilities.xml ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/docs/examples/plugins/src/simple_plugin_static_caps_capabilities.xml Sun Jan 10 16:22:03 2010 (r5984) @@ -0,0 +1,17 @@ +<?xml version="1.0"?> +<Caps Version="1.0" CapsFormat="<fill in capsformat>"> + <ObjType Name="<fill in objtype>" ObjFormat="<fill in objformat>"> + <Cap> + <Name>CapabilityName1</Name> + </Cap> + <Cap> + <Name>CAP2</Name> + </Cap> + <Cap> + <Name>Name</Name> + </Cap> + <Cap> + <Name>Telephone</Name> + </Cap> + </ObjType> +</Caps> Added: trunk/docs/examples/plugins/src/simple_plugin_static_caps_description.xml ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/docs/examples/plugins/src/simple_plugin_static_caps_description.xml Sun Jan 10 16:22:03 2010 (r5984) @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<versions version="0.1"> + <version> + <PlugIn>simple_plugin_static_caps</PlugIn> + <Priority>50</Priority> + <Vendor></Vendor> + <ModelVersion></ModelVersion> + <FirmwareVersion></FirmwareVersion> + <SoftwareVersion></SoftwareVersion> + <HardwareVersion></HardwareVersion> + <Identifier>simple_plugin_static_caps_capabilities.xml</Identifier> + </version> +</versions> + + |
From: <svn...@op...> - 2010-01-10 15:17:14
|
Author: markellis Date: Sun Jan 10 16:17:04 2010 New Revision: 5983 URL: http://www.opensync.org/changeset/5983 Log: update for libopensync API changes Modified: plugins/python-module/CMakeLists.txt plugins/python-module/src/CMakeLists.txt plugins/python-module/src/python_module.c Modified: plugins/python-module/CMakeLists.txt ============================================================================== --- plugins/python-module/CMakeLists.txt Sun Jan 10 16:09:19 2010 (r5982) +++ plugins/python-module/CMakeLists.txt Sun Jan 10 16:17:04 2010 (r5983) @@ -1,12 +1,18 @@ PROJECT( libopensync-plugin-python C ) -SET( VERSION "0.38" ) +SET( VERSION "0.40" ) SET( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules" ) +CMAKE_MINIMUM_REQUIRED( VERSION 2.4.4 ) + +IF(COMMAND cmake_policy) + cmake_policy(SET CMP0003 NEW) +ENDIF(COMMAND cmake_policy) + INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) -SET( OPENSYNC_MIN_VERSION "0.37" ) +SET( OPENSYNC_MIN_VERSION "0.40" ) FIND_PACKAGE( OpenSync REQUIRED ) FIND_PACKAGE( PythonLibs REQUIRED ) Modified: plugins/python-module/src/CMakeLists.txt ============================================================================== --- plugins/python-module/src/CMakeLists.txt Sun Jan 10 16:09:19 2010 (r5982) +++ plugins/python-module/src/CMakeLists.txt Sun Jan 10 16:17:04 2010 (r5983) @@ -1,6 +1,9 @@ LINK_DIRECTORIES( ${OPENSYNC_LIBRARY_DIRS} ${GLIB2_LIBRARY_DIRS} ) INCLUDE_DIRECTORIES( ${OPENSYNC_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} ${PYTHON_INCLUDE_PATH} ) +IF(COMMAND cmake_policy) + cmake_policy(SET CMP0005 OLD) +ENDIF(COMMAND cmake_policy) ADD_DEFINITIONS( -DOPENSYNC_PYTHONPLG_DIR="\\\"${OPENSYNC_PYTHONPLG_DIR}\\\"" ) # python plugin module source Modified: plugins/python-module/src/python_module.c ============================================================================== --- plugins/python-module/src/python_module.c Sun Jan 10 16:09:19 2010 (r5982) +++ plugins/python-module/src/python_module.c Sun Jan 10 16:17:04 2010 (r5983) @@ -159,7 +159,7 @@ * - function(info, context) * - function(info, context, change) */ -static osync_bool pm_call_module_method(MemberData *data, char *name, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *chg) +static osync_bool pm_call_module_method(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata, char *name, OSyncChange *chg) { osync_trace(TRACE_ENTRY, "%s(%s, %p, %p, %p)", __func__, name, info, ctx, chg); PyObject *ret = NULL; @@ -168,21 +168,24 @@ PyGILState_STATE pystate = PyGILState_Ensure(); - PyObject *pyinfo = pm_make_info(data->osync_module, info, &error); + PyObject *osync_module = NULL; + if (!(osync_module = pm_load_opensync(&error))) + goto error; + + PyObject *pyinfo = pm_make_info(osync_module, info, &error); if (!pyinfo) goto error; - PyObject *pycontext = pm_make_context(data->osync_module, ctx, &error); + PyObject *pycontext = pm_make_context(osync_module, ctx, &error); if (!pycontext) { Py_DECREF(pyinfo); goto error; } - OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); - PyObject *sink_pyobject = osync_objtype_sink_get_userdata(sink); + PyObject *sink_pyobject = userdata; if (chg) { - PyObject *pychange = pm_make_change(data->osync_module, chg, &error); + PyObject *pychange = pm_make_change(osync_module, chg, &error); if (!pychange) { Py_DECREF(pyinfo); Py_DECREF(pycontext); @@ -201,6 +204,7 @@ if (ret) { Py_DECREF(pycontext); Py_DECREF(ret); + Py_XDECREF(osync_module); PyGILState_Release(pystate); osync_context_report_success(ctx); osync_trace(TRACE_EXIT, "%s", __func__); @@ -212,7 +216,7 @@ PyErr_Fetch(&pytype, &pyvalue, &pytraceback); PyObject *osyncerror = NULL; - osyncerror = PyObject_GetAttrString(data->osync_module, "Error"); + osyncerror = PyObject_GetAttrString(osync_module, "Error"); if (!osyncerror) { PYERR_CLEAR(); osync_error_set(&error, OSYNC_ERROR_GENERIC, "Failed to get OSyncError class object"); @@ -256,6 +260,7 @@ Py_XDECREF(osyncerror); error: + Py_XDECREF(osync_module); PyGILState_Release(pystate); if (report_error) osync_context_report_osyncerror(ctx, error); @@ -263,51 +268,46 @@ return FALSE; } -static void pm_connect(void *data, OSyncPluginInfo *info, OSyncContext *ctx) +static void pm_connect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata) { - pm_call_module_method(data, "connect", info, ctx, NULL); + pm_call_module_method(sink, info, ctx, userdata, "connect", NULL); } -static void pm_disconnect(void *data, OSyncPluginInfo *info, OSyncContext *ctx) +static void pm_disconnect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata) { - pm_call_module_method(data, "disconnect", info, ctx, NULL); + pm_call_module_method(sink, info, ctx, userdata, "disconnect", NULL); } -static void pm_get_changes(void *data, OSyncPluginInfo *info, OSyncContext *ctx) +static void pm_get_changes(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, osync_bool slow_sync, void *userdata) { - pm_call_module_method(data, "get_changes", info, ctx, NULL); + pm_call_module_method(sink, info, ctx, userdata, "get_changes", NULL); } -static void pm_commit(void *data, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change) +static void pm_commit(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change, void *userdata) { - pm_call_module_method(data, "commit", info, ctx, change); + pm_call_module_method(sink, info, ctx, userdata, "commit", change); } -static void pm_committed_all(void *data, OSyncPluginInfo *info, OSyncContext *ctx) +static void pm_committed_all(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata) { - pm_call_module_method(data, "committed_all", info, ctx, NULL); + pm_call_module_method(sink, info, ctx, userdata, "committed_all", NULL); } -static osync_bool pm_read(void *data, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change) +static void pm_read(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change, void *userdata) { - return pm_call_module_method(data, "read", info, ctx, change); + pm_call_module_method(sink, info, ctx, userdata, "read", change); +} + +static void pm_sync_done(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata) +{ + pm_call_module_method(sink, info, ctx, userdata, "sync_done", NULL); } -static void pm_sync_done(void *data, OSyncPluginInfo *info, OSyncContext *ctx) +static void pm_connect_done(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, osync_bool slow_sync, void *userdata) { - pm_call_module_method(data, "sync_done", info, ctx, NULL); + pm_call_module_method(sink, info, ctx, userdata, "sync_done", NULL); } -static OSyncObjTypeSinkFunctions pm_sink_functions = { - .connect = pm_connect, - .disconnect = pm_disconnect, - .get_changes = pm_get_changes, - .commit = pm_commit, - .committed_all = pm_committed_all, - .read = pm_read, - .batch_commit = NULL, /* not (yet) supported for python plugins */ - .sync_done = pm_sync_done -}; /** Calls the method initialize function * @@ -319,6 +319,8 @@ osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, plugin, info, error); MemberData *data = g_malloc0(sizeof(MemberData)); char *modulename; + OSyncList *s, *sinks = NULL; + OSyncObjTypeSink *sink = NULL; if (!(modulename = osync_plugin_get_data(plugin))) return NULL; @@ -352,14 +354,22 @@ Py_DECREF(ret); /* loop through all objtype sinks, set up function pointers */ - int n, max = osync_plugin_info_num_objtypes(info); - for (n = 0; n < max; n++) { - OSyncObjTypeSink *sink = osync_plugin_info_nth_objtype(info, n); - PyObject *sinkobj = osync_objtype_sink_get_userdata(sink); - osync_objtype_sink_set_functions(sink, pm_sink_functions, sinkobj); - Py_INCREF(sinkobj); - data->sinks = g_slist_prepend(data->sinks, sinkobj); + + sinks = osync_plugin_info_get_objtype_sinks(info); + for (s = sinks; s; s = s->next) { + sink = (OSyncObjTypeSink *)s; + + osync_objtype_sink_set_connect_func(sink, pm_connect); + osync_objtype_sink_set_disconnect_func(sink, pm_disconnect); + osync_objtype_sink_set_get_changes_func(sink, pm_get_changes); + osync_objtype_sink_set_commit_func(sink, pm_commit); + osync_objtype_sink_set_committed_all_func(sink, pm_committed_all); + osync_objtype_sink_set_read_func(sink, pm_read); + osync_objtype_sink_set_sync_done_func(sink, pm_sync_done); + osync_objtype_sink_set_connect_done_func(sink, pm_connect_done); + } + osync_list_free(sinks); PyGILState_Release(pystate); osync_trace(TRACE_EXIT, "%s", __func__); @@ -374,7 +384,7 @@ return NULL; } -static osync_bool pm_discover(void *data_in, OSyncPluginInfo *info, OSyncError **error) +static osync_bool pm_discover(OSyncPluginInfo *info, void *data_in, OSyncError **error) { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data_in, info, error); @@ -474,7 +484,10 @@ osync_plugin_set_discover(plugin, pm_discover); osync_plugin_set_finalize(plugin, pm_finalize); osync_plugin_set_data(plugin, g_strdup(modulename)); - osync_plugin_env_register_plugin(env, plugin); + + if (!osync_plugin_env_register_plugin(env, plugin, error)) + return FALSE; + osync_plugin_unref(plugin); osync_trace(TRACE_EXIT, "%s", __func__); @@ -597,7 +610,7 @@ PyEval_ReleaseLock(); } else if (!PyEval_ThreadsInitialized()) { /* Python has been initialised, but threads are not. */ - osync_error_set(error, OSYNC_ERROR_GENERIC, "The Python interpreter in this process has been initialised without threading support."); + osync_error_set(error, OSYNC_ERROR_GENERIC, "The Python interpreter in this process has been initialised without threading support."); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return FALSE; } |
From: <svn...@op...> - 2010-01-10 15:09:30
|
Author: markellis Date: Sun Jan 10 16:09:19 2010 New Revision: 5982 URL: http://www.opensync.org/changeset/5982 Log: wrapper modifications due to API changes, sufficient to allow a clean import into python Modified: trunk/ChangeLog trunk/wrapper/opensync-engine.i trunk/wrapper/opensync-format.i trunk/wrapper/opensync-group.i trunk/wrapper/opensync-merger.i trunk/wrapper/opensync-plugin.i trunk/wrapper/opensync-version.i Modified: trunk/ChangeLog ============================================================================== --- trunk/ChangeLog Sun Jan 10 15:59:08 2010 (r5981) +++ trunk/ChangeLog Sun Jan 10 16:09:19 2010 (r5982) @@ -1,3 +1,8 @@ +2010-01-10 Mark Ellis <ma...@mp...> + + * wrapper/opensync-{engine,format,group,merger,plugin,version}.i: modifications due to API + changes, sufficient to allow a clean import into python + 2009-02-04 Graham Cobb <g+...@co...> * opensync/group/opensync_member.c (osync_member_load): Use osync_member_add_objtype_sink Modified: trunk/wrapper/opensync-engine.i ============================================================================== --- trunk/wrapper/opensync-engine.i Sun Jan 10 15:59:08 2010 (r5981) +++ trunk/wrapper/opensync-engine.i Sun Jan 10 16:09:19 2010 (r5982) @@ -250,7 +250,7 @@ %pythoncode %{ - group = property(get_group) + # group = property(get_group) # archive = property(get_archive) %} } Modified: trunk/wrapper/opensync-format.i ============================================================================== --- trunk/wrapper/opensync-format.i Sun Jan 10 15:59:08 2010 (r5981) +++ trunk/wrapper/opensync-format.i Sun Jan 10 16:09:19 2010 (r5982) @@ -278,9 +278,9 @@ __oldinit = __init__ def __init__(self, *args): self.__oldinit(*args) - /* - self.filters = _ListWrapper(self.num_filters, self.nth_filter) - */ + + # self.filters = _ListWrapper(self.num_filters, self.nth_filter) + %} } Modified: trunk/wrapper/opensync-group.i ============================================================================== --- trunk/wrapper/opensync-group.i Sun Jan 10 15:59:08 2010 (r5981) +++ trunk/wrapper/opensync-group.i Sun Jan 10 16:09:19 2010 (r5982) @@ -38,11 +38,29 @@ osync_group_env_remove_group(self, group); } + int num_groups() { + OSyncList *groups = osync_group_env_get_groups(self); + unsigned int num = osync_list_length(groups); + osync_list_free(groups); + return num; + } + + Group *nth_group(int nth) { + OSyncList *groups = osync_group_env_get_groups(self); + + Group *group = (OSyncGroup*)osync_list_nth_data(groups, nth); + if (group) + osync_group_ref(group); + osync_list_free(groups); + return group; + } + %pythoncode %{ # extend the SWIG-generated constructor, so that we can setup our list-wrapper classes __oldinit = __init__ def __init__(self, *args): self.__oldinit(*args) + self.groups = _ListWrapper(self.num_groups, self.nth_group) %} } @@ -132,7 +150,24 @@ Member *member = osync_group_find_member(self, id); if (member) osync_member_ref(member); - return member; + return member; + } + + int num_members() { + OSyncList *members = osync_group_get_members(self); + unsigned int num = osync_list_length(members); + osync_list_free(members); + return num; + } + + Member *nth_member(int nth) { + OSyncList *members = osync_group_get_members(self); + + Member *member = (Member*)osync_list_nth_data(members, nth); + if (member) + osync_member_ref(member); + osync_list_free(members); + return member; } const char *get_configdir() { @@ -143,6 +178,21 @@ osync_group_set_configdir(self, directory); } + int num_objtypes() { + OSyncList *objtypes = osync_group_get_objtypes(self); + unsigned int num = osync_list_length(objtypes); + osync_list_free(objtypes); + return num; + } + + const char *nth_objtype(int nth) { + OSyncList *objtypes = osync_group_get_objtypes(self); + + const char *objtype = (const char*)osync_list_nth_data(objtypes, nth); + osync_list_free(objtypes); + return objtype; + } + void set_objtype_enabled(const char *objtype, bool enabled) { osync_group_set_objtype_enabled(self, objtype, enabled); } @@ -205,7 +255,7 @@ %pythoncode %{ name = property(get_name, set_name) configdir = property(get_configdir, set_configdir) - last_synchronization = property(get_last_synchronization, set_last_synchronization) + last_synchronization = property(get_last_synchronization) merger_enabled = property(get_merger_enabled, set_merger_enabled) converter_enabled = property(get_converter_enabled, set_converter_enabled) @@ -213,21 +263,14 @@ __oldinit = __init__ def __init__(self, *args): self.__oldinit(*args) - /* - self.filters = _ListWrapper(self.num_filters, self.nth_filter) - */ + + self.members = _ListWrapper(self.num_members, self.nth_member) + self.objtypes = _ListWrapper(self.num_objtypes, self.nth_objtype) + # self.filters = _ListWrapper(self.num_filters, self.nth_filter) %} } -typedef enum {} StartType; - -%constant int START_TYPE_UNKNOWN = OSYNC_START_TYPE_UNKNOWN; -%constant int START_TYPE_PROCESS = OSYNC_START_TYPE_PROCESS; -%constant int START_TYPE_THREAD = OSYNC_START_TYPE_THREAD; -%constant int START_TYPE_EXTERNAL = OSYNC_START_TYPE_EXTERNAL; - - typedef struct {} Member; %extend Member { Member() { Modified: trunk/wrapper/opensync-merger.i ============================================================================== --- trunk/wrapper/opensync-merger.i Sun Jan 10 15:59:08 2010 (r5981) +++ trunk/wrapper/opensync-merger.i Sun Jan 10 16:09:19 2010 (r5982) @@ -130,6 +130,10 @@ return; } + const char *get_objtype() { + return osync_xmlformat_get_objtype(self); + } + %pythoncode %{ objtype = property(get_objtype) %} Modified: trunk/wrapper/opensync-plugin.i ============================================================================== --- trunk/wrapper/opensync-plugin.i Sun Jan 10 15:59:08 2010 (r5981) +++ trunk/wrapper/opensync-plugin.i Sun Jan 10 16:09:19 2010 (r5982) @@ -4,6 +4,13 @@ %constant int PLUGIN_OPTIONAL_CONFIGURATION = OSYNC_PLUGIN_OPTIONAL_CONFIGURATION; %constant int PLUGIN_NEEDS_CONFIGURATION = OSYNC_PLUGIN_NEEDS_CONFIGURATION; +typedef enum {} StartType; + +%constant int START_TYPE_UNKNOWN = OSYNC_START_TYPE_UNKNOWN; +%constant int START_TYPE_PROCESS = OSYNC_START_TYPE_PROCESS; +%constant int START_TYPE_THREAD = OSYNC_START_TYPE_THREAD; +%constant int START_TYPE_EXTERNAL = OSYNC_START_TYPE_EXTERNAL; + typedef struct {} Plugin; %extend Plugin { @@ -123,7 +130,9 @@ int num_plugins() { OSyncList *plugins = osync_plugin_env_get_plugins(self); - return osync_list_length(plugins); + unsigned int num = osync_list_length(plugins); + osync_list_free(plugins); + return num; } Plugin *nth_plugin(int nth) { @@ -132,6 +141,7 @@ Plugin *plugin = (OSyncPlugin*)osync_list_nth_data(plugins, nth); if (plugin) osync_plugin_ref(plugin); + osync_list_free(plugins); return plugin; } @@ -270,7 +280,7 @@ config = property(get_config, set_config) main_sink = property(get_main_sink, set_main_sink) format_env = property(get_format_env, set_format_env) - sink = property(get_sink, set_sink) + # sink = property(get_sink, set_sink) groupname = property(get_groupname, set_groupname) version = property(get_version, set_version) capabilities = property(get_capabilities, set_capabilities) @@ -411,7 +421,7 @@ void committed_all(PluginInfo *info, Context *ctx) { osync_objtype_sink_committed_all(self, info, ctx); } - + */ bool is_enabled() { return osync_objtype_sink_is_enabled(self); } @@ -443,7 +453,24 @@ void set_read(bool read) { osync_objtype_sink_set_read(self, read); } - + + unsigned int num_objformatsinks() { + OSyncList *objformatsinks = osync_objtype_sink_get_objformat_sinks(self); + unsigned int num = osync_list_length(objformatsinks); + osync_list_free(objformatsinks); + return num; + } + + ObjFormatSink *nth_objformatsink(int nth) { + OSyncList *objformatsinks = osync_objtype_sink_get_objformat_sinks(self); + ObjFormatSink *ret = (ObjFormatSink*)osync_list_nth_data(objformatsinks, nth); + if (ret) + osync_objformat_sink_ref(ret); + osync_list_free(objformatsinks); + return ret; + } + + /* void set_slowsync(bool slowsync) { osync_objtype_sink_set_slowsync(self, slowsync); } @@ -463,14 +490,14 @@ available = property(is_available, set_available) write = property(get_write, set_write) read = property(get_read, set_read) - slowsync = property(get_slowsync, set_slowsync) - callback_obj = property(get_callback_obj) + #slowsync = property(get_slowsync, set_slowsync) + #callback_obj = property(get_callback_obj) # extend the SWIG-generated constructor, so that we can setup our list-wrapper classes __oldinit = __init__ def __init__(self, *args): self.__oldinit(*args) - self.objformats = _ListWrapper(self.num_objformats, self.nth_objformat) + self.objformats = _ListWrapper(self.num_objformatsinks, self.nth_objformatsink) %} } Modified: trunk/wrapper/opensync-version.i ============================================================================== --- trunk/wrapper/opensync-version.i Sun Jan 10 15:59:08 2010 (r5981) +++ trunk/wrapper/opensync-version.i Sun Jan 10 16:09:19 2010 (r5982) @@ -99,13 +99,13 @@ } %pythoncode %{ - plugin = property(get_plugin, set_plugin) - priority = property(get_priority, set_priority) - vendor = property(get_vendor, set_vendor) - modelversion = property(get_modelversion, set_modelversion) - firmwareversion = property(get_firmwareversion, set_firmwareversion) - softwareversion = property(get_softwareversion, set_softwareversion) - hardwareversion = property(get_hardwareversion, set_hardwareversion) - identifier = property(get_identifier, set_identifier) +# plugin = property(get_plugin, set_plugin) +# priority = property(get_priority, set_priority) +# vendor = property(get_vendor, set_vendor) +# modelversion = property(get_modelversion, set_modelversion) +# firmwareversion = property(get_firmwareversion, set_firmwareversion) +# softwareversion = property(get_softwareversion, set_softwareversion) +# hardwareversion = property(get_hardwareversion, set_hardwareversion) +# identifier = property(get_identifier, set_identifier) %} }; |
From: <svn...@op...> - 2010-01-10 14:59:19
|
Author: dgollub Date: Sun Jan 10 15:59:08 2010 New Revision: 5981 URL: http://www.opensync.org/changeset/5981 Log: Added TODO comments about avoiding sorting. Sorting is complex: O(N) and causes performance looses... refs #923 Modified: format-plugins/xmlformat/trunk/src/xmlformat.c Modified: format-plugins/xmlformat/trunk/src/xmlformat.c ============================================================================== --- format-plugins/xmlformat/trunk/src/xmlformat.c Sun Jan 10 15:57:16 2010 (r5980) +++ format-plugins/xmlformat/trunk/src/xmlformat.c Sun Jan 10 15:59:08 2010 (r5981) @@ -67,7 +67,8 @@ return FALSE; } - if(!osync_xmlformat_sort(xmlformat, error)) { + /* TODO: Try to avoid sorting */ + if (!osync_xmlformat_sort(xmlformat, error)) { osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return FALSE; } @@ -308,6 +309,7 @@ osync_trace(TRACE_ENTRY, "%s(%p, %u, %p, %p)", __func__, data, size, attribute, error); + /* TODO: Avoid sorting somehow */ if (!osync_xmlformat_sort((OSyncXMLFormat *)data, error)) goto error; |
From: <svn...@op...> - 2010-01-10 14:57:27
|
Author: dgollub Date: Sun Jan 10 15:57:16 2010 New Revision: 5980 URL: http://www.opensync.org/changeset/5980 Log: Applied patch from paule, scriptor which introduces sorting for XMLFormat plugin. In future versions we should try to find a way to avoid sorting as often as possible. fixes #923 Modified: format-plugins/xmlformat/trunk/src/xmlformat.c Modified: format-plugins/xmlformat/trunk/src/xmlformat.c ============================================================================== --- format-plugins/xmlformat/trunk/src/xmlformat.c Wed Jan 6 21:53:30 2010 (r5979) +++ format-plugins/xmlformat/trunk/src/xmlformat.c Sun Jan 10 15:57:16 2010 (r5980) @@ -67,6 +67,11 @@ return FALSE; } + if(!osync_xmlformat_sort(xmlformat, error)) { + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; + } + *output = (char *) xmlformat; *outpsize = osync_xmlformat_size(); @@ -303,6 +308,9 @@ osync_trace(TRACE_ENTRY, "%s(%p, %u, %p, %p)", __func__, data, size, attribute, error); + if (!osync_xmlformat_sort((OSyncXMLFormat *)data, error)) + goto error; + fieldlist = osync_xmlformat_search_field((OSyncXMLFormat *)data, attribute, error, NULL); if (!fieldlist) goto error; |
From: <svn...@op...> - 2010-01-06 20:53:41
|
Author: scriptor Date: Wed Jan 6 21:53:30 2010 New Revision: 5979 URL: http://www.opensync.org/changeset/5979 Log: The user can now choose which LDAP library the LDAP plugin is to be linked against, when he runs cmake: Link it against libldap from openldap ( http://www.openldap.org/ ): -DUSE_OPENLDAP=on Link it against libldap60 from the Mozilla LDAP C SDK ( http://www.mozilla.org/directory/csdk.html ): -DUSE_MOZLDAP=on The previous version always chose openldap. Mozldap could only be used, when libldap from openldap was not found (not installed). Now, the user can easily switch between both libraries. Modified: plugins/ldap-sync/CMakeLists.txt plugins/ldap-sync/INSTALL plugins/ldap-sync/src/CMakeLists.txt plugins/ldap-sync/src/ldap_plugin.h Modified: plugins/ldap-sync/CMakeLists.txt ============================================================================== --- plugins/ldap-sync/CMakeLists.txt Wed Jan 6 21:53:17 2010 (r5978) +++ plugins/ldap-sync/CMakeLists.txt Wed Jan 6 21:53:30 2010 (r5979) @@ -55,25 +55,222 @@ FIND_PACKAGE( LibXslt REQUIRED ) FIND_PACKAGE( LibLdap ) FIND_PACKAGE( LibMozLdap ) -FIND_PACKAGE( LibSASL2 ) -FIND_PACKAGE( LibGSSAPIV2 ) -FIND_PACKAGE( Check ) -IF ( NOT CHECK_FOUND ) - MESSAGE( STATUS " Could NOT find the check library: \"check\" or \"libcheck\": http://check.sourceforge.net/ . The test suite can NOT be built, therefore.") -ENDIF ( NOT CHECK_FOUND ) -# By default use openldap, if available. -# Fall back to mozldap only, if necessary (and possible, of course). +IF ( USE_OPENLDAP ) + # The user prefers openldap. So try and usd this particular library. + MESSAGE( STATUS "User has defined USE_OPENLDAP." ) + IF ( LIBLDAP_FOUND ) + SET ( USE_OPENLDAP 1 ) + # libldap and liblber from openldap + IF ( LIBLBER_FOUND ) + SET ( _LDAP_INCLUDE_DIRS ${LDAP_INCLUDE_DIR} ${LBER_INCLUDE_DIR} ) + ELSE ( LIBLBER_FOUND ) + SET ( _LDAP_INCLUDE_DIRS ${LDAP_INCLUDE_DIR} ) + ENDIF ( LIBLBER_FOUND ) + + IF ( LIBLBER_FOUND ) + SET ( _LDAP_LIBRARY_DIRS ${LDAP_LIBRARY_DIRS} ${LBER_LIBRARY_DIRS} ) + ELSE ( LIBLBER_FOUND ) + SET ( _LDAP_LIBRARY_DIRS ${LDAP_LIBRARY_DIRS} ) + ENDIF ( LIBLBER_FOUND ) + + IF ( LIBLBER_FOUND) + SET ( _LDAP_LIBRARIES ${LDAP_LIBRARY} ${LBER_LIBRARY} ) + ELSE ( LIBLBER_FOUND) + SET ( _LDAP_LIBRARIES ${LDAP_LIBRARY} ) + ENDIF ( LIBLBER_FOUND) + + ELSE ( LIBLDAP_FOUND ) + MESSAGE ( FATAL_ERROR " libldap from openldap could NOT be found, although USE_OPENLDAP has been defined. " ) + ENDIF ( LIBLDAP_FOUND ) + +ELSE ( USE_OPENLDAP ) + IF ( USE_MOZLDAP ) + # The user prefers mozldap. So try and usd this particular library. + MESSAGE ( STATUS "User has defined USE_MOZLDAP." ) + IF ( LIBMOZLDAP_FOUND ) + SET ( USE_MOZLDAP 1 ) + #libldap60 from Mozilla + IF ( MOZLDAP_INCLUDE_DIR ) + SET ( _LDAP_INCLUDE_DIRS ${MOZLDAP_INCLUDE_DIR} ) + ELSE ( MOZLDAP_INCLUDE_DIR ) + IF ( LIBMOZLDAP_INCLUDEDIR ) + SET ( _LDAP_INCLUDE_DIRS ${LIBMOZLDAP_INCLUDEDIR}) + ENDIF ( LIBMOZLDAP_INCLUDEDIR ) + ENDIF ( MOZLDAP_INCLUDE_DIR ) + + IF ( LIBMOZLDAP_LIBDIR ) + SET ( _LDAP_LIBRARY_DIRS ${LIBMOZLDAP_LIBDIR} ) + ENDIF ( LIBMOZLDAP_LIBDIR ) + + IF ( LIBMOZLDAP_LIBRARIES ) + SET ( _LDAP_LIBRARIES ${LIBMOZLDAP_LIBRARIES} ) + ELSE ( LIBMOZLDAP_LIBRARIES ) + IF ( MOZLDAP_LIBRARY ) + SET ( _LDAP_LIBRARIES ${MOZLDAP_LIBRARY} ) + ELSE ( MOZLDAP_LIBRARY ) + MESSAGE( FATAL_ERROR " Neither LIBMOZLDAP_LIBRARIES nor MOZLDAP_LIBRARY has been defined." ) + ENDIF ( MOZLDAP_LIBRARY ) + ENDIF ( LIBMOZLDAP_LIBRARIES ) + + ELSE ( LIBMOZLDAP_FOUND ) + MESSAGE (FATAL_ERROR " libmozldap from the Mozilla LDAP C SDK could NOT be found, although USE_MOZLDAP has been defined. " ) + ENDIF ( LIBMOZLDAP_FOUND ) + ELSE ( USE_MOZLDAP ) + # The user has no particular preference with regard to the LDAP library. + # By default use openldap, if available. + # Fall back to mozldap only, if necessary (and possible, of course). + MESSAGE ( STATUS "User has not chosen a particular LDAP library." ) + IF ( LIBLDAP_FOUND ) + SET ( USE_OPENLDAP 1 ) + # libldap and liblber from openldap + IF ( LIBLBER_FOUND ) + SET ( _LDAP_INCLUDE_DIRS ${LDAP_INCLUDE_DIR} ${LBER_INCLUDE_DIR} ) + ELSE ( LIBLBER_FOUND ) + SET ( _LDAP_INCLUDE_DIRS ${LDAP_INCLUDE_DIR} ) + ENDIF ( LIBLBER_FOUND ) + + IF ( LIBLBER_FOUND ) + SET ( _LDAP_LIBRARY_DIRS ${LDAP_LIBRARY_DIRS} ${LBER_LIBRARY_DIRS} ) + ELSE ( LIBLBER_FOUND ) + SET ( _LDAP_LIBRARY_DIRS ${LDAP_LIBRARY_DIRS} ) + ENDIF ( LIBLBER_FOUND ) + + IF ( LIBLBER_FOUND) + SET ( _LDAP_LIBRARIES ${LDAP_LIBRARY} ${LBER_LIBRARY} ) + ELSE ( LIBLBER_FOUND) + SET ( _LDAP_LIBRARIES ${LDAP_LIBRARY} ) + ENDIF ( LIBLBER_FOUND) + + ELSE ( LIBLDAP_FOUND ) + IF ( LIBMOZLDAP_FOUND ) + SET ( USE_MOZLDAP 1 ) + #libldap60 from Mozilla + IF ( MOZLDAP_INCLUDE_DIR ) + SET ( _LDAP_INCLUDE_DIRS ${MOZLDAP_INCLUDE_DIR} ) + ELSE ( MOZLDAP_INCLUDE_DIR ) + IF ( LIBMOZLDAP_INCLUDEDIR ) + SET ( _LDAP_INCLUDE_DIRS ${LIBMOZLDAP_INCLUDEDIR}) + ENDIF ( LIBMOZLDAP_INCLUDEDIR ) + ENDIF ( MOZLDAP_INCLUDE_DIR ) + + IF ( LIBMOZLDAP_LIBDIR ) + SET ( _LDAP_LIBRARY_DIRS ${LIBMOZLDAP_LIBDIR} ) + ENDIF ( LIBMOZLDAP_LIBDIR ) + + IF ( LIBMOZLDAP_LIBRARIES ) + SET ( _LDAP_LIBRARIES ${LIBMOZLDAP_LIBRARIES} ) + ELSE ( LIBMOZLDAP_LIBRARIES ) + IF ( MOZLDAP_LIBRARY ) + SET ( _LDAP_LIBRARIES ${MOZLDAP_LIBRARY} ) + ELSE ( MOZLDAP_LIBRARY ) + MESSAGE( FATAL_ERROR " Neither LIBMOZLDAP_LIBRARIES nor MOZLDAP_LIBRARY has been defined." ) + ENDIF ( MOZLDAP_LIBRARY ) + ENDIF ( LIBMOZLDAP_LIBRARIES ) + + ELSE ( LIBMOZLDAP_FOUND ) + MESSAGE (FATAL_ERROR " Neither libmozldap from the Mozilla LDAP C SDK nor libldap from openldap could be found. " ) + ENDIF ( LIBMOZLDAP_FOUND ) + ENDIF ( LIBLDAP_FOUND ) + ENDIF ( USE_MOZLDAP) +ENDIF ( USE_OPENLDAP ) + + +#################### + +# Determine _LDAP_INCLUDE_DIRS +IF ( LIBLDAP_FOUND ) +# # libldap and liblber from openldap +# IF ( LIBLBER_FOUND ) +# SET ( _LDAP_INCLUDE_DIRS ${LDAP_INCLUDE_DIR} ${LBER_INCLUDE_DIR} ) +# ELSE ( LIBLBER_FOUND ) +# SET ( _LDAP_INCLUDE_DIRS ${LDAP_INCLUDE_DIR} ) +# ENDIF ( LIBLBER_FOUND ) + +ELSE ( LIBLDAP_FOUND ) + IF ( LIBMOZLDAP_FOUND ) +# #libldap60 from Mozilla +# IF ( MOZLDAP_INCLUDE_DIR ) +# SET ( _LDAP_INCLUDE_DIRS ${MOZLDAP_INCLUDE_DIR} ) +# +# ELSE ( MOZLDAP_INCLUDE_DIR ) +# IF ( LIBMOZLDAP_INCLUDEDIR ) +# SET ( _LDAP_INCLUDE_DIRS ${LIBMOZLDAP_INCLUDEDIR}) +# ENDIF ( LIBMOZLDAP_INCLUDEDIR ) +# ENDIF ( MOZLDAP_INCLUDE_DIR ) + + ELSE ( LIBMOZLDAP_FOUND ) + MESSAGE( FATAL_ERROR " Neither libldap from openldap nor libldap60 from Mozilla could be found. The ldap-sync plugin requires one of these libraries including the header files, as can be found in \"development packages\" or \"SDK's\"." ) + ENDIF ( LIBMOZLDAP_FOUND ) +ENDIF ( LIBLDAP_FOUND ) + + + + +# Determine _LDAP_LIBRARY_DIRS IF ( LIBLDAP_FOUND ) - SET ( USE_OPENLDAP 1 ) +# IF ( LIBLBER_FOUND ) +# SET ( _LDAP_LIBRARY_DIRS ${LDAP_LIBRARY_DIRS} ${LBER_LIBRARY_DIRS} ) +# ELSE ( LIBLBER_FOUND ) +# SET ( _LDAP_LIBRARY_DIRS ${LDAP_LIBRARY_DIRS} ) +# ENDIF ( LIBLBER_FOUND ) +ELSE ( LIBLDAP_FOUND ) +# IF ( LIBMOZLDAP_FOUND ) +# IF ( LIBMOZLDAP_LIBDIR ) +# SET ( _LDAP_LIBRARY_DIRS ${LIBMOZLDAP_LIBDIR} ) +# ENDIF ( LIBMOZLDAP_LIBDIR ) +# ELSE ( LIBMOZLDAP_FOUND ) +# MESSAGE( FATAL_ERROR " Neither libldap from openldap nor libldap60 from Mozilla could be found. The ldap-sync plugin requires one of these." ) +# ENDIF ( LIBMOZLDAP_FOUND ) +ENDIF ( LIBLDAP_FOUND ) + + + + +# Determine _LDAP_LIBRARIES +IF ( LIBLDAP_FOUND ) +# IF ( LIBLBER_FOUND) +# SET ( _LDAP_LIBRARIES ${LDAP_LIBRARY} ${LBER_LIBRARY} ) +# ELSE ( LIBLBER_FOUND) +# SET ( _LDAP_LIBRARIES ${LDAP_LIBRARY} ) +# ENDIF ( LIBLBER_FOUND) ELSE ( LIBLDAP_FOUND ) IF ( LIBMOZLDAP_FOUND ) - SET ( USE_MOZLDAP 1 ) + +# IF ( LIBMOZLDAP_LIBRARIES ) +# SET ( _LDAP_LIBRARIES ${LIBMOZLDAP_LIBRARIES} ) +# +# ELSE ( LIBMOZLDAP_LIBRARIES ) +# IF ( MOZLDAP_LIBRARY ) +# SET ( _LDAP_LIBRARIES ${MOZLDAP_LIBRARY} ) +# ELSE ( MOZLDAP_LIBRARY ) +# MESSAGE( FATAL_ERROR " Neither LIBMOZLDAP_LIBRARIES nor MOZLDAP_LIBRARY has been defined." ) +# ENDIF ( MOZLDAP_LIBRARY ) +# +# ENDIF ( LIBMOZLDAP_LIBRARIES ) + + ELSE ( LIBMOZLDAP_FOUND ) + MESSAGE( FATAL_ERROR " Neither libldap from openldap nor libldap60 from Mozilla could be found. The ldap-sync plugin requires one of these." ) ENDIF ( LIBMOZLDAP_FOUND ) ENDIF ( LIBLDAP_FOUND ) + + +################### + + +FIND_PACKAGE( LibSASL2 ) +FIND_PACKAGE( LibGSSAPIV2 ) +FIND_PACKAGE( Check ) +IF ( NOT CHECK_FOUND ) + MESSAGE( STATUS " Could NOT find the check library: \"check\" or \"libcheck\": http://check.sourceforge.net/ . The test suite can NOT be built, therefore.") +ENDIF ( NOT CHECK_FOUND ) + + + + ############### Doxygen ############################ MESSAGE(STATUS "checking for doxygen...") FIND_PROGRAM( DOXYGEN_EXECUTABLE doxygen ) @@ -201,10 +398,12 @@ MESSAGE(STATUS "LDAP_PLUGIN_OPENSYNC_SCHEMASDIR = ${LDAP_PLUGIN_OPENSYNC_SCHEMASDIR}") IF ( USE_OPENLDAP ) - MESSAGE (STATUS "libldap from openldap is to be used.") + MESSAGE (STATUS "libldap from openldap will be used.") ELSE ( USE_OPENLDAP ) IF ( USE_MOZLDAP ) - MESSAGE (STATUS "libldap60 from Mozilla is to be used.") + MESSAGE (STATUS "libldap60 from Mozilla will be used.") + ELSE ( USE_MOZLDAP ) + MESSAGE (FATAL_ERROR "Neither libldap from openldap nor libldap60 from Mozilla has been chosen. This is not possible. The LDAP plugin requires either of these libraries.") ENDIF ( USE_MOZLDAP ) ENDIF ( USE_OPENLDAP ) Modified: plugins/ldap-sync/INSTALL ============================================================================== --- plugins/ldap-sync/INSTALL Wed Jan 6 21:53:17 2010 (r5978) +++ plugins/ldap-sync/INSTALL Wed Jan 6 21:53:30 2010 (r5979) @@ -13,6 +13,19 @@ ldconfig +By default, the LDAP plugin is linked against libldap from openldap +( http://www.openldap.org/ ). However, the user can choose to link +the LDAP plugin against libldap60 from the Mozilla LDAP C SDK +( http://www.mozilla.org/directory/csdk.html ) by + + -DUSE_MOZLDAP=on + +Likewise, -DUSE_OPENLDAP=on will link it against libldap from openldap. + + + + + B. Debug build: tar -xvjf libopensync-plugin-ldap-0.40.tar.bz2 Modified: plugins/ldap-sync/src/CMakeLists.txt ============================================================================== --- plugins/ldap-sync/src/CMakeLists.txt Wed Jan 6 21:53:17 2010 (r5978) +++ plugins/ldap-sync/src/CMakeLists.txt Wed Jan 6 21:53:30 2010 (r5979) @@ -22,90 +22,6 @@ # - -# Determine _LDAP_INCLUDE_DIRS -IF ( LIBLDAP_FOUND ) - # libldap and liblber from openldap - IF ( LIBLBER_FOUND ) - SET ( _LDAP_INCLUDE_DIRS ${LDAP_INCLUDE_DIR} ${LBER_INCLUDE_DIR} ) - ELSE ( LIBLBER_FOUND ) - SET ( _LDAP_INCLUDE_DIRS ${LDAP_INCLUDE_DIR} ) - ENDIF ( LIBLBER_FOUND ) - -ELSE ( LIBLDAP_FOUND ) - IF ( LIBMOZLDAP_FOUND ) - #libldap60 from Mozilla - IF ( MOZLDAP_INCLUDE_DIR ) - SET ( _LDAP_INCLUDE_DIRS ${MOZLDAP_INCLUDE_DIR} ) - - ELSE ( MOZLDAP_INCLUDE_DIR ) - IF ( LIBMOZLDAP_INCLUDEDIR ) - SET ( _LDAP_INCLUDE_DIRS ${LIBMOZLDAP_INCLUDEDIR}) - ENDIF ( LIBMOZLDAP_INCLUDEDIR ) - ENDIF ( MOZLDAP_INCLUDE_DIR ) - - ELSE ( LIBMOZLDAP_FOUND ) - MESSAGE( FATAL_ERROR " Neither libldap from openldap nor libldap60 from Mozilla could be found. The ldap-sync plugin requires one of these libraries including the header files, as can be found in \"development packages\" or \"SDK's\"." ) - ENDIF ( LIBMOZLDAP_FOUND ) -ENDIF ( LIBLDAP_FOUND ) - - - - -# Determine _LDAP_LIBRARY_DIRS -IF ( LIBLDAP_FOUND ) - IF ( LIBLBER_FOUND ) - SET ( _LDAP_LIBRARY_DIRS ${LDAP_LIBRARY_DIRS} ${LBER_LIBRARY_DIRS} ) - ELSE ( LIBLBER_FOUND ) - SET ( _LDAP_LIBRARY_DIRS ${LDAP_LIBRARY_DIRS} ) - ENDIF ( LIBLBER_FOUND ) -ELSE ( LIBLDAP_FOUND ) - IF ( LIBMOZLDAP_FOUND ) - IF ( LIBMOZLDAP_LIBDIR ) - SET ( _LDAP_LIBRARY_DIRS ${LIBMOZLDAP_LIBDIR} ) - ENDIF ( LIBMOZLDAP_LIBDIR ) - ELSE ( LIBMOZLDAP_FOUND ) - MESSAGE( FATAL_ERROR " Neither libldap from openldap nor libldap60 from Mozilla could be found. The ldap-sync plugin requires one of these." ) - ENDIF ( LIBMOZLDAP_FOUND ) -ENDIF ( LIBLDAP_FOUND ) - - - - -# Determine _LDAP_LIBRARIES -IF ( LIBLDAP_FOUND ) - IF ( LIBLBER_FOUND) - SET ( _LDAP_LIBRARIES ${LDAP_LIBRARY} ${LBER_LIBRARY} ) - ELSE ( LIBLBER_FOUND) - SET ( _LDAP_LIBRARIES ${LDAP_LIBRARY} ) - ENDIF ( LIBLBER_FOUND) -ELSE ( LIBLDAP_FOUND ) - IF ( LIBMOZLDAP_FOUND ) - - IF ( LIBMOZLDAP_LIBRARIES ) - SET ( _LDAP_LIBRARIES ${LIBMOZLDAP_LIBRARIES} ) - - ELSE ( LIBMOZLDAP_LIBRARIES ) - IF ( MOZLDAP_LIBRARY ) - SET ( _LDAP_LIBRARIES ${MOZLDAP_LIBRARY} ) - ELSE ( MOZLDAP_LIBRARY ) - MESSAGE( FATAL_ERROR " Neither LIBMOZLDAP_LIBRARIES nor MOZLDAP_LIBRARY has been defined." ) - ENDIF ( MOZLDAP_LIBRARY ) - - ENDIF ( LIBMOZLDAP_LIBRARIES ) - - ELSE ( LIBMOZLDAP_FOUND ) - MESSAGE( FATAL_ERROR " Neither libldap from openldap nor libldap60 from Mozilla could be found. The ldap-sync plugin requires one of these." ) - ENDIF ( LIBMOZLDAP_FOUND ) -ENDIF ( LIBLDAP_FOUND ) - - - - - - - - # Safety checks IF ( NOT _LDAP_INCLUDE_DIRS ) MESSAGE( FATAL_ERROR " _LDAP_INCLUDE_DIRS could not be determined. The ldap-sync plugin requires the header files of an LDAP client library, either from openldap or from Mozilla." ) Modified: plugins/ldap-sync/src/ldap_plugin.h ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.h Wed Jan 6 21:53:17 2010 (r5978) +++ plugins/ldap-sync/src/ldap_plugin.h Wed Jan 6 21:53:30 2010 (r5979) @@ -39,11 +39,16 @@ #include <ctype.h> #include <glib.h> -#ifdef LIBLDAP_FOUND -#include <lber.h> -#include <ldap.h> -#else -# ifdef LIBMOZLDAP_FOUND + + +#ifdef USE_OPENLDAP + +# include <lber.h> +# include <ldap.h> + +#else // ifdef USE_OPENLDAP + +# ifdef USE_MOZLDAP # ifdef MOZLDAP_INCLUDE_DIR # include <mozldap/ldap.h> # include <mozldap/ldap_ssl.h> @@ -55,8 +60,31 @@ # include <../mozldap/ldap_ssl.h> # endif # endif -# endif -#endif + +# else // ifdef USE_MOZLDAP + +# ifdef LIBLDAP_FOUND +# include <lber.h> +# include <ldap.h> +# else +# ifdef LIBMOZLDAP_FOUND +# ifdef MOZLDAP_INCLUDE_DIR +# include <mozldap/ldap.h> +# include <mozldap/ldap_ssl.h> +# else +# ifdef LIBMOZLDAP_INCLUDEDIR +// I want to make sure that it is really the "mozldap/ldap.h" that +// is to be included. And NOT some /usr/include/ldap.h. +# include <../mozldap/ldap.h> +# include <../mozldap/ldap_ssl.h> +# endif +# endif +# endif +# endif + +# endif // ifdef USE_MOZLDAP +#endif // ifdef USE_OPENLDAP + #include <libxml/parser.h> |
From: <svn...@op...> - 2010-01-06 20:53:33
|
Author: scriptor Date: Wed Jan 6 21:53:17 2010 New Revision: 5978 URL: http://www.opensync.org/changeset/5978 Log: Memory errors which I have no control of need to be suppressed in valgrind. Modified: plugins/ldap-sync/tests/opensync.suppr Modified: plugins/ldap-sync/tests/opensync.suppr ============================================================================== --- plugins/ldap-sync/tests/opensync.suppr Tue Jan 5 22:08:57 2010 (r5977) +++ plugins/ldap-sync/tests/opensync.suppr Wed Jan 6 21:53:17 2010 (r5978) @@ -4403,4 +4403,59 @@ fun:main } +{ + <undefined_values_sqlite3> + Memcheck:Param + write(buf) + obj:/lib64/libc-2.11.so + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + fun:sqlite3_step + fun:sqlite3_exec + fun:osync_db_query + fun:osync_archive_create_changes + fun:osync_archive_flush_changes + fun:osync_mapping_table_flush + fun:osync_obj_engine_initialize + fun:osync_engine_command + fun:_command_dispatch + fun:g_main_context_dispatch + obj:/lib64/libglib-2.0.so.0.2200.2 + fun:g_main_loop_run + obj:/lib64/libglib-2.0.so.0.2200.2 + fun:start_thread +} + +{ + <undefined_values_sqlite4> + Memcheck:Param + write(buf) + obj:/lib64/libc-2.11.so + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + fun:sqlite3_step + fun:sqlite3_exec + fun:osync_db_query + fun:osync_archive_flush_ignored_conflict + fun:osync_obj_engine_command + fun:osync_engine_event + fun:_osync_engine_generate_connect_done_event + fun:_osync_engine_connect_done_callback + fun:_osync_client_proxy_connect_done_handler + fun:_osync_queue_remove_pending_reply + fun:_incoming_dispatch + fun:g_main_context_dispatch + obj:/lib64/libglib-2.0.so.0.2200.2 + fun:g_main_loop_run + obj:/lib64/libglib-2.0.so.0.2200.2 + fun:start_thread +} |
From: <svn...@op...> - 2010-01-05 21:09:12
|
Author: scriptor Date: Tue Jan 5 22:08:57 2010 New Revision: 5977 URL: http://www.opensync.org/changeset/5977 Log: The schema discovery must be performed in two steps rather than just one: 1. Which entry carries the schemata? This is answered by the "subschemaSubentry". 2. Which schemata are available? This is answered by the entry returned in 1. Modified: plugins/ldap-sync/src/ldap_connect.c Modified: plugins/ldap-sync/src/ldap_connect.c ============================================================================== --- plugins/ldap-sync/src/ldap_connect.c Tue Jan 5 19:55:20 2010 (r5976) +++ plugins/ldap-sync/src/ldap_connect.c Tue Jan 5 22:08:57 2010 (r5977) @@ -1169,9 +1169,10 @@ */ osync_bool ldap_plugin_check_ldap_schema_support(OSyncContext *ctx, sink_environment *sinkenv, const char *ldap_schema, osync_bool *result, OSyncError **error) { - LDAPMessage *res = NULL, *res2 = NULL; + LDAPMessage *res = NULL, *res2 = NULL, *res3 = NULL, *res4 = NULL; int i = 0; - struct berval **ber = NULL; + struct berval **ber = NULL, **ber2 = NULL; + char *search_base = NULL; osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p)", __func__, (void *)ctx, (void *)sinkenv, (void *)ldap_schema, (void *)result, (void *)error); @@ -1207,8 +1208,56 @@ *result = FALSE; + // Get the relevant search_base. It may differ from server to server. + if (!ldap_plugin_call_ldap_search(ctx, sinkenv->ld, "", "(objectClass=*)", LDAP_SCOPE_BASE, OPERATIONAL_ATTRIBUTES, sinkenv, TRUE, &res3, error)) { + if (!osync_error_is_set(error)) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_call_ldap_search() has failed.\n", __FILE__, __LINE__); + } + + goto error; + } + + + // subschemaSubentry MUST be present. So it is legitimate, when we error out + // here. + if (res3 == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_call_ldap_search() must have failed.\n", __FILE__, __LINE__); + ldap_plugin_dump_ldap_error_message(sinkenv, __FILE__, __LINE__, "", "", "ldap_plugin_call_ldap_search()"); + + goto error; + } + + + res4 = ldap_first_entry(sinkenv->ld, res3); + if (res4) { + ber2 = ldap_get_values_len(sinkenv->ld, res4, "subschemaSubentry"); + if (ber2) { + while (ber2[i]) { + if (ber2[i]->bv_val) { + search_base = g_strdup(ber2[i]->bv_val); + break; + } + + i++; + } + } + } + + + + + + + // We haven't found the real search_base. So let's assume, it is + // "cn=Subschema". + if (search_base == NULL) { + osync_trace(TRACE_INTERNAL, "%s:%i: WARNING: search_base = NULL. Setting it to \"cn=Subschema\".", __FILE__, __LINE__); + search_base = g_strdup("cn=Subschema"); + } + + // Look for all the LDAP subschemata (as used by slapd from openldap): - if (!ldap_plugin_call_ldap_search(ctx, sinkenv->ld, "cn=Subschema", "(objectClass=subschema)", LDAP_SCOPE_BASE, OBJECTCLASSES, sinkenv, TRUE, &res, error)) { + if (!ldap_plugin_call_ldap_search(ctx, sinkenv->ld, search_base, "(objectClass=subschema)", LDAP_SCOPE_BASE, OBJECTCLASSES, sinkenv, TRUE, &res, error)) { if (!osync_error_is_set(error)) { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_call_ldap_search() has failed.\n", __FILE__, __LINE__); } @@ -1219,7 +1268,7 @@ if (res == NULL) { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_call_ldap_search() must have failed.\n", __FILE__, __LINE__); - ldap_plugin_dump_ldap_error_message(sinkenv, __FILE__, __LINE__, "cn=Subschema", "(objectClass=subschema)", "ldap_plugin_call_ldap_search()"); + ldap_plugin_dump_ldap_error_message(sinkenv, __FILE__, __LINE__, search_base, "(objectClass=subschema)", "ldap_plugin_call_ldap_search()"); goto error; } @@ -1228,17 +1277,12 @@ res2 = ldap_first_entry(sinkenv->ld, res); if (!res2) { /* No objectClass entries found */ -/* - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Could not find any objectClass entry while searching for LDAP subschemata.", __FILE__, __LINE__); - goto error; -*/ - if (res) ldap_msgfree(res); // Look for all the LDAP schemata (as used by ns-slapd from the // fedora directory server): - if (!ldap_plugin_call_ldap_search(ctx, sinkenv->ld, "cn=schema", "(objectClass=subschema)", LDAP_SCOPE_BASE, OBJECTCLASSES, sinkenv, TRUE, &res, error)) { + if (!ldap_plugin_call_ldap_search(ctx, sinkenv->ld, search_base, "(objectClass=subschema)", LDAP_SCOPE_BASE, OBJECTCLASSES, sinkenv, TRUE, &res, error)) { if (!osync_error_is_set(error)) { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_call_ldap_search() has failed.\n", __FILE__, __LINE__); } @@ -1248,7 +1292,7 @@ if (res == NULL) { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_call_ldap_search() must have failed.\n", __FILE__, __LINE__); - ldap_plugin_dump_ldap_error_message(sinkenv, __FILE__, __LINE__, "cn=schema", "(objectClass=subschema)", "ldap_plugin_call_ldap_search()"); + ldap_plugin_dump_ldap_error_message(sinkenv, __FILE__, __LINE__, search_base, "(objectClass=subschema)", "ldap_plugin_call_ldap_search()"); goto error; } @@ -1287,6 +1331,8 @@ if (res) ldap_msgfree(res); + if (search_base) + g_free(search_base); osync_trace(TRACE_EXIT, "%s", __func__); @@ -1300,6 +1346,9 @@ if (res) ldap_msgfree(res); + if (search_base) + g_free(search_base); + if (!osync_error_is_set(error)) osync_error_set(error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); @@ -1501,7 +1550,11 @@ * sub: the current location in the DIT and all of its children * * - * @param kind_of_attributes For example, whether user attributes or control attributes are to be shown. + * @param kind_of_attributes For example, whether user attributes or + * operational attributes are to be shown. + * ldap_plugin.h defines 3 types: USER_ATTRIBUTES, + * OPERATIONAL_ATTRIBUTES and OBJECTCLASSES. + * * @param sinkenv The object type specific environment * @param results This function fills this struct with the search result. * @param ignore_no_such_object This variable tells this function whether |
From: <svn...@op...> - 2010-01-05 18:55:33
|
Author: scriptor Date: Tue Jan 5 19:55:20 2010 New Revision: 5976 URL: http://www.opensync.org/changeset/5976 Log: Two more memory errors outside of the LDAP plugin need to be suppressed. Modified: plugins/ldap-sync/tests/opensync.suppr Modified: plugins/ldap-sync/tests/opensync.suppr ============================================================================== --- plugins/ldap-sync/tests/opensync.suppr Tue Jan 5 19:55:02 2010 (r5975) +++ plugins/ldap-sync/tests/opensync.suppr Tue Jan 5 19:55:20 2010 (r5976) @@ -4358,3 +4358,49 @@ } +{ + <undefined_values_sqlite1> + Memcheck:Param + write(buf) + fun:__write_nocancel + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + fun:sqlite3_step + fun:sqlite3_exec + fun:osync_db_query + fun:osync_sink_states_table_create + fun:osync_sink_state_db_new + fun:osync_objtype_sink_open_state_db + fun:plugin_initialize + fun:run_command + fun:main +} + +{ + <undefined_values_sqlite2> + Memcheck:Param + write(buf) + fun:__write_nocancel + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + obj:/usr/lib64/libsqlite3.so.0.8.6 + fun:sqlite3_step + fun:sqlite3_exec + fun:osync_db_query + fun:osync_sink_state_set + fun:ldap_plugin_sync_done + fun:osync_objtype_sink_sync_done + fun:syncdone_sink + fun:syncdone + fun:run_command + fun:main +} + + |
From: <svn...@op...> - 2010-01-05 18:55:11
|
Author: scriptor Date: Tue Jan 5 19:55:02 2010 New Revision: 5975 URL: http://www.opensync.org/changeset/5975 Log: Basic installation instructions. Now with some remarks about the "test" target and the authentication specific tests. Modified: plugins/ldap-sync/INSTALL Modified: plugins/ldap-sync/INSTALL ============================================================================== --- plugins/ldap-sync/INSTALL Tue Jan 5 19:54:44 2010 (r5974) +++ plugins/ldap-sync/INSTALL Tue Jan 5 19:55:02 2010 (r5975) @@ -3,28 +3,26 @@ A. Regular build: -tar -xvjf libopensync-plugin-ldap-0.39.tar.bz2 -cd libopensync-plugin-ldap-0.39 +tar -xvjf libopensync-plugin-ldap-0.40.tar.bz2 +cd libopensync-plugin-ldap-0.40 mkdir build cd build -PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DUPDATE_TYPE=svn /home/user1/libopensync-0.39/libopensync-plugin-ldap-0.39 +PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DUPDATE_TYPE=svn .. make -s make -w install ldconfig -cd ../.. B. Debug build: -tar -xvjf libopensync-plugin-ldap-0.39.tar.bz2 -cd libopensync-plugin-ldap-0.39 +tar -xvjf libopensync-plugin-ldap-0.40.tar.bz2 +cd libopensync-plugin-ldap-0.40 mkdir build_debug cd build_debug -PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DUPDATE_TYPE=svn -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON /home/user1/libopensync-0.39/libopensync-plugin-ldap-0.39 +PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DUPDATE_TYPE=svn -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON .. make -s make -w install ldconfig -cd ../.. @@ -63,6 +61,8 @@ suffix "dc=example,dc=com" + + If you prefer a different DN, you must change tests/test.conf and @@ -81,19 +81,41 @@ mkdir build_debug cd build_debug -PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DUPDATE_TYPE=svn -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON -DRUN_LONG_TESTS=off /home/user1/libopensync-0.39/libopensync-plugin-ldap-0.39 +# Without authentification specific tests and without longer valgrind tests: +PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DUPDATE_TYPE=svn -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON -DRUN_AUTH_TESTS=off -DRUN_LONG_TESTS=off .. + +# or: + +# Without authentification specific tests, but with time-consuming valgrind testts: +PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DUPDATE_TYPE=svn -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON -DRUN_AUTH_TESTS=off -DRUN_LONG_TESTS=on .. + +# or: -or: +# With authentification specific tests and with time-consuming valgrind tests: +PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DUPDATE_TYPE=svn -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON -DRUN_AUTH_TESTS=on -DRUN_LONG_TESTS=on .. + +# or: + +# When preparing for code coverage (gcov or lcov), and without authentication +# specific tests and without longer valgrind tests: +PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DUPDATE_TYPE=svn -DCMAKE_BUILD_TYPE=Profiling -DCMAKE_VERBOSE_MAKEFILE=ON -DRUN_LONG_TESTS=off -DRUN_AUTH_TESTS=off .. -PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DUPDATE_TYPE=svn -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON -DRUN_LONG_TESTS=on /home/user1/libopensync-0.39/libopensync-plugin-ldap-0.39 make +make install make test + Tests with valgrind take quite some time: They are run only when cmake is run with "-DRUN_LONG_TESTS=on". + +Authentication specific tests are disabled by default, because the +require appropriate configuration of the LDAP servers. They can +be enabled by "-DRUN_AUTH_TESTS=on". + + reset; time make test (...) 100% tests passed, 0 tests failed out of 162 @@ -111,20 +133,67 @@ ctest -N -IV. Run only one particular test: + +IV. Run only particular tests: cd build -ctest -I 51,51 +ctest -I 120,120 -V +ctest -I 124,137 ctest -R remove_test_ldifs +ctest -R add_mod_del_contact1_and_fastsync -V + + + +V. Submit the build and test results to a dashboard: + +make ExperimentalStart +make ExperimentalConfigure +make ExperimentalBuild +make ExperimentalTest +make ExperimentalCoverage +make ExperimentalSubmit + + + +E. Profiling: + +I. Code coverage with lcov: + +Prerequisite: + +Build the code with -DCMAKE_BUILD_TYPE=Profiling + +Example: + +PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DUPDATE_TYPE=svn -DCMAKE_BUILD_TYPE=Profiling -DCMAKE_VERBOSE_MAKEFILE=ON -DRUN_AUTH_TESTS=on -DRUN_LONG_TESTS=off .. + + +Compile and install it and run as many tests as possible: + + make -s clean + make -s + sudo make -s install + make test + + +Then, "make -s coverage". + +If this has succeeded, have a look at + + coverage/html/ldap_plugin_20090813151059/index.html + +for example. + + -E. The following cmake modules are required for the LDAP plugin: +F. The following cmake modules are required for the LDAP plugin: FindLibLdap.cmake -FindLibGCrypt.cmake +FindLibMozLdap.cmake FindLibSASL2.cmake FindLibGSSAPIV2.cmake |