From acc9f36811e032569a17572c15879e72b1b2b90a Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Mar 31 2020 09:35:09 +0000 Subject: import evolution-ews-3.28.5-5.el7 --- diff --git a/SOURCES/evolution-ews-3.28.5-cve-2019-3890.patch b/SOURCES/evolution-ews-3.28.5-cve-2019-3890.patch new file mode 100644 index 0000000..65b055d --- /dev/null +++ b/SOURCES/evolution-ews-3.28.5-cve-2019-3890.patch @@ -0,0 +1,782 @@ +diff -up evolution-ews-3.28.5/src/addressbook/e-book-backend-ews.c.cve-2019-3890 evolution-ews-3.28.5/src/addressbook/e-book-backend-ews.c +--- evolution-ews-3.28.5/src/addressbook/e-book-backend-ews.c.cve-2019-3890 2019-04-15 09:43:49.672771516 +0200 ++++ evolution-ews-3.28.5/src/addressbook/e-book-backend-ews.c 2019-04-15 09:43:49.683771516 +0200 +@@ -2901,7 +2901,8 @@ ebb_ews_connect_sync (EBookMetaBackend * + bbews->priv->cnc, "proxy-resolver", + G_BINDING_SYNC_CREATE); + +- *out_auth_result = e_ews_connection_try_credentials_sync (bbews->priv->cnc, credentials, cancellable, error); ++ *out_auth_result = e_ews_connection_try_credentials_sync (bbews->priv->cnc, credentials, NULL, ++ out_certificate_pem, out_certificate_errors, cancellable, error); + + if (*out_auth_result == E_SOURCE_AUTHENTICATION_ACCEPTED) { + ESource *source = e_backend_get_source (E_BACKEND (bbews)); +diff -up evolution-ews-3.28.5/src/calendar/e-cal-backend-ews.c.cve-2019-3890 evolution-ews-3.28.5/src/calendar/e-cal-backend-ews.c +--- evolution-ews-3.28.5/src/calendar/e-cal-backend-ews.c.cve-2019-3890 2019-04-15 09:43:49.676771516 +0200 ++++ evolution-ews-3.28.5/src/calendar/e-cal-backend-ews.c 2019-04-15 09:43:49.684771516 +0200 +@@ -1394,7 +1394,8 @@ ecb_ews_connect_sync (ECalMetaBackend *m + cbews->priv->cnc, "proxy-resolver", + G_BINDING_SYNC_CREATE); + +- *out_auth_result = e_ews_connection_try_credentials_sync (cbews->priv->cnc, credentials, cancellable, error); ++ *out_auth_result = e_ews_connection_try_credentials_sync (cbews->priv->cnc, credentials, NULL, ++ out_certificate_pem, out_certificate_errors, cancellable, error); + + if (*out_auth_result == E_SOURCE_AUTHENTICATION_ACCEPTED) { + ESource *source = e_backend_get_source (E_BACKEND (cbews)); +diff -up evolution-ews-3.28.5/src/camel/camel-ews-store.c.cve-2019-3890 evolution-ews-3.28.5/src/camel/camel-ews-store.c +--- evolution-ews-3.28.5/src/camel/camel-ews-store.c.cve-2019-3890 2018-07-30 16:01:00.000000000 +0200 ++++ evolution-ews-3.28.5/src/camel/camel-ews-store.c 2019-04-15 09:43:49.684771516 +0200 +@@ -1831,6 +1831,8 @@ ews_authenticate_sync (CamelService *ser + const gchar *password; + gchar *hosturl; + gchar *old_sync_state = NULL, *new_sync_state = NULL; ++ gchar *certificate_pem = NULL; ++ GTlsCertificateFlags certificate_errors = 0; + GError *local_error = NULL; + + ews_store = CAMEL_EWS_STORE (service); +@@ -1959,6 +1961,18 @@ ews_authenticate_sync (CamelService *ser + + g_slist_free_full (created_folder_ids, g_free); + ++ if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED) && ++ e_ews_connection_get_ssl_error_details (connection, &certificate_pem, &certificate_errors)) { ++ source = e_ews_connection_get_source (connection); ++ ++ if (source) { ++ e_source_emit_credentials_required (source, E_SOURCE_CREDENTIALS_REASON_SSL_FAILED, ++ certificate_pem, certificate_errors, local_error); ++ } ++ ++ g_free (certificate_pem); ++ } ++ + if (local_error == NULL) { + result = CAMEL_AUTHENTICATION_ACCEPTED; + } else if (g_error_matches (local_error, EWS_CONNECTION_ERROR, EWS_CONNECTION_ERROR_AUTHENTICATION_FAILED)) { +diff -up evolution-ews-3.28.5/src/collection/e-ews-backend.c.cve-2019-3890 evolution-ews-3.28.5/src/collection/e-ews-backend.c +--- evolution-ews-3.28.5/src/collection/e-ews-backend.c.cve-2019-3890 2019-04-15 09:43:49.679771516 +0200 ++++ evolution-ews-3.28.5/src/collection/e-ews-backend.c 2019-04-15 09:43:49.685771516 +0200 +@@ -727,6 +727,15 @@ ews_backend_constructed (GObject *object + /* Reset the connectable, it steals data from Authentication extension, + where is written incorrect address */ + e_backend_set_connectable (backend, NULL); ++ ++ /* Eventually unset temporary SSL trust, but only once, when the process started. ++ It might bee too often anywhere lease (like in the authenticate callback) */ ++ if (e_source_has_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND)) { ++ ESourceWebdav *webdav_extension; ++ ++ webdav_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND); ++ e_source_webdav_unset_temporary_ssl_trust (webdav_extension); ++ } + } + + static void +@@ -930,7 +939,7 @@ ews_backend_create_resource_sync (EColle + } + + if (!success) { +- connection = e_ews_backend_ref_connection_sync (E_EWS_BACKEND (backend), NULL, cancellable, error); ++ connection = e_ews_backend_ref_connection_sync (E_EWS_BACKEND (backend), NULL, NULL, NULL, cancellable, error); + if (connection == NULL) + return FALSE; + +@@ -1037,7 +1046,7 @@ ews_backend_delete_resource_sync (EColle + const gchar *extension_name; + gboolean success = FALSE; + +- connection = e_ews_backend_ref_connection_sync (E_EWS_BACKEND (backend), NULL, cancellable, error); ++ connection = e_ews_backend_ref_connection_sync (E_EWS_BACKEND (backend), NULL, NULL, NULL, cancellable, error); + if (connection == NULL) + return FALSE; + +@@ -1142,7 +1151,7 @@ ews_backend_authenticate_sync (EBackend + ews_backend->priv->credentials = e_named_parameters_new_clone (credentials); + g_mutex_unlock (&ews_backend->priv->connection_lock); + +- connection = e_ews_backend_ref_connection_sync (ews_backend, &result, cancellable, error); ++ connection = e_ews_backend_ref_connection_sync (ews_backend, &result, out_certificate_pem, out_certificate_errors, cancellable, error); + g_clear_object (&connection); + + if (result == E_SOURCE_AUTHENTICATION_ACCEPTED) { +@@ -1223,7 +1232,7 @@ ews_backend_ref_connection_thread (GSimp + EEwsConnection *connection; + GError *error = NULL; + +- connection = e_ews_backend_ref_connection_sync (E_EWS_BACKEND (object), NULL, cancellable, &error); ++ connection = e_ews_backend_ref_connection_sync (E_EWS_BACKEND (object), NULL, NULL, NULL, cancellable, &error); + + /* Sanity check. */ + g_return_if_fail ( +@@ -1241,6 +1250,8 @@ ews_backend_ref_connection_thread (GSimp + EEwsConnection * + e_ews_backend_ref_connection_sync (EEwsBackend *backend, + ESourceAuthenticationResult *result, ++ gchar **out_certificate_pem, ++ GTlsCertificateFlags *out_certificate_errors, + GCancellable *cancellable, + GError **error) + { +@@ -1272,7 +1283,8 @@ e_ews_backend_ref_connection_sync (EEwsB + connection, "proxy-resolver", + G_BINDING_SYNC_CREATE); + +- local_result = e_ews_connection_try_credentials_sync (connection, backend->priv->credentials, cancellable, error); ++ local_result = e_ews_connection_try_credentials_sync (connection, backend->priv->credentials, NULL, ++ out_certificate_pem, out_certificate_errors, cancellable, error); + if (result) + *result = local_result; + +@@ -1413,7 +1425,7 @@ e_ews_backend_sync_folders_sync (EEwsBac + return TRUE; + } + +- connection = e_ews_backend_ref_connection_sync (backend, NULL, cancellable, error); ++ connection = e_ews_backend_ref_connection_sync (backend, NULL, NULL, NULL, cancellable, error); + + if (connection == NULL) { + backend->priv->need_update_folders = TRUE; +diff -up evolution-ews-3.28.5/src/collection/e-ews-backend.h.cve-2019-3890 evolution-ews-3.28.5/src/collection/e-ews-backend.h +--- evolution-ews-3.28.5/src/collection/e-ews-backend.h.cve-2019-3890 2018-07-30 16:01:00.000000000 +0200 ++++ evolution-ews-3.28.5/src/collection/e-ews-backend.h 2019-04-15 09:43:49.685771516 +0200 +@@ -63,6 +63,8 @@ EEwsConnection * + e_ews_backend_ref_connection_sync + (EEwsBackend *backend, + ESourceAuthenticationResult *result, ++ gchar **out_certificate_pem, ++ GTlsCertificateFlags *out_certificate_errors, + GCancellable *cancellable, + GError **error); + void e_ews_backend_ref_connection (EEwsBackend *backend, +diff -up evolution-ews-3.28.5/src/configuration/e-ews-config-lookup.c.cve-2019-3890 evolution-ews-3.28.5/src/configuration/e-ews-config-lookup.c +--- evolution-ews-3.28.5/src/configuration/e-ews-config-lookup.c.cve-2019-3890 2018-07-30 16:01:00.000000000 +0200 ++++ evolution-ews-3.28.5/src/configuration/e-ews-config-lookup.c 2019-04-15 09:43:49.685771516 +0200 +@@ -344,9 +344,54 @@ ews_config_lookup_worker_run (EConfigLoo + + if (password) { + const gchar *servers; ++ gchar *certificate_host = NULL; ++ gchar *certificate_pem = NULL; ++ GTlsCertificateFlags certificate_errors = 0; ++ GError *local_error = NULL; ++ ++ if (e_named_parameters_exists (params, E_CONFIG_LOOKUP_PARAM_CERTIFICATE_PEM) && ++ e_named_parameters_exists (params, E_CONFIG_LOOKUP_PARAM_CERTIFICATE_TRUST) && ++ e_named_parameters_exists (params, E_CONFIG_LOOKUP_PARAM_CERTIFICATE_HOST)) { ++ GTlsCertificate *certificate; ++ const gchar *param_certificate_pem; ++ ++ param_certificate_pem = e_named_parameters_get (params, E_CONFIG_LOOKUP_PARAM_CERTIFICATE_PEM); ++ certificate = g_tls_certificate_new_from_pem (param_certificate_pem, -1, NULL); ++ ++ if (certificate) { ++ ETrustPromptResponse trust_response; ++ ++ trust_response = e_config_lookup_decode_certificate_trust ( ++ e_named_parameters_get (params, E_CONFIG_LOOKUP_PARAM_CERTIFICATE_TRUST)); ++ ++ if (trust_response != E_TRUST_PROMPT_RESPONSE_UNKNOWN) { ++ ESourceWebdav *webdav_extension; ++ ++ webdav_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND); ++ e_source_webdav_update_ssl_trust (webdav_extension, ++ e_named_parameters_get (params, E_CONFIG_LOOKUP_PARAM_CERTIFICATE_HOST), ++ certificate, trust_response); ++ } ++ ++ g_object_unref (certificate); ++ } ++ } + +- if (e_ews_autodiscover_ws_url_sync (source, ews_settings, email_address, password, cancellable, NULL)) { ++ if (e_ews_autodiscover_ws_url_sync (source, ews_settings, email_address, password, &certificate_pem, &certificate_errors, cancellable, &local_error)) { + ews_config_lookup_worker_result_from_settings (lookup_worker, config_lookup, email_address, ews_settings, params); ++ } else if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED)) { ++ const gchar *hosturl; ++ SoupURI *suri; ++ ++ hosturl = camel_ews_settings_get_hosturl (ews_settings); ++ suri = soup_uri_new (hosturl); ++ if (suri) { ++ certificate_host = g_strdup (soup_uri_get_host (suri)); ++ ++ soup_uri_free (suri); ++ } ++ } else { ++ g_clear_error (&local_error); + } + + servers = e_named_parameters_get (params, E_CONFIG_LOOKUP_PARAM_SERVERS); +@@ -357,7 +402,7 @@ ews_config_lookup_worker_run (EConfigLoo + + servers_strv = g_strsplit (servers, ";", 0); + +- for (ii = 0; servers_strv && servers_strv[ii] && !g_cancellable_is_cancelled (cancellable); ii++) { ++ for (ii = 0; servers_strv && servers_strv[ii] && !g_cancellable_is_cancelled (cancellable) && !local_error; ii++) { + const gchar *server = servers_strv[ii]; + gchar *tmp = NULL; + +@@ -368,8 +413,21 @@ ews_config_lookup_worker_run (EConfigLoo + + camel_ews_settings_set_hosturl (ews_settings, server); + +- if (e_ews_autodiscover_ws_url_sync (source, ews_settings, email_address, password, cancellable, NULL)) { ++ if (e_ews_autodiscover_ws_url_sync (source, ews_settings, email_address, password, &certificate_pem, &certificate_errors, cancellable, &local_error)) { + ews_config_lookup_worker_result_from_settings (lookup_worker, config_lookup, email_address, ews_settings, params); ++ } else if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED)) { ++ const gchar *hosturl; ++ SoupURI *suri; ++ ++ hosturl = camel_ews_settings_get_hosturl (ews_settings); ++ suri = soup_uri_new (hosturl); ++ if (suri) { ++ certificate_host = g_strdup (soup_uri_get_host (suri)); ++ ++ soup_uri_free (suri); ++ } ++ } else { ++ g_clear_error (&local_error); + } + + g_free (tmp); +@@ -378,7 +436,31 @@ ews_config_lookup_worker_run (EConfigLoo + g_strfreev (servers_strv); + } + +- if (out_restart_params) ++ if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED) && ++ certificate_pem && *certificate_pem && certificate_errors) { ++ gchar *description = e_trust_prompt_describe_certificate_errors (certificate_errors); ++ ++ if (description) { ++ g_set_error_literal (error, E_CONFIG_LOOKUP_WORKER_ERROR, ++ E_CONFIG_LOOKUP_WORKER_ERROR_CERTIFICATE, description); ++ ++ g_free (description); ++ ++ if (out_restart_params) { ++ if (!*out_restart_params) ++ *out_restart_params = e_named_parameters_new_clone (params); ++ ++ e_named_parameters_set (*out_restart_params, E_CONFIG_LOOKUP_PARAM_CERTIFICATE_PEM, certificate_pem); ++ e_named_parameters_set (*out_restart_params, E_CONFIG_LOOKUP_PARAM_CERTIFICATE_HOST, certificate_host); ++ } ++ } ++ } ++ ++ g_clear_error (&local_error); ++ g_free (certificate_host); ++ g_free (certificate_pem); ++ ++ if (out_restart_params && !*out_restart_params) + *out_restart_params = e_named_parameters_new_clone (params); + } + +diff -up evolution-ews-3.28.5/src/configuration/e-ews-config-utils.c.cve-2019-3890 evolution-ews-3.28.5/src/configuration/e-ews-config-utils.c +--- evolution-ews-3.28.5/src/configuration/e-ews-config-utils.c.cve-2019-3890 2018-07-30 16:01:00.000000000 +0200 ++++ evolution-ews-3.28.5/src/configuration/e-ews-config-utils.c 2019-04-15 09:43:49.686771516 +0200 +@@ -317,7 +317,7 @@ ews_config_utils_try_credentials_sync (E + if (data->try_credentials_func) + auth_result = data->try_credentials_func (data->conn, credentials, data->user_data, cancellable, error); + else +- auth_result = e_ews_connection_try_credentials_sync (data->conn, credentials, cancellable, error); ++ auth_result = e_ews_connection_try_credentials_sync (data->conn, credentials, NULL, NULL, NULL, cancellable, error); + + if (auth_result == E_SOURCE_AUTHENTICATION_ACCEPTED) { + *out_authenticated = TRUE; +@@ -377,7 +377,7 @@ e_ews_config_utils_open_connection_for ( + if (try_credentials_func) + result = try_credentials_func (conn, NULL, user_data, cancellable, &local_error); + else +- result = e_ews_connection_try_credentials_sync (conn, NULL, cancellable, &local_error); ++ result = e_ews_connection_try_credentials_sync (conn, NULL, NULL, NULL, NULL, cancellable, &local_error); + + if (result != E_SOURCE_AUTHENTICATION_ACCEPTED) { + g_clear_object (&conn); +diff -up evolution-ews-3.28.5/src/configuration/e-mail-config-ews-autodiscover.c.cve-2019-3890 evolution-ews-3.28.5/src/configuration/e-mail-config-ews-autodiscover.c +--- evolution-ews-3.28.5/src/configuration/e-mail-config-ews-autodiscover.c.cve-2019-3890 2018-07-30 16:01:00.000000000 +0200 ++++ evolution-ews-3.28.5/src/configuration/e-mail-config-ews-autodiscover.c 2019-04-15 09:43:49.686771516 +0200 +@@ -45,6 +45,8 @@ struct _AsyncContext { + ESource *source; + CamelEwsSettings *ews_settings; + gchar *email_address; ++ gchar *certificate_pem; ++ GTlsCertificateFlags certificate_errors; + }; + + enum { +@@ -67,6 +69,7 @@ async_context_free (gpointer ptr) + g_clear_object (&async_context->source); + g_clear_object (&async_context->ews_settings); + g_free (async_context->email_address); ++ g_free (async_context->certificate_pem); + + g_slice_free (AsyncContext, async_context); + } +@@ -87,6 +90,9 @@ mail_config_ews_autodiscover_finish (EMa + } + + static void ++mail_config_ews_autodiscover_run (EMailConfigEwsAutodiscover *autodiscover); ++ ++static void + mail_config_ews_autodiscover_run_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) +@@ -111,17 +117,62 @@ mail_config_ews_autodiscover_run_cb (GOb + g_object_thaw_notify (G_OBJECT (settings)); + + if (e_activity_handle_cancellation (async_context->activity, error)) { +- g_error_free (error); ++ /* Do nothing, just free the error below */ ++ } else if (g_error_matches (error, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED) && ++ async_context->certificate_pem && *async_context->certificate_pem && async_context->certificate_errors) { ++ ETrustPromptResponse response; ++ GtkWidget *parent; ++ const gchar *host; ++ ++ parent = gtk_widget_get_toplevel (GTK_WIDGET (autodiscover)); ++ if (!GTK_IS_WINDOW (parent)) ++ parent = NULL; ++ ++ host = camel_network_settings_get_host (CAMEL_NETWORK_SETTINGS (settings)); ++ ++ response = e_trust_prompt_run_modal (parent ? GTK_WINDOW (parent) : NULL, ++ E_SOURCE_EXTENSION_COLLECTION, _("Exchange Web Services"), ++ host, async_context->certificate_pem, async_context->certificate_errors, ++ error->message); ++ ++ g_clear_error (&error); ++ ++ if (response != E_TRUST_PROMPT_RESPONSE_UNKNOWN) { ++ GTlsCertificate *certificate; ++ ++ certificate = g_tls_certificate_new_from_pem (async_context->certificate_pem, -1, &error); ++ if (certificate) { ++ ESourceWebdav *extension_webdav; ++ ++ extension_webdav = e_source_get_extension (async_context->source, E_SOURCE_EXTENSION_WEBDAV_BACKEND); ++ ++ e_source_webdav_update_ssl_trust (extension_webdav, host, certificate, response); ++ ++ g_object_unref (certificate); ++ } ++ ++ if (error) { ++ e_alert_submit ( ++ alert_sink, ++ "ews:autodiscovery-error", ++ error->message, NULL); ++ } ++ } + ++ if (response == E_TRUST_PROMPT_RESPONSE_ACCEPT || ++ response == E_TRUST_PROMPT_RESPONSE_ACCEPT_TEMPORARILY) { ++ mail_config_ews_autodiscover_run (autodiscover); ++ } + } else if (error != NULL) { + e_alert_submit ( + alert_sink, + "ews:autodiscovery-error", + error->message, NULL); +- g_error_free (error); + } + + gtk_widget_set_sensitive (GTK_WIDGET (autodiscover), TRUE); ++ ++ g_clear_error (&error); + } + + static gboolean +@@ -141,6 +192,7 @@ mail_config_ews_autodiscover_sync (ECred + async_context->ews_settings, async_context->email_address, + credentials && e_named_parameters_get (credentials, E_SOURCE_CREDENTIAL_PASSWORD) ? + e_named_parameters_get (credentials, E_SOURCE_CREDENTIAL_PASSWORD) : "", ++ &async_context->certificate_pem, &async_context->certificate_errors, + cancellable, &local_error); + + if (local_error == NULL) { +@@ -173,6 +225,7 @@ mail_config_ews_autodiscover_run_thread + if (without_password) { + success = e_ews_autodiscover_ws_url_sync (async_context->source, + async_context->ews_settings, async_context->email_address, "", ++ &async_context->certificate_pem, &async_context->certificate_errors, + cancellable, &local_error); + } + +@@ -236,6 +289,8 @@ mail_config_ews_autodiscover_run (EMailC + async_context->source = g_object_ref (source); + async_context->ews_settings = g_object_ref (settings); + async_context->email_address = g_strdup (e_mail_config_service_page_get_email_address (page)); ++ async_context->certificate_pem = NULL; ++ async_context->certificate_errors = 0; + + /* + * The GTask will be run in a new thread, which will invoke +diff -up evolution-ews-3.28.5/src/server/e-ews-connection.c.cve-2019-3890 evolution-ews-3.28.5/src/server/e-ews-connection.c +--- evolution-ews-3.28.5/src/server/e-ews-connection.c.cve-2019-3890 2018-07-30 16:01:00.000000000 +0200 ++++ evolution-ews-3.28.5/src/server/e-ews-connection.c 2019-04-15 09:43:49.689771516 +0200 +@@ -111,6 +111,10 @@ struct _EEwsConnectionPrivate { + + /* Set to TRUE when this connection had been disconnected and cannot be used anymore */ + gboolean disconnected_flag; ++ ++ gboolean ssl_info_set; ++ gchar *ssl_certificate_pem; ++ GTlsCertificateFlags ssl_certificate_errors; + }; + + enum { +@@ -836,6 +840,37 @@ ews_connection_credentials_failed (EEwsC + return expired; + } + ++static void ++ews_connection_check_ssl_error (EEwsConnection *connection, ++ SoupMessage *message) ++{ ++ g_return_if_fail (E_IS_EWS_CONNECTION (connection)); ++ g_return_if_fail (SOUP_IS_MESSAGE (message)); ++ ++ if (message->status_code == SOUP_STATUS_SSL_FAILED) { ++ GTlsCertificate *certificate = NULL; ++ ++ g_mutex_lock (&connection->priv->property_lock); ++ ++ g_clear_pointer (&connection->priv->ssl_certificate_pem, g_free); ++ connection->priv->ssl_info_set = FALSE; ++ ++ g_object_get (G_OBJECT (message), ++ "tls-certificate", &certificate, ++ "tls-errors", &connection->priv->ssl_certificate_errors, ++ NULL); ++ ++ if (certificate) { ++ g_object_get (certificate, "certificate-pem", &connection->priv->ssl_certificate_pem, NULL); ++ connection->priv->ssl_info_set = TRUE; ++ ++ g_object_unref (certificate); ++ } ++ ++ g_mutex_unlock (&connection->priv->property_lock); ++ } ++} ++ + /* Response callbacks */ + + static void +@@ -852,8 +887,15 @@ ews_response_cb (SoupSession *session, + if (g_cancellable_is_cancelled (enode->cancellable)) + goto exit; + ++ ews_connection_check_ssl_error (enode->cnc, msg); ++ + if (ews_connection_credentials_failed (enode->cnc, msg, enode->simple)) { + goto exit; ++ } else if (msg->status_code == SOUP_STATUS_SSL_FAILED) { ++ g_simple_async_result_set_error ( ++ enode->simple, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED, ++ "%s", msg->reason_phrase); ++ goto exit; + } else if (msg->status_code == SOUP_STATUS_UNAUTHORIZED) { + if (msg->response_headers) { + const gchar *diagnostics; +@@ -1855,6 +1897,9 @@ ews_connection_constructed (GObject *obj + cnc->priv->soup_thread = g_thread_new (NULL, e_ews_soup_thread, cnc); + + cnc->priv->soup_session = soup_session_async_new_with_options ( ++ SOUP_SESSION_TIMEOUT, 90, ++ SOUP_SESSION_SSL_STRICT, TRUE, ++ SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE, + SOUP_SESSION_ASYNC_CONTEXT, cnc->priv->soup_context, + NULL); + +@@ -1971,6 +2016,7 @@ ews_connection_finalize (GObject *object + g_free (priv->email); + g_free (priv->hash_key); + g_free (priv->impersonate_user); ++ g_free (priv->ssl_certificate_pem); + + g_clear_object (&priv->bearer_auth); + +@@ -2557,10 +2603,15 @@ e_ews_connection_update_credentials (EEw + ESourceAuthenticationResult + e_ews_connection_try_credentials_sync (EEwsConnection *cnc, + const ENamedParameters *credentials, ++ ESource *use_source, ++ gchar **out_certificate_pem, ++ GTlsCertificateFlags *out_certificate_errors, + GCancellable *cancellable, + GError **error) + { + ESourceAuthenticationResult result; ++ ESource *source; ++ gboolean de_set_source; + EwsFolderId *fid = NULL; + GSList *ids = NULL; + GError *local_error = NULL; +@@ -2574,14 +2625,31 @@ e_ews_connection_try_credentials_sync (E + fid->is_distinguished_id = TRUE; + ids = g_slist_append (ids, fid); + ++ source = e_ews_connection_get_source (cnc); ++ if (use_source && use_source != source) { ++ cnc->priv->source = g_object_ref (use_source); ++ de_set_source = TRUE; ++ } else { ++ source = NULL; ++ de_set_source = FALSE; ++ } ++ + e_ews_connection_get_folder_sync ( + cnc, EWS_PRIORITY_MEDIUM, "Default", + NULL, ids, NULL, cancellable, &local_error); + ++ if (de_set_source) { ++ g_clear_object (&cnc->priv->source); ++ cnc->priv->source = source; ++ } ++ + g_slist_free_full (ids, (GDestroyNotify) e_ews_folder_id_free); + + if (local_error == NULL) { + result = E_SOURCE_AUTHENTICATION_ACCEPTED; ++ } else if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED) && ++ e_ews_connection_get_ssl_error_details (cnc, out_certificate_pem, out_certificate_errors)) { ++ result = E_SOURCE_AUTHENTICATION_ERROR_SSL_FAILED; + } else { + gboolean auth_failed; + +@@ -2618,6 +2686,29 @@ e_ews_connection_get_source (EEwsConnect + return cnc->priv->source; + } + ++gboolean ++e_ews_connection_get_ssl_error_details (EEwsConnection *cnc, ++ gchar **out_certificate_pem, ++ GTlsCertificateFlags *out_certificate_errors) ++{ ++ g_return_val_if_fail (E_IS_EWS_CONNECTION (cnc), FALSE); ++ g_return_val_if_fail (out_certificate_pem != NULL, FALSE); ++ g_return_val_if_fail (out_certificate_errors != NULL, FALSE); ++ ++ g_mutex_lock (&cnc->priv->property_lock); ++ if (!cnc->priv->ssl_info_set) { ++ g_mutex_unlock (&cnc->priv->property_lock); ++ return FALSE; ++ } ++ ++ *out_certificate_pem = g_strdup (cnc->priv->ssl_certificate_pem); ++ *out_certificate_errors = cnc->priv->ssl_certificate_errors; ++ ++ g_mutex_unlock (&cnc->priv->property_lock); ++ ++ return TRUE; ++} ++ + const gchar * + e_ews_connection_get_uri (EEwsConnection *cnc) + { +@@ -2906,6 +2997,9 @@ autodiscover_response_cb (SoupSession *s + g_set_error ( + &error, SOUP_HTTP_ERROR, status, + "%d %s", status, msg->reason_phrase); ++ ++ if (status == SOUP_STATUS_SSL_FAILED) ++ ews_connection_check_ssl_error (ad->cnc, msg); + } + + g_free (service_url); +@@ -3056,7 +3150,8 @@ static void post_restarted (SoupMessage + } + + static SoupMessage * +-e_ews_get_msg_for_url (CamelEwsSettings *settings, ++e_ews_get_msg_for_url (EEwsConnection *cnc, ++ CamelEwsSettings *settings, + const gchar *url, + xmlOutputBuffer *buf, + GError **error) +@@ -3078,6 +3173,9 @@ e_ews_get_msg_for_url (CamelEwsSettings + return NULL; + } + ++ if (cnc->priv->source) ++ e_soup_ssl_trust_connect (msg, cnc->priv->source); ++ + e_ews_message_attach_chunk_allocator (msg); + + e_ews_message_set_user_agent_header (msg, settings); +@@ -3107,6 +3205,8 @@ e_ews_autodiscover_ws_url_sync (ESource + CamelEwsSettings *settings, + const gchar *email_address, + const gchar *password, ++ gchar **out_certificate_pem, ++ GTlsCertificateFlags *out_certificate_errors, + GCancellable *cancellable, + GError **error) + { +@@ -3125,7 +3225,7 @@ e_ews_autodiscover_ws_url_sync (ESource + + result = e_async_closure_wait (closure); + +- success = e_ews_autodiscover_ws_url_finish (settings, result, error); ++ success = e_ews_autodiscover_ws_url_finish (settings, result, out_certificate_pem, out_certificate_errors, error); + + e_async_closure_free (closure); + +@@ -3236,11 +3336,11 @@ e_ews_autodiscover_ws_url (ESource *sour + simple, ad, (GDestroyNotify) autodiscover_data_free); + + /* Passing a NULL URL string returns NULL. */ +- ad->msgs[0] = e_ews_get_msg_for_url (settings, url1, buf, &error); +- ad->msgs[1] = e_ews_get_msg_for_url (settings, url2, buf, NULL); +- ad->msgs[2] = e_ews_get_msg_for_url (settings, url3, buf, NULL); +- ad->msgs[3] = e_ews_get_msg_for_url (settings, url4, buf, NULL); +- ad->msgs[4] = e_ews_get_msg_for_url (settings, url5, buf, NULL); ++ ad->msgs[0] = e_ews_get_msg_for_url (cnc, settings, url1, buf, &error); ++ ad->msgs[1] = e_ews_get_msg_for_url (cnc, settings, url2, buf, NULL); ++ ad->msgs[2] = e_ews_get_msg_for_url (cnc, settings, url3, buf, NULL); ++ ad->msgs[3] = e_ews_get_msg_for_url (cnc, settings, url4, buf, NULL); ++ ad->msgs[4] = e_ews_get_msg_for_url (cnc, settings, url5, buf, NULL); + + /* These have to be submitted only after they're both set in ad->msgs[] + * or there will be races with fast completion */ +@@ -3300,10 +3400,13 @@ has_suffix_icmp (const gchar *text, + gboolean + e_ews_autodiscover_ws_url_finish (CamelEwsSettings *settings, + GAsyncResult *result, ++ gchar **out_certificate_pem, ++ GTlsCertificateFlags *out_certificate_errors, + GError **error) + { + GSimpleAsyncResult *simple; + struct _autodiscover_data *ad; ++ GError *local_error = NULL; + + g_return_val_if_fail ( + g_simple_async_result_is_valid ( +@@ -3313,8 +3416,20 @@ e_ews_autodiscover_ws_url_finish (CamelE + simple = G_SIMPLE_ASYNC_RESULT (result); + ad = g_simple_async_result_get_op_res_gpointer (simple); + +- if (g_simple_async_result_propagate_error (simple, error)) ++ if (g_simple_async_result_propagate_error (simple, &local_error)) { ++ if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED)) { ++ if (!e_ews_connection_get_ssl_error_details (ad->cnc, out_certificate_pem, out_certificate_errors)) { ++ if (out_certificate_pem) ++ *out_certificate_pem = NULL; ++ if (out_certificate_errors) ++ *out_certificate_errors = 0; ++ } ++ } ++ ++ g_propagate_error (error, local_error); ++ + return FALSE; ++ } + + g_warn_if_fail (ad->as_url != NULL); + g_warn_if_fail (ad->oab_url != NULL); +@@ -3473,6 +3588,8 @@ oal_response_cb (SoupSession *soup_sessi + simple = G_SIMPLE_ASYNC_RESULT (user_data); + data = g_simple_async_result_get_op_res_gpointer (simple); + ++ ews_connection_check_ssl_error (data->cnc, soup_message); ++ + if (ews_connection_credentials_failed (data->cnc, soup_message, simple)) { + goto exit; + } else if (soup_message->status_code != 200) { +@@ -3618,7 +3735,7 @@ e_ews_connection_get_oal_list (EEwsConne + + g_return_if_fail (E_IS_EWS_CONNECTION (cnc)); + +- soup_message = e_ews_get_msg_for_url (cnc->priv->settings, cnc->priv->uri, NULL, &error); ++ soup_message = e_ews_get_msg_for_url (cnc, cnc->priv->settings, cnc->priv->uri, NULL, &error); + + simple = g_simple_async_result_new ( + G_OBJECT (cnc), callback, user_data, +@@ -3739,7 +3856,7 @@ e_ews_connection_get_oal_detail (EEwsCon + + g_return_if_fail (E_IS_EWS_CONNECTION (cnc)); + +- soup_message = e_ews_get_msg_for_url (cnc->priv->settings, cnc->priv->uri, NULL, &error); ++ soup_message = e_ews_get_msg_for_url (cnc, cnc->priv->settings, cnc->priv->uri, NULL, &error); + + simple = g_simple_async_result_new ( + G_OBJECT (cnc), callback, user_data, +@@ -3826,6 +3943,8 @@ oal_download_response_cb (SoupSession *s + simple = G_SIMPLE_ASYNC_RESULT (user_data); + data = g_simple_async_result_get_op_res_gpointer (simple); + ++ ews_connection_check_ssl_error (data->cnc, soup_message); ++ + if (ews_connection_credentials_failed (data->cnc, soup_message, simple)) { + g_unlink (data->cache_filename); + } else if (soup_message->status_code != 200) { +@@ -3954,7 +4073,7 @@ e_ews_connection_download_oal_file (EEws + + g_return_if_fail (E_IS_EWS_CONNECTION (cnc)); + +- soup_message = e_ews_get_msg_for_url (cnc->priv->settings, cnc->priv->uri, NULL, &error); ++ soup_message = e_ews_get_msg_for_url (cnc, cnc->priv->settings, cnc->priv->uri, NULL, &error); + + simple = g_simple_async_result_new ( + G_OBJECT (cnc), callback, user_data, +diff -up evolution-ews-3.28.5/src/server/e-ews-connection.h.cve-2019-3890 evolution-ews-3.28.5/src/server/e-ews-connection.h +--- evolution-ews-3.28.5/src/server/e-ews-connection.h.cve-2019-3890 2018-07-30 16:01:00.000000000 +0200 ++++ evolution-ews-3.28.5/src/server/e-ews-connection.h 2019-04-15 09:43:49.689771516 +0200 +@@ -426,9 +426,16 @@ ESourceAuthenticationResult + e_ews_connection_try_credentials_sync + (EEwsConnection *cnc, + const ENamedParameters *credentials, ++ ESource *use_source, ++ gchar **out_certificate_pem, ++ GTlsCertificateFlags *out_certificate_errors, + GCancellable *cancellable, + GError **error); + ESource * e_ews_connection_get_source (EEwsConnection *cnc); ++gboolean e_ews_connection_get_ssl_error_details ++ (EEwsConnection *cnc, ++ gchar **out_certificate_pem, ++ GTlsCertificateFlags *out_certificate_errors); + const gchar * e_ews_connection_get_uri (EEwsConnection *cnc); + ESoupAuthBearer * + e_ews_connection_ref_bearer_auth(EEwsConnection *cnc); +@@ -469,6 +476,8 @@ gboolean e_ews_autodiscover_ws_url_sync + CamelEwsSettings *settings, + const gchar *email_address, + const gchar *password, ++ gchar **out_certificate_pem, ++ GTlsCertificateFlags *out_certificate_errors, + GCancellable *cancellable, + GError **error); + void e_ews_autodiscover_ws_url (ESource *source, +@@ -481,6 +490,8 @@ void e_ews_autodiscover_ws_url (ESource + gboolean e_ews_autodiscover_ws_url_finish + (CamelEwsSettings *settings, + GAsyncResult *result, ++ gchar **out_certificate_pem, ++ GTlsCertificateFlags *out_certificate_errors, + GError **error); + const gchar * e_ews_connection_get_mailbox (EEwsConnection *cnc); + void e_ews_connection_set_mailbox (EEwsConnection *cnc, +diff -up evolution-ews-3.28.5/src/server/e-ews-connection-utils.c.cve-2019-3890 evolution-ews-3.28.5/src/server/e-ews-connection-utils.c +--- evolution-ews-3.28.5/src/server/e-ews-connection-utils.c.cve-2019-3890 2018-07-30 16:01:00.000000000 +0200 ++++ evolution-ews-3.28.5/src/server/e-ews-connection-utils.c 2019-04-15 09:43:49.690771516 +0200 +@@ -522,8 +522,13 @@ e_ews_connection_utils_prepare_message ( + GCancellable *cancellable) + { + ESoupAuthBearer *using_bearer_auth; ++ ESource *source; + GError *local_error = NULL; + ++ source = e_ews_connection_get_source (cnc); ++ if (source) ++ e_soup_ssl_trust_connect (message, source); ++ + if (!ews_connection_utils_maybe_prepare_bearer_auth (cnc, message, cancellable)) + return FALSE; + diff --git a/SOURCES/evolution-ews-3.28.5-sync-category-list.patch b/SOURCES/evolution-ews-3.28.5-sync-category-list.patch new file mode 100644 index 0000000..12cc76f --- /dev/null +++ b/SOURCES/evolution-ews-3.28.5-sync-category-list.patch @@ -0,0 +1,1168 @@ +diff -up evolution-ews-3.28.5/src/camel/camel-ews-store.c.sync-category-list evolution-ews-3.28.5/src/camel/camel-ews-store.c +--- evolution-ews-3.28.5/src/camel/camel-ews-store.c.sync-category-list 2019-10-24 09:39:08.336278207 +0200 ++++ evolution-ews-3.28.5/src/camel/camel-ews-store.c 2019-10-24 09:39:08.341278207 +0200 +@@ -673,6 +673,43 @@ ews_update_has_ooo_set (CamelSession *se + g_clear_object (&oof_settings); + } + ++static void ++ews_exchange_server_categories_cb (CamelSession *session, ++ GCancellable *cancellable, ++ gpointer user_data, ++ GError **error) ++{ ++ CamelEwsStore *ews_store = user_data; ++ EEwsConnection *cnc; ++ EwsFolderId fid = { 0 }; ++ gchar *properties = NULL; ++ GError *local_error = NULL; ++ ++ cnc = camel_ews_store_ref_connection (ews_store); ++ if (!cnc) ++ return; ++ ++ fid.id = (gchar *) "calendar"; ++ fid.is_distinguished_id = TRUE; ++ ++ if (e_ews_connection_get_user_configuration_sync (cnc, G_PRIORITY_DEFAULT, &fid, "CategoryList", ++ E_EWS_USER_CONFIGURATION_PROPERTIES_XMLDATA, &properties, cancellable, &local_error) && properties) { ++ guchar *data; ++ gsize data_len = 0; ++ ++ data = g_base64_decode (properties, &data_len); ++ ++ if (data && data_len > 0) ++ camel_ews_utils_merge_category_list (ews_store, data, data_len); ++ ++ g_free (data); ++ } ++ ++ g_clear_error (&local_error); ++ g_clear_object (&cnc); ++ g_free (properties); ++} ++ + struct ScheduleUpdateData + { + GCancellable *cancellable; +@@ -1252,6 +1289,12 @@ ews_connect_sync (CamelService *service, + g_object_ref (ews_store), + g_object_unref); + ++ camel_session_submit_job ( ++ session, _("Look up Exchange server categories"), ++ ews_exchange_server_categories_cb, ++ g_object_ref (ews_store), ++ g_object_unref); ++ + if (!priv->updates_cancellable) + priv->updates_cancellable = g_cancellable_new (); + +@@ -2377,6 +2420,17 @@ ews_get_folder_info_sync (CamelStore *st + ews_store = (CamelEwsStore *) store; + priv = ews_store->priv; + ++ if ((flags & CAMEL_STORE_FOLDER_INFO_REFRESH) != 0 && ++ camel_offline_store_get_online (CAMEL_OFFLINE_STORE (ews_store))) { ++ CamelSession *session; ++ ++ session = camel_service_ref_session (CAMEL_SERVICE (ews_store)); ++ if (session) { ++ ews_exchange_server_categories_cb (session, cancellable, ews_store, NULL); ++ g_object_unref (session); ++ } ++ } ++ + if ((flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST) != 0) { + gboolean includes_last_folder = TRUE; + GSList *folders = NULL, *to_check = NULL; +diff -up evolution-ews-3.28.5/src/camel/camel-ews-store-summary.c.sync-category-list evolution-ews-3.28.5/src/camel/camel-ews-store-summary.c +--- evolution-ews-3.28.5/src/camel/camel-ews-store-summary.c.sync-category-list 2018-07-30 16:01:00.000000000 +0200 ++++ evolution-ews-3.28.5/src/camel/camel-ews-store-summary.c 2019-10-24 09:39:08.341278207 +0200 +@@ -31,6 +31,7 @@ + #define S_UNLOCK(x) (g_rec_mutex_unlock(&(x)->priv->s_lock)) + + #define STORE_GROUP_NAME "##storepriv" ++#define CATEGORIES_KEY "Categories" + #define CURRENT_SUMMARY_VERSION 3 + + struct _CamelEwsStoreSummaryPrivate { +@@ -1047,3 +1048,159 @@ camel_ews_store_summary_has_folder (Came + + return ret; + } ++ ++static gchar * ++camel_ews_category_to_string (const CamelEwsCategory *cat) ++{ ++ gchar *guid, *name, *color_def = NULL, *str; ++ ++ g_return_val_if_fail (cat != NULL, NULL); ++ ++ guid = g_uri_escape_string (cat->guid, NULL, TRUE); ++ name = g_uri_escape_string (cat->name, NULL, TRUE); ++ ++ if (cat->color_def) ++ color_def = g_uri_escape_string (cat->color_def, NULL, TRUE); ++ ++ str = g_strconcat ( ++ guid ? guid : "", "\t", ++ name ? name : "", "\t", ++ color_def ? color_def : "", ++ NULL); ++ ++ g_free (guid); ++ g_free (name); ++ g_free (color_def); ++ ++ return str; ++} ++ ++static CamelEwsCategory * ++camel_ews_category_from_string (const gchar *str) ++{ ++ CamelEwsCategory *cat; ++ gchar **strv, *guid, *name, *color_def; ++ ++ g_return_val_if_fail (str != NULL, NULL); ++ ++ strv = g_strsplit (str, "\t", -1); ++ if (!strv || !strv[0] || !strv[1]) { ++ g_strfreev (strv); ++ return NULL; ++ } ++ ++ guid = g_uri_unescape_string (strv[0], NULL); ++ name = g_uri_unescape_string (strv[1], NULL); ++ color_def = (strv[2] && strv[2][0]) ? g_uri_unescape_string (strv[2], NULL) : NULL; ++ ++ cat = camel_ews_category_new (guid, name, color_def); ++ ++ g_free (guid); ++ g_free (name); ++ g_free (color_def); ++ g_strfreev (strv); ++ ++ return cat; ++} ++ ++GHashTable * /* gchar *guid ~> CamelEwsCategory * */ ++camel_ews_store_summary_get_categories (CamelEwsStoreSummary *ews_summary) ++{ ++ GHashTable *categories; ++ gchar **strv; ++ g_return_val_if_fail (CAMEL_IS_EWS_STORE_SUMMARY (ews_summary), NULL); ++ ++ S_LOCK (ews_summary); ++ ++ strv = g_key_file_get_string_list (ews_summary->priv->key_file, STORE_GROUP_NAME, CATEGORIES_KEY, NULL, NULL); ++ ++ S_UNLOCK (ews_summary); ++ ++ categories = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, camel_ews_category_free); ++ ++ if (strv) { ++ gint ii; ++ ++ for (ii = 0; strv[ii]; ii++) { ++ CamelEwsCategory *cat; ++ ++ cat = camel_ews_category_from_string (strv[ii]); ++ if (cat) ++ g_hash_table_insert (categories, cat->guid, cat); ++ } ++ ++ g_strfreev (strv); ++ } ++ ++ return categories; ++} ++ ++void ++camel_ews_store_summary_set_categories (CamelEwsStoreSummary *ews_summary, ++ GHashTable *categories) /* gchar *guid ~> CamelEwsCategory * */ ++{ ++ GPtrArray *array; ++ GHashTableIter iter; ++ gpointer value; ++ ++ g_return_if_fail (CAMEL_IS_EWS_STORE_SUMMARY (ews_summary)); ++ g_return_if_fail (categories != NULL); ++ ++ array = g_ptr_array_new_full (g_hash_table_size (categories), g_free); ++ ++ g_hash_table_iter_init (&iter, categories); ++ while (g_hash_table_iter_next (&iter, NULL, &value)) { ++ CamelEwsCategory *cat = value; ++ ++ if (cat) { ++ gchar *str; ++ ++ str = camel_ews_category_to_string (cat); ++ ++ if (str) ++ g_ptr_array_add (array, str); ++ } ++ } ++ ++ S_LOCK (ews_summary); ++ ++ g_key_file_set_string_list (ews_summary->priv->key_file, STORE_GROUP_NAME, CATEGORIES_KEY, ++ (const gchar * const *) array->pdata, array->len); ++ ++ ews_summary->priv->dirty = TRUE; ++ ++ S_UNLOCK (ews_summary); ++ ++ g_ptr_array_free (array, TRUE); ++} ++ ++CamelEwsCategory * ++camel_ews_category_new (const gchar *guid, ++ const gchar *name, ++ const gchar *color_def) ++{ ++ CamelEwsCategory *cat; ++ ++ g_return_val_if_fail (guid != NULL, NULL); ++ g_return_val_if_fail (name != NULL, NULL); ++ ++ cat = g_new0 (CamelEwsCategory, 1); ++ cat->guid = g_strdup (guid); ++ cat->name = g_strdup (name); ++ cat->color_def = g_strdup (color_def); ++ ++ return cat; ++} ++ ++void ++camel_ews_category_free (gpointer ptr) ++{ ++ CamelEwsCategory *cat = ptr; ++ ++ if (cat) { ++ g_free (cat->guid); ++ g_free (cat->name); ++ g_free (cat->color_def); ++ g_free (cat); ++ } ++} +diff -up evolution-ews-3.28.5/src/camel/camel-ews-store-summary.h.sync-category-list evolution-ews-3.28.5/src/camel/camel-ews-store-summary.h +--- evolution-ews-3.28.5/src/camel/camel-ews-store-summary.h.sync-category-list 2018-07-30 16:01:00.000000000 +0200 ++++ evolution-ews-3.28.5/src/camel/camel-ews-store-summary.h 2019-10-24 09:39:08.341278207 +0200 +@@ -50,6 +50,12 @@ + + G_BEGIN_DECLS + ++typedef struct _CamelEwsCategory { ++ gchar *guid; ++ gchar *name; ++ gchar *color_def; ++} CamelEwsCategory; ++ + typedef struct _CamelEwsStoreSummary CamelEwsStoreSummary; + typedef struct _CamelEwsStoreSummaryClass CamelEwsStoreSummaryClass; + typedef struct _CamelEwsStoreSummaryPrivate CamelEwsStoreSummaryPrivate; +@@ -215,6 +221,17 @@ gchar * camel_ews_store_summary_get_fol + gboolean camel_ews_store_summary_has_folder + (CamelEwsStoreSummary *ews_summary, + const gchar *id); ++GHashTable * camel_ews_store_summary_get_categories /* gchar *guid ~> CamelEwsCategory * */ ++ (CamelEwsStoreSummary *ews_summary); ++void camel_ews_store_summary_set_categories ++ (CamelEwsStoreSummary *ews_summary, ++ GHashTable *categories); /* gchar *guid ~> CamelEwsCategory * */ ++ ++CamelEwsCategory * ++ camel_ews_category_new (const gchar *guid, ++ const gchar *name, ++ const gchar *color_def); ++void camel_ews_category_free (gpointer ptr); /* CamelEwsCategory * */ + + G_END_DECLS + +diff -up evolution-ews-3.28.5/src/camel/camel-ews-utils.c.sync-category-list evolution-ews-3.28.5/src/camel/camel-ews-utils.c +--- evolution-ews-3.28.5/src/camel/camel-ews-utils.c.sync-category-list 2018-07-30 16:01:00.000000000 +0200 ++++ evolution-ews-3.28.5/src/camel/camel-ews-utils.c 2019-10-24 09:39:08.341278207 +0200 +@@ -29,6 +29,7 @@ + #include + + #include ++#include + + #include "server/camel-ews-settings.h" + #include "server/e-ews-camel-common.h" +@@ -381,6 +382,43 @@ camel_ews_utils_sync_deleted_items (Came + } + + static const gchar * ++ews_utils_outlook_color_index_to_color_def (gint color_index) ++{ ++ const gchar *colors_array[] = { ++ "#ff1a36", /* Red */ ++ "#ff8c00", /* Orange */ ++ "#f4b10b", /* Peach */ ++ "#fff100", /* Yellow */ ++ "#009e48", /* Green */ ++ "#00b294", /* Teal */ ++ "#89933f", /* Olive */ ++ "#00bcf2", /* Blue */ ++ "#8e69df", /* Purple */ ++ "#f30092", /* Maroon */ ++ "#6c7e9a", /* Steel */ ++ "#425066", /* DarkSteel */ ++ "#969696", /* Gray */ ++ "#525552", /* DarkGray */ ++ "#282828", /* Black */ ++ "#a00023", /* DarkRed */ ++ "#c45502", /* DarkOrange */ ++ "#af7000", /* DarkPeach */ ++ "#b59b02", /* DarkYellow */ ++ "#176002", /* DarkGreen */ ++ "#00725c", /* DarkTeal */ ++ "#5c6022", /* DarkOlive */ ++ "#036393", /* DarkBlue */ ++ "#422f8e", /* DarkPurple */ ++ "#960269" /* DarkMaroon */ ++ }; ++ ++ if (color_index >= 0 && color_index < G_N_ELEMENTS (colors_array)) ++ return colors_array[color_index]; ++ ++ return NULL; ++} ++ ++static const gchar * + ews_utils_rename_label (const gchar *cat, + gboolean from_cat) + { +@@ -422,6 +460,58 @@ ews_utils_is_system_user_flag (const gch + g_str_equal (name, "$has-cal"); + } + ++/* From Exchange name (which allows spaces) to evolution-name */ ++static gchar * ++camel_ews_utils_encode_category_name (const gchar *name) ++{ ++ if (name && strchr (name, ' ')) { ++ GString *str; ++ ++ str = g_string_sized_new (strlen (name) + 16); ++ ++ while (*name) { ++ if (*name == '_') ++ g_string_append_c (str, '_'); ++ ++ g_string_append_c (str, *name == ' ' ? '_' : *name); ++ ++ name++; ++ } ++ ++ return g_string_free (str, FALSE); ++ } ++ ++ return g_strdup (name); ++} ++ ++/* From evolution-name to Exchange name (which allows spaces) */ ++static gchar * ++camel_ews_utils_decode_category_name (const gchar *flag) ++{ ++ if (flag && strchr (flag, '_')) { ++ GString *str = g_string_sized_new (strlen (flag)); ++ ++ while (*flag) { ++ if (*flag == '_') { ++ if (flag[1] == '_') { ++ g_string_append_c (str, '_'); ++ flag++; ++ } else { ++ g_string_append_c (str, ' '); ++ } ++ } else { ++ g_string_append_c (str, *flag); ++ } ++ ++ flag++; ++ } ++ ++ return g_string_free (str, FALSE); ++ } ++ ++ return g_strdup (flag); ++} ++ + /* free with g_slist_free_full (flags, g_free); + the lists' members are values for the String xml element. */ + GSList * +@@ -441,6 +531,7 @@ ews_utils_gather_server_user_flags (ESoa + * array of strings */ + for (ii = 0; ii < len; ii++) { + const gchar *n = ews_utils_rename_label (camel_named_flags_get (user_flags, ii), FALSE); ++ + if (*n == '\0') + continue; + +@@ -449,26 +540,7 @@ ews_utils_gather_server_user_flags (ESoa + if (ews_utils_is_system_user_flag (n)) + continue; + +- if (strchr (n, '_')) { +- GString *str = g_string_sized_new (strlen (n)); +- +- while (*n) { +- if (*n == '_') { +- if (n[1] == '_') +- g_string_append_c (str, '_'); +- else +- g_string_append_c (str, ' '); +- } else { +- g_string_append_c (str, *n); +- } +- +- n++; +- } +- +- out_user_flags = g_slist_prepend (out_user_flags, g_string_free (str, FALSE)); +- } else { +- out_user_flags = g_slist_prepend (out_user_flags, g_strdup (n)); +- } ++ out_user_flags = g_slist_prepend (out_user_flags, camel_ews_utils_decode_category_name (n)); + } + + camel_message_info_property_unlock (mi); +@@ -512,33 +584,17 @@ ews_utils_merge_server_user_flags (EEwsI + + /* now transfer over all the categories */ + for (p = e_ews_item_get_categories (item); p; p = p->next) { +- const gchar *flag = ews_utils_rename_label (p->data, 1); +- gchar *underscored = NULL; ++ const gchar *name = ews_utils_rename_label (p->data, 1); ++ gchar *flag; + +- if (!flag || !*flag) ++ if (!name || !*name) + continue; + +- if (strchr (flag, ' ')) { +- GString *str; +- +- str = g_string_sized_new (strlen (flag) + 16); +- +- while (*flag) { +- if (*flag == '_') +- g_string_append_c (str, '_'); +- +- g_string_append_c (str, *flag == ' ' ? '_' : *flag); +- +- flag++; +- } +- +- underscored = g_string_free (str, FALSE); +- flag = underscored; +- } ++ flag = camel_ews_utils_encode_category_name (name); + + camel_message_info_set_user_flag (mi, flag, TRUE); + +- g_free (underscored); ++ g_free (flag); + } + + camel_message_info_thaw_notifications (mi); +@@ -1281,3 +1337,279 @@ camel_ews_utils_ref_corresponding_source + + return source; + } ++ ++static gboolean ++ews_util_equal_label_tag_cb (gconstpointer ptr1, ++ gconstpointer ptr2) ++{ ++ const gchar *evo_label_def = ptr1; ++ const gchar *tag = ptr2; ++ const gchar *pos; ++ ++ if (!evo_label_def || !tag || !*tag) ++ return FALSE; ++ ++ pos = g_strrstr (evo_label_def, tag); ++ ++ return pos > evo_label_def && pos[-1] == '|' && !pos[strlen (tag)]; ++} ++ ++static gboolean ++ews_utils_find_in_ptr_array (GPtrArray *haystack, ++ gconstpointer needle, ++ GEqualFunc equal_func, ++ guint *out_index) ++{ ++ guint ii; ++ ++ if (!haystack) ++ return FALSE; ++ ++ if (!equal_func) ++ equal_func = g_direct_equal; ++ ++ for (ii = 0; ii < haystack->len; ii++) { ++ if (equal_func (haystack->pdata[ii], needle)) { ++ if (out_index) ++ *out_index = ii; ++ ++ return TRUE; ++ } ++ } ++ ++ return FALSE; ++} ++ ++/* Returns whether had been done any changes */ ++static gboolean ++ews_utils_save_category_changes (GHashTable *old_categories, /* gchar *guid ~> CamelEwsCategory * */ ++ GHashTable *new_categories) /* gchar *guid ~> CamelEwsCategory * */ ++{ ++ GHashTableIter iter; ++ GSettings *settings; ++ GPtrArray *evo_labels; /* gchar * (encoded label definition) */ ++ gchar **strv; ++ gint ii; ++ gpointer value; ++ gboolean changed = FALSE; ++ ++ if (!old_categories || !new_categories) ++ return new_categories != NULL; ++ ++ evo_labels = g_ptr_array_new_full (5, g_free); ++ ++ settings = e_util_ref_settings ("org.gnome.evolution.mail"); ++ strv = g_settings_get_strv (settings, "labels"); ++ ++ for (ii = 0; strv && strv[ii]; ii++) { ++ g_ptr_array_add (evo_labels, g_strdup (strv[ii])); ++ } ++ ++ g_strfreev (strv); ++ ++ g_hash_table_iter_init (&iter, new_categories); ++ while (g_hash_table_iter_next (&iter, NULL, &value)) { ++ CamelEwsCategory *new_cat = value, *old_cat; ++ gchar *tag = NULL; ++ ++ if (!new_cat) ++ continue; ++ ++ old_cat = g_hash_table_lookup (old_categories, new_cat->guid); ++ if (old_cat) { ++ if (g_strcmp0 (old_cat->name, new_cat->name) != 0 || ++ g_strcmp0 (old_cat->color_def, new_cat->color_def) != 0) { ++ /* Old category changed name or color */ ++ tag = camel_ews_utils_encode_category_name (new_cat->name); ++ } ++ } else { ++ /* This is a new category */ ++ tag = camel_ews_utils_encode_category_name (new_cat->name); ++ } ++ ++ if (tag && *tag) { ++ guint index = (guint) -1; ++ gchar *label_def; ++ ++ changed = TRUE; ++ ++ /* Sanitize value */ ++ for (ii = 0; tag[ii]; ii++) { ++ if (tag[ii] == '|') ++ tag[ii] = '-'; ++ } ++ ++ if (old_cat && g_strcmp0 (old_cat->name, new_cat->name) != 0) { ++ gchar *old_tag = camel_ews_utils_encode_category_name (old_cat->name); ++ ++ if (old_tag && *old_tag) { ++ if (!ews_utils_find_in_ptr_array (evo_labels, old_tag, ews_util_equal_label_tag_cb, &index)) ++ index = (guint) -1; ++ } ++ ++ g_free (old_tag); ++ } ++ ++ for (ii = 0; new_cat->name[ii]; ii++) { ++ if (new_cat->name[ii] == '|') ++ new_cat->name[ii] = '-'; ++ } ++ ++ if (index == (guint) -1 && ++ !ews_utils_find_in_ptr_array (evo_labels, tag, ews_util_equal_label_tag_cb, &index)) ++ index = (guint) -1; ++ ++ label_def = g_strconcat (new_cat->name, "|", new_cat->color_def ? new_cat->color_def : "#FF0000", "|", tag, NULL); ++ ++ if (index == (guint) -1 || index >= (gint) evo_labels->len) { ++ g_ptr_array_add (evo_labels, label_def); ++ } else { ++ g_free (evo_labels->pdata[index]); ++ evo_labels->pdata[index] = label_def; ++ } ++ } ++ ++ g_hash_table_remove (old_categories, new_cat->guid); ++ ++ g_free (tag); ++ } ++ ++ if (g_hash_table_size (old_categories) > 0) { ++ /* Some categories had been removed */ ++ changed = TRUE; ++ ++ g_hash_table_iter_init (&iter, old_categories); ++ while (g_hash_table_iter_next (&iter, NULL, &value)) { ++ CamelEwsCategory *old_cat = value; ++ gchar *old_tag; ++ guint index; ++ ++ if (!old_cat) ++ continue; ++ ++ old_tag = camel_ews_utils_encode_category_name (old_cat->name); ++ ++ for (ii = 0; old_tag && old_tag[ii]; ii++) { ++ if (old_tag[ii] == '|') ++ old_tag[ii] = '-'; ++ } ++ ++ if (old_tag && ++ ews_utils_find_in_ptr_array (evo_labels, old_tag, ews_util_equal_label_tag_cb, &index)) ++ g_ptr_array_remove_index (evo_labels, index); ++ ++ g_free (old_tag); ++ } ++ } ++ ++ if (changed) { ++ /* NULL-terminated array of strings */ ++ g_ptr_array_add (evo_labels, NULL); ++ ++ g_settings_set_strv (settings, "labels", (const gchar * const *) evo_labels->pdata); ++ } ++ ++ g_ptr_array_free (evo_labels, TRUE); ++ g_object_unref (settings); ++ ++ return changed; ++} ++ ++void ++camel_ews_utils_merge_category_list (CamelEwsStore *ews_store, ++ const guchar *xml_data, ++ gsize xml_data_len) ++{ ++ xmlDocPtr doc; ++ xmlXPathContextPtr xpath_ctx; ++ ++ g_return_if_fail (CAMEL_IS_EWS_STORE (ews_store)); ++ g_return_if_fail (xml_data != NULL); ++ ++ doc = e_xml_parse_data (xml_data, xml_data_len); ++ if (!doc) ++ return; ++ ++ xpath_ctx = e_xml_new_xpath_context_with_namespaces (doc, "C", "CategoryList.xsd", NULL); ++ ++ if (xpath_ctx) { ++ xmlXPathObjectPtr xpath_obj_categories; ++ ++ xpath_obj_categories = e_xml_xpath_eval (xpath_ctx, "%s", "/C:categories/C:category"); ++ ++ if (xpath_obj_categories) { ++ GHashTable *old_categories, *new_categories; ++ gint response_index, response_length; ++ ++ new_categories = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, camel_ews_category_free); ++ ++ response_length = xmlXPathNodeSetGetLength (xpath_obj_categories->nodesetval); ++ ++ for (response_index = 0; response_index < response_length; response_index++) { ++ xmlXPathObjectPtr xpath_obj_category; ++ ++ xpath_obj_category = e_xml_xpath_eval (xpath_ctx, ++ "/C:categories/C:category[%d]", ++ response_index + 1); ++ ++ if (xpath_obj_category) { ++ gchar *name; ++ ++ name = e_xml_xpath_eval_as_string (xpath_ctx, "/C:categories/C:category[%d]/@name", response_index + 1); ++ ++ if (name && ews_utils_rename_label (name, 1) == name) { ++ const gchar *color_def = NULL; ++ gchar *color, *guid; ++ gint color_index = -1; ++ ++ color = e_xml_xpath_eval_as_string (xpath_ctx, "/C:categories/C:category[%d]/@color", response_index + 1); ++ if (color) { ++ gchar *endptr = NULL; ++ ++ color_index = (gint) g_ascii_strtoll (color, &endptr, 10); ++ ++ if (endptr == color) ++ color_index = -1; ++ } ++ ++ g_free (color); ++ ++ if (color_index >= 0) ++ color_def = ews_utils_outlook_color_index_to_color_def (color_index); ++ ++ guid = e_xml_xpath_eval_as_string (xpath_ctx, "/C:categories/C:category[%d]/@guid", response_index + 1); ++ ++ if (guid && *guid) { ++ CamelEwsCategory *cat; ++ ++ cat = camel_ews_category_new (guid, name, color_def); ++ if (cat) ++ g_hash_table_insert (new_categories, cat->guid, cat); ++ } ++ ++ g_free (guid); ++ } ++ ++ g_free (name); ++ xmlXPathFreeObject (xpath_obj_category); ++ } ++ } ++ ++ xmlXPathFreeObject (xpath_obj_categories); ++ ++ old_categories = camel_ews_store_summary_get_categories (ews_store->summary); ++ ++ if (ews_utils_save_category_changes (old_categories, new_categories)) { ++ camel_ews_store_summary_set_categories (ews_store->summary, new_categories); ++ camel_ews_store_summary_save (ews_store->summary, NULL); ++ } ++ ++ g_hash_table_destroy (new_categories); ++ g_hash_table_destroy (old_categories); ++ } ++ } ++ ++ if (xpath_ctx) ++ xmlXPathFreeContext (xpath_ctx); ++ xmlFreeDoc (doc); ++} +diff -up evolution-ews-3.28.5/src/camel/camel-ews-utils.h.sync-category-list evolution-ews-3.28.5/src/camel/camel-ews-utils.h +--- evolution-ews-3.28.5/src/camel/camel-ews-utils.h.sync-category-list 2018-07-30 16:01:00.000000000 +0200 ++++ evolution-ews-3.28.5/src/camel/camel-ews-utils.h 2019-10-24 09:39:08.341278207 +0200 +@@ -94,6 +94,10 @@ CamelMessageInfo * /* (transfer full) */ + EEwsConnection *cnc, + EEwsItem *item, + GCancellable *cancellable); ++void camel_ews_utils_merge_category_list ++ (CamelEwsStore *ews_store, ++ const guchar *xml_data, ++ gsize xml_data_len); + + G_END_DECLS + +diff -up evolution-ews-3.28.5/src/server/e-ews-connection.c.sync-category-list evolution-ews-3.28.5/src/server/e-ews-connection.c +--- evolution-ews-3.28.5/src/server/e-ews-connection.c.sync-category-list 2019-10-24 09:39:08.339278207 +0200 ++++ evolution-ews-3.28.5/src/server/e-ews-connection.c 2019-10-24 09:46:14.667272312 +0200 +@@ -155,7 +155,7 @@ struct _EwsAsyncData { + EwsDelegateDeliver deliver_to; + EEwsFolderType folder_type; + EEwsConnection *cnc; +- gchar *user_photo; /* base64-encoded, as GetUserPhoto result */ ++ gchar *custom_data; /* Can be re-used by operations, will be freed with g_free() */ + }; + + struct _EwsNode { +@@ -200,7 +200,7 @@ ews_connection_error_quark (void) + static void + async_data_free (EwsAsyncData *async_data) + { +- g_free (async_data->user_photo); ++ g_free (async_data->custom_data); + g_free (async_data); + } + +@@ -10830,10 +10830,10 @@ get_user_photo_response_cb (ESoapRespons + return; + } + +- async_data->user_photo = e_soap_parameter_get_string_value (param); +- if (async_data->user_photo && !*async_data->user_photo) { +- g_free (async_data->user_photo); +- async_data->user_photo = NULL; ++ async_data->custom_data = e_soap_parameter_get_string_value (param); ++ if (async_data->custom_data && !*async_data->custom_data) { ++ g_free (async_data->custom_data); ++ async_data->custom_data = NULL; + } + } + +@@ -10918,11 +10918,11 @@ e_ews_connection_get_user_photo_finish ( + if (g_simple_async_result_propagate_error (simple, error)) + return FALSE; + +- if (!async_data->user_photo) ++ if (!async_data->custom_data) + return FALSE; + +- *out_picture_data = async_data->user_photo; +- async_data->user_photo = NULL; ++ *out_picture_data = async_data->custom_data; ++ async_data->custom_data = NULL; + + return TRUE; + } +@@ -10953,5 +10953,256 @@ e_ews_connection_get_user_photo_sync (EE + + e_async_closure_free (closure); + ++ return success; ++} ++ ++static void ++get_user_configuration_response_cb (ESoapResponse *response, ++ GSimpleAsyncResult *simple) ++{ ++ EwsAsyncData *async_data; ++ ESoapParameter *param, *subparam; ++ GError *error = NULL; ++ ++ async_data = g_simple_async_result_get_op_res_gpointer (simple); ++ ++ param = e_soap_response_get_first_parameter_by_name (response, "ResponseMessages", &error); ++ ++ if (param) { ++ param = e_soap_parameter_get_first_child_by_name (param, "GetUserConfigurationResponseMessage"); ++ if (!param) { ++ g_set_error (&error, ++ SOUP_HTTP_ERROR, SOUP_STATUS_MALFORMED, ++ "Missing <%s> in SOAP response", "GetUserConfigurationResponseMessage"); ++ } ++ } ++ ++ if (param) { ++ param = e_soap_parameter_get_first_child_by_name (param, "UserConfiguration"); ++ if (!param) { ++ g_set_error (&error, ++ SOUP_HTTP_ERROR, SOUP_STATUS_MALFORMED, ++ "Missing <%s> in SOAP response", "UserConfiguration"); ++ } ++ } ++ ++ /* Sanity check */ ++ g_return_if_fail ( ++ (param != NULL && error == NULL) || ++ (param == NULL && error != NULL)); ++ ++ if (error != NULL) { ++ g_simple_async_result_take_error (simple, error); ++ return; ++ } ++ ++ subparam = e_soap_parameter_get_first_child_by_name (param, "ItemId"); ++ if (subparam) { ++ gchar *id, *changekey; ++ ++ id = e_soap_parameter_get_property (subparam, "Id"); ++ changekey = e_soap_parameter_get_property (subparam, "ChangeKey"); ++ ++ /* Encoded as: Id + "\n" + ChangeKey */ ++ async_data->custom_data = g_strconcat (id ? id : "", "\n", changekey, NULL); ++ ++ g_free (changekey); ++ g_free (id); ++ } ++ ++ if (!subparam) { ++ subparam = e_soap_parameter_get_first_child_by_name (param, "Dictionary"); ++ if (subparam) ++ async_data->custom_data = e_soap_response_dump_parameter (response, subparam); ++ } ++ ++ if (!subparam) { ++ subparam = e_soap_parameter_get_first_child_by_name (param, "XmlData"); ++ if (subparam) { ++ async_data->custom_data = e_soap_parameter_get_string_value (subparam); ++ } ++ } ++ ++ if (!subparam) { ++ subparam = e_soap_parameter_get_first_child_by_name (param, "BinaryData"); ++ if (subparam) { ++ async_data->custom_data = e_soap_parameter_get_string_value (subparam); ++ } ++ } ++ ++ if (async_data->custom_data && !*async_data->custom_data) { ++ g_free (async_data->custom_data); ++ async_data->custom_data = NULL; ++ } ++} ++ ++static void ++e_ews_folder_id_append_to_msg (ESoapMessage *msg, ++ const gchar *email, ++ const EwsFolderId *fid) ++{ ++ g_return_if_fail (msg != NULL); ++ g_return_if_fail (fid != NULL); ++ ++ if (fid->is_distinguished_id) ++ e_soap_message_start_element (msg, "DistinguishedFolderId", NULL, NULL); ++ else ++ e_soap_message_start_element (msg, "FolderId", NULL, NULL); ++ ++ e_soap_message_add_attribute (msg, "Id", fid->id, NULL, NULL); ++ if (fid->change_key) ++ e_soap_message_add_attribute (msg, "ChangeKey", fid->change_key, NULL, NULL); ++ ++ if (fid->is_distinguished_id && email) { ++ e_soap_message_start_element (msg, "Mailbox", NULL, NULL); ++ e_ews_message_write_string_parameter (msg, "EmailAddress", NULL, email); ++ e_soap_message_end_element (msg); ++ } ++ ++ e_soap_message_end_element (msg); ++} ++ ++void ++e_ews_connection_get_user_configuration (EEwsConnection *cnc, ++ gint pri, ++ const EwsFolderId *fid, ++ const gchar *config_name, ++ EEwsUserConfigurationProperties props, ++ GCancellable *cancellable, ++ GAsyncReadyCallback callback, ++ gpointer user_data) ++{ ++ ESoapMessage *msg; ++ GSimpleAsyncResult *simple; ++ EwsAsyncData *async_data; ++ EwsFolderId local_fid; ++ ++ g_return_if_fail (cnc != NULL); ++ g_return_if_fail (cnc->priv != NULL); ++ g_return_if_fail (fid != NULL); ++ g_return_if_fail (config_name != NULL); ++ ++ simple = g_simple_async_result_new (G_OBJECT (cnc), callback, user_data, e_ews_connection_get_user_configuration); ++ async_data = g_new0 (EwsAsyncData, 1); ++ g_simple_async_result_set_op_res_gpointer (simple, async_data, (GDestroyNotify) async_data_free); ++ ++ /* EWS server version earlier than 2010 doesn't support it. */ ++ if (!e_ews_connection_satisfies_server_version (cnc, E_EWS_EXCHANGE_2010)) { ++ g_simple_async_result_complete_in_idle (simple); ++ g_object_unref (simple); ++ return; ++ } ++ ++ local_fid = *fid; ++ local_fid.change_key = NULL; ++ ++ msg = e_ews_message_new_with_header ( ++ cnc->priv->settings, ++ cnc->priv->uri, ++ cnc->priv->impersonate_user, ++ "GetUserConfiguration", ++ NULL, ++ NULL, ++ cnc->priv->version, ++ E_EWS_EXCHANGE_2010, ++ FALSE, ++ TRUE); ++ ++ e_soap_message_start_element (msg, "UserConfigurationName", "messages", NULL); ++ e_soap_message_add_attribute (msg, "Name", config_name, NULL, NULL); ++ ++ e_ews_folder_id_append_to_msg (msg, cnc->priv->email, &local_fid); ++ ++ e_soap_message_end_element (msg); /* UserConfigurationName */ ++ ++ e_soap_message_start_element (msg, "UserConfigurationProperties", "messages", NULL); ++ ++ switch (props) { ++ case E_EWS_USER_CONFIGURATION_PROPERTIES_ID: ++ e_soap_message_write_string (msg, "Id"); ++ break; ++ case E_EWS_USER_CONFIGURATION_PROPERTIES_DICTIONARY: ++ e_soap_message_write_string (msg, "Dictionary"); ++ break; ++ case E_EWS_USER_CONFIGURATION_PROPERTIES_XMLDATA: ++ e_soap_message_write_string (msg, "XmlData"); ++ break; ++ case E_EWS_USER_CONFIGURATION_PROPERTIES_BINARYDATA: ++ e_soap_message_write_string (msg, "BinaryData"); ++ break; ++ /* case E_EWS_USER_CONFIGURATION_PROPERTIES_ALL: ++ e_soap_message_write_string (msg, "All"); ++ break; */ ++ default: ++ e_soap_message_write_string (msg, "Unknown"); ++ break; ++ } ++ ++ e_soap_message_end_element (msg); /* UserConfigurationProperties */ ++ ++ e_ews_message_write_footer (msg); ++ ++ e_ews_connection_queue_request (cnc, msg, get_user_configuration_response_cb, pri, cancellable, simple); ++ ++ g_object_unref (simple); ++} ++ ++gboolean ++e_ews_connection_get_user_configuration_finish (EEwsConnection *cnc, ++ GAsyncResult *result, ++ gchar **out_properties, ++ GError **error) ++{ ++ GSimpleAsyncResult *simple; ++ EwsAsyncData *async_data; ++ ++ g_return_val_if_fail (cnc != NULL, FALSE); ++ g_return_val_if_fail ( ++ g_simple_async_result_is_valid (result, G_OBJECT (cnc), e_ews_connection_get_user_configuration), ++ FALSE); ++ g_return_val_if_fail (out_properties != NULL, FALSE); ++ ++ simple = G_SIMPLE_ASYNC_RESULT (result); ++ async_data = g_simple_async_result_get_op_res_gpointer (simple); ++ ++ if (g_simple_async_result_propagate_error (simple, error)) ++ return FALSE; ++ ++ if (!async_data->custom_data) ++ return FALSE; ++ ++ *out_properties = async_data->custom_data; ++ async_data->custom_data = NULL; ++ ++ return TRUE; ++} ++ ++gboolean ++e_ews_connection_get_user_configuration_sync (EEwsConnection *cnc, ++ gint pri, ++ const EwsFolderId *fid, ++ const gchar *config_name, ++ EEwsUserConfigurationProperties props, ++ gchar **out_properties, ++ GCancellable *cancellable, ++ GError **error) ++{ ++ EAsyncClosure *closure; ++ GAsyncResult *result; ++ gboolean success; ++ ++ g_return_val_if_fail (cnc != NULL, FALSE); ++ ++ closure = e_async_closure_new (); ++ ++ e_ews_connection_get_user_configuration ( ++ cnc, pri, fid, config_name, props, cancellable, e_async_closure_callback, closure); ++ ++ result = e_async_closure_wait (closure); ++ ++ success = e_ews_connection_get_user_configuration_finish (cnc, result, out_properties, error); ++ ++ e_async_closure_free (closure); ++ + return success; + } +diff -up evolution-ews-3.28.5/src/server/e-ews-connection.h.sync-category-list evolution-ews-3.28.5/src/server/e-ews-connection.h +--- evolution-ews-3.28.5/src/server/e-ews-connection.h.sync-category-list 2019-10-24 09:39:08.339278207 +0200 ++++ evolution-ews-3.28.5/src/server/e-ews-connection.h 2019-10-24 09:39:08.342278207 +0200 +@@ -132,6 +132,15 @@ typedef enum { + E_EWS_SIZE_REQUESTED_648X648 = 648 + } EEwsSizeRequested; + ++typedef enum { ++ E_EWS_USER_CONFIGURATION_PROPERTIES_UNKNOWN = -1, ++ E_EWS_USER_CONFIGURATION_PROPERTIES_ID, ++ E_EWS_USER_CONFIGURATION_PROPERTIES_DICTIONARY, ++ E_EWS_USER_CONFIGURATION_PROPERTIES_XMLDATA, ++ E_EWS_USER_CONFIGURATION_PROPERTIES_BINARYDATA /*, ++ E_EWS_USER_CONFIGURATION_PROPERTIES_ALL - skip it, be specific */ ++} EEwsUserConfigurationProperties; ++ + typedef struct { + gchar *id; + gchar *dn; +@@ -1377,6 +1386,29 @@ gboolean e_ews_connection_get_user_photo + gchar **out_picture_data, /* base64-encoded */ + GCancellable *cancellable, + GError **error); ++void e_ews_connection_get_user_configuration ++ (EEwsConnection *cnc, ++ gint pri, ++ const EwsFolderId *fid, ++ const gchar *config_name, ++ EEwsUserConfigurationProperties props, ++ GCancellable *cancellable, ++ GAsyncReadyCallback callback, ++ gpointer user_data); ++gboolean e_ews_connection_get_user_configuration_finish ++ (EEwsConnection *cnc, ++ GAsyncResult *result, ++ gchar **out_properties, ++ GError **error); ++gboolean e_ews_connection_get_user_configuration_sync ++ (EEwsConnection *cnc, ++ gint pri, ++ const EwsFolderId *fid, ++ const gchar *config_name, ++ EEwsUserConfigurationProperties props, ++ gchar **out_properties, ++ GCancellable *cancellable, ++ GError **error); + + G_END_DECLS + +diff -up evolution-ews-3.28.5/src/server/e-soap-response.c.sync-category-list evolution-ews-3.28.5/src/server/e-soap-response.c +--- evolution-ews-3.28.5/src/server/e-soap-response.c.sync-category-list 2018-07-30 16:01:00.000000000 +0200 ++++ evolution-ews-3.28.5/src/server/e-soap-response.c 2019-10-24 09:39:08.342278207 +0200 +@@ -685,3 +685,29 @@ e_soap_response_dump_response (ESoapResp + + return ret; + } ++ ++gchar * ++e_soap_response_dump_parameter (ESoapResponse *response, ++ ESoapParameter *param) ++{ ++ xmlBuffer *buffer; ++ gint len; ++ gchar *data; ++ ++ g_return_val_if_fail (E_IS_SOAP_RESPONSE (response), NULL); ++ g_return_val_if_fail (param != NULL, NULL); ++ ++ buffer = xmlBufferCreate (); ++ len = xmlNodeDump (buffer, response->priv->xmldoc, param, 0, 0); ++ ++ if (len <= 0) { ++ xmlBufferFree (buffer); ++ return NULL; ++ } ++ ++ data = g_strndup ((const gchar *) buffer->content, len); ++ ++ xmlBufferFree (buffer); ++ ++ return data; ++} +diff -up evolution-ews-3.28.5/src/server/e-soap-response.h.sync-category-list evolution-ews-3.28.5/src/server/e-soap-response.h +--- evolution-ews-3.28.5/src/server/e-soap-response.h.sync-category-list 2018-07-30 16:01:00.000000000 +0200 ++++ evolution-ews-3.28.5/src/server/e-soap-response.h 2019-10-24 09:39:08.343278207 +0200 +@@ -101,6 +101,8 @@ ESoapParameter * + const gchar *name); + gint e_soap_response_dump_response (ESoapResponse *response, + FILE *buffer); ++gchar * e_soap_response_dump_parameter (ESoapResponse *response, ++ ESoapParameter *param); + + G_END_DECLS + diff --git a/SPECS/evolution-ews.spec b/SPECS/evolution-ews.spec index 66b337f..582e60f 100644 --- a/SPECS/evolution-ews.spec +++ b/SPECS/evolution-ews.spec @@ -2,7 +2,7 @@ Name: evolution-ews Version: 3.28.5 -Release: 2%{?dist} +Release: 5%{?dist} Group: Applications/Productivity Summary: Evolution extension for Exchange Web Services License: LGPLv2 @@ -28,6 +28,12 @@ Patch05: evolution-ews-3.28.5-meeting-with-attachment.patch # RH bug #1633711 - 5/5 - https://gitlab.gnome.org/GNOME/evolution-ews/commit/f50530ad101b47d461a345ff2b8b295b86c05d3a Patch06: evolution-ews-3.28.5-double-collection-backend-populate.patch +# RH bug #1696760 +Patch07: evolution-ews-3.28.5-cve-2019-3890.patch + +# RH bug #1392567 +Patch08: evolution-ews-3.28.5-sync-category-list.patch + Requires: evolution >= %{eds_evo_version} Requires: evolution-data-server >= %{eds_evo_version} Requires: %{name}-langpacks = %{version}-%{release} @@ -72,6 +78,8 @@ This package contains translations for %{name}. %patch04 -p1 -b .contact-country-forgotten %patch05 -p1 -b .meeting-with-attachment %patch06 -p1 -b .double-collection-backend-populate +%patch07 -p1 -b .cve-2019-3890 +%patch08 -p1 -b .sync-category-list %build @@ -112,6 +120,16 @@ make install DESTDIR=$RPM_BUILD_ROOT %files langpacks -f _build/%{name}.lang %changelog +* Tue Oct 29 2019 Milan Crha - 3.28.5-5 +- Remove patch for RH bug #1764669 (Send meeting change notifications only if being the organizer) + +* Thu Oct 24 2019 Milan Crha - 3.28.5-4 +- Add patch for RH bug #1392567 (Sync CategoryList with mail Labels) +- Add patch for RH bug #1764669 (Send meeting change notifications only if being the organizer) + +* Wed Aug 14 2019 Milan Crha - 3.28.5-3 +- Add patch for RH bug #1696760 (CVE-2019-3890 - SSL Certificates are not validated) + * Fri Nov 09 2018 Milan Crha - 3.28.5-2 - Add patches for RH bug #1633711 (Backport few minor regression fixes from 3.30)