[evolution-mapi] Claim detailed error when org.gnome.KrbAuthDialog not found
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-mapi] Claim detailed error when org.gnome.KrbAuthDialog not found
- Date: Wed, 25 Apr 2018 15:15:24 +0000 (UTC)
commit bb03200f1e0b23a7d66e7b00fece7099dc82906a
Author: Milan Crha <mcrha redhat com>
Date: Wed Apr 25 17:17:13 2018 +0200
Claim detailed error when org.gnome.KrbAuthDialog not found
po/POTFILES.in | 1 +
src/camel/camel-mapi-store.c | 34 ++++++++++++++++++-----
src/collection/e-mapi-backend.c | 21 ++++++++++++---
src/configuration/e-mail-config-mapi-backend.c | 26 +++++++++++++++---
src/configuration/e-mapi-config-utils.c | 21 +++++++++++++-
src/libexchangemapi/e-mapi-utils.c | 12 ++++++++
6 files changed, 97 insertions(+), 18 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6a848cb..403e110 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -20,3 +20,4 @@ src/configuration/e-mapi-subscribe-foreign-folder.c
src/libexchangemapi/e-mapi-cal-utils.c
src/libexchangemapi/e-mapi-connection.c
src/libexchangemapi/e-mapi-folder.c
+src/libexchangemapi/e-mapi-utils.c
diff --git a/src/camel/camel-mapi-store.c b/src/camel/camel-mapi-store.c
index 2343c26..cd67d6d 100644
--- a/src/camel/camel-mapi-store.c
+++ b/src/camel/camel-mapi-store.c
@@ -2990,7 +2990,7 @@ mapi_authenticate_sync (CamelService *service,
EMapiProfileData empd = { 0 };
const gchar *profile;
const gchar *password;
- GError *mapi_error = NULL;
+ GError *mapi_error = NULL, *krb_error = NULL;
ENamedParameters *credentials;
settings = camel_service_ref_settings (service);
@@ -3004,8 +3004,7 @@ mapi_authenticate_sync (CamelService *service,
profile = camel_mapi_settings_get_profile (mapi_settings);
if (empd.krb_sso) {
- e_mapi_util_trigger_krb_auth (&empd, NULL);
-
+ e_mapi_util_trigger_krb_auth (&empd, &krb_error);
password = NULL;
} else {
password = camel_service_get_password (service);
@@ -3058,8 +3057,9 @@ mapi_authenticate_sync (CamelService *service,
}
camel_store_summary_array_free (store->summary, array);
- } else if (g_error_matches (mapi_error, E_MAPI_ERROR, MAPI_E_LOGON_FAILED) ||
- g_error_matches (mapi_error, E_MAPI_ERROR, ecRpcFailed)) {
+ } else if (!krb_error && (
+ g_error_matches (mapi_error, E_MAPI_ERROR, MAPI_E_LOGON_FAILED) ||
+ g_error_matches (mapi_error, E_MAPI_ERROR, ecRpcFailed))) {
g_clear_error (&mapi_error);
result = CAMEL_AUTHENTICATION_REJECTED;
} else {
@@ -3067,14 +3067,32 @@ mapi_authenticate_sync (CamelService *service,
g_return_val_if_fail (
mapi_error != NULL,
CAMEL_AUTHENTICATION_ERROR);
- if (!e_mapi_utils_propagate_cancelled_error (mapi_error, error))
- g_propagate_error (error, mapi_error);
- else
+ if (!e_mapi_utils_propagate_cancelled_error (mapi_error, error)) {
+ if (krb_error && mapi_error) {
+ GError *new_error = g_error_new (mapi_error->domain, mapi_error->code,
+ /* Translators: the first '%s' is replaced with a generic error
message,
+ the second '%s' is replaced with additional error information. */
+ C_("gssapi_error", "%s (%s)"), mapi_error->message,
krb_error->message);
+ g_propagate_error (error, new_error);
+ } else if (krb_error) {
+ g_propagate_error (error, krb_error);
+ krb_error = NULL;
+ } else if (mapi_error) {
+ g_propagate_error (error, mapi_error);
+ mapi_error = NULL;
+ }
+
g_clear_error (&mapi_error);
+ g_clear_error (&krb_error);
+ } else {
+ g_clear_error (&mapi_error);
+ }
result = CAMEL_AUTHENTICATION_ERROR;
}
g_rec_mutex_unlock (&store->priv->connection_lock);
+
+ g_clear_error (&krb_error);
g_object_unref (settings);
g_object_unref (session);
diff --git a/src/collection/e-mapi-backend.c b/src/collection/e-mapi-backend.c
index 3621375..937ab08 100644
--- a/src/collection/e-mapi-backend.c
+++ b/src/collection/e-mapi-backend.c
@@ -863,7 +863,7 @@ mapi_backend_authenticate_sync (EBackend *backend,
EMapiConnection *conn;
CamelMapiSettings *settings;
GSList *mapi_folders = NULL;
- GError *mapi_error = NULL;
+ GError *mapi_error = NULL, *krb_error = NULL;
g_return_val_if_fail (E_IS_MAPI_BACKEND (backend), E_SOURCE_AUTHENTICATION_ERROR);
@@ -871,7 +871,7 @@ mapi_backend_authenticate_sync (EBackend *backend,
settings = mapi_backend_get_settings (mapi_backend);
if (camel_mapi_settings_get_kerberos (settings))
- e_mapi_util_trigger_krb_auth_from_settings (settings, NULL);
+ e_mapi_util_trigger_krb_auth_from_settings (settings, &krb_error);
conn = e_mapi_connection_new (NULL,
camel_mapi_settings_get_profile (settings),
@@ -886,10 +886,22 @@ mapi_backend_authenticate_sync (EBackend *backend,
g_error_matches (mapi_error, E_MAPI_ERROR, MAPI_E_PASSWORD_EXPIRED))
res = E_SOURCE_AUTHENTICATION_REJECTED;
- if (res != E_SOURCE_AUTHENTICATION_REJECTED)
+ if (res != E_SOURCE_AUTHENTICATION_REJECTED) {
+ if (krb_error) {
+ GError *new_error = g_error_new (mapi_error->domain, mapi_error->code,
+ /* Translators: the first '%s' is replaced with a generic error
message,
+ the second '%s' is replaced with additional error information. */
+ C_("gssapi_error", "%s (%s)"), mapi_error->message,
krb_error->message);
+ g_clear_error (&mapi_error);
+ mapi_error = new_error;
+ }
+
g_propagate_error (error, mapi_error);
- else
+ } else {
g_clear_error (&mapi_error);
+ }
+
+ g_clear_error (&krb_error);
return res;
}
@@ -924,6 +936,7 @@ mapi_backend_authenticate_sync (EBackend *backend,
g_object_unref (conn);
g_clear_error (&mapi_error);
+ g_clear_error (&krb_error);
return E_SOURCE_AUTHENTICATION_ACCEPTED;
}
diff --git a/src/configuration/e-mail-config-mapi-backend.c b/src/configuration/e-mail-config-mapi-backend.c
index 37dbbaa..39e5a51 100644
--- a/src/configuration/e-mail-config-mapi-backend.c
+++ b/src/configuration/e-mail-config-mapi-backend.c
@@ -379,7 +379,7 @@ validate_credentials_thread (GObject *button,
registry = e_mail_config_service_page_get_registry (page);
if (data->krb_sso) {
- GError *error = NULL;
+ GError *krb_error = NULL, *local_error = NULL;
EMapiProfileData empd = { 0 };
empd.username = data->username;
@@ -389,15 +389,33 @@ validate_credentials_thread (GObject *button,
empd.krb_sso = data->krb_sso;
empd.krb_realm = data->krb_realm;
- e_mapi_util_trigger_krb_auth (&empd, &error);
- g_clear_error (&error);
+ e_mapi_util_trigger_krb_auth (&empd, &krb_error);
data->success = validate_credentials_test (
registry,
&empd,
data->mapi_settings,
cancellable,
- perror);
+ &local_error);
+
+ if (!data->success) {
+ if (krb_error && local_error) {
+ GError *new_error = g_error_new (local_error->domain, local_error->code,
+ /* Translators: the first '%s' is replaced with a generic error
message,
+ the second '%s' is replaced with additional error information. */
+ C_("gssapi_error", "%s (%s)"), local_error->message,
krb_error->message);
+ g_propagate_error (perror, new_error);
+ } else if (krb_error) {
+ g_propagate_error (perror, krb_error);
+ krb_error = NULL;
+ } else if (local_error) {
+ g_propagate_error (perror, local_error);
+ local_error = NULL;
+ }
+ }
+
+ g_clear_error (&krb_error);
+ g_clear_error (&local_error);
} else {
EShell *shell;
ESource *source;
diff --git a/src/configuration/e-mapi-config-utils.c b/src/configuration/e-mapi-config-utils.c
index 8f5636c..342b571 100644
--- a/src/configuration/e-mapi-config-utils.c
+++ b/src/configuration/e-mapi-config-utils.c
@@ -327,10 +327,27 @@ e_mapi_config_utils_open_connection_for (GtkWindow *parent,
while (!conn && !g_cancellable_is_cancelled (cancellable) && !local_error) {
if (empd.krb_sso) {
- e_mapi_util_trigger_krb_auth (&empd, &local_error);
- g_clear_error (&local_error);
+ GError *krb_error = NULL;
+
+ e_mapi_util_trigger_krb_auth (&empd, &krb_error);
conn = e_mapi_connection_new (registry, profile, NULL, cancellable, &local_error);
+
+ if (!conn && krb_error) {
+ if (local_error) {
+ GError *new_error = g_error_new (local_error->domain,
local_error->code,
+ /* Translators: the first '%s' is replaced with a generic
error message,
+ the second '%s' is replaced with additional error
information. */
+ C_("gssapi_error", "%s (%s)"), local_error->message,
krb_error->message);
+ g_clear_error (&local_error);
+ local_error = new_error;
+ } else {
+ local_error = krb_error;
+ krb_error = NULL;
+ }
+ }
+
+ g_clear_error (&krb_error);
} else {
EShell *shell;
TryCredentialsData data;
diff --git a/src/libexchangemapi/e-mapi-utils.c b/src/libexchangemapi/e-mapi-utils.c
index 859dad9..877f252 100644
--- a/src/libexchangemapi/e-mapi-utils.c
+++ b/src/libexchangemapi/e-mapi-utils.c
@@ -24,6 +24,7 @@
#include "evolution-mapi-config.h"
#include <glib.h>
+#include <glib/gi18n-lib.h>
#include <gio/gio.h>
#include <libedataserver/libedataserver.h>
@@ -847,6 +848,17 @@ e_mapi_util_trigger_krb_auth (const EMapiProfileData *empd,
if (local_error) {
g_dbus_error_strip_remote_error (local_error);
+
+ if (g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN)) {
+ GError *new_error = g_error_new (G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN,
+ _("Cannot ask for Kerberos ticket. Obtain the ticket manually, like on
command line with “kinit” or"
+ " open “Online Accounts” in “Settings” and add the Kerberos account there.
Reported error was: %s"),
+ local_error->message);
+
+ g_clear_error (&local_error);
+ local_error = new_error;
+ }
+
g_propagate_error (error, local_error);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]