From e6a5563beea0c9a38636a48badb87efc923efdda Mon Sep 17 00:00:00 2001 From: Michael Gratton Date: Thu, 21 Feb 2019 12:00:17 +1100 Subject: [PATCH 1/5] Flip the sense of the libunwind build option Updates !109, see also #238 --- meson.build | 8 ++++++-- meson_options.txt | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 0e6d0143..ee4a5f9d 100644 --- a/meson.build +++ b/meson.build @@ -70,8 +70,12 @@ libmath = cc.find_library('m') libnotify = dependency('libnotify', version: '>= 0.7.5') libsecret = dependency('libsecret-1', version: '>= 0.11') libsoup = dependency('libsoup-2.4', version: '>= 2.48') -libunwind_dep = dependency('libunwind', version: '>= 1.1', required: get_option('libunwind')) -libunwind_generic_dep = dependency('libunwind-generic', version: '>= 1.1', required: get_option('libunwind')) +libunwind_dep = dependency( + 'libunwind', version: '>= 1.1', required: not get_option('libunwind_optional') +) +libunwind_generic_dep = dependency( + 'libunwind-generic', version: '>= 1.1', required: not get_option('libunwind_optional') +) libxml = dependency('libxml-2.0', version: '>= 2.7.8') posix = valac.find_library('posix') webkit2gtk_web_extension = dependency('webkit2gtk-web-extension-4.0', version: '>=' + target_webkit) diff --git a/meson_options.txt b/meson_options.txt index 63bbce7e..2bd04e4a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -4,4 +4,4 @@ option('poodle', type: 'boolean', value: true, description: 'Whether to apply th option('ref_tracking', type: 'boolean', value: false, description: 'Whether to use explicit reference tracking.') option('iso_639_xml', type: 'string', value: '', description: 'Full path to the ISO 639 XML file.') option('iso_3166_xml', type: 'string', value: '', description: 'Full path to the ISO 3166 XML file.') -option('libunwind', type: 'boolean', value: true, description: 'Whether to depend on libunwind.') +option('libunwind_optional', type: 'boolean', value: false, description: 'Determines if libunwind is required.') From eb1aa4c31f56975cead6a1f128ea481499f7d8d9 Mon Sep 17 00:00:00 2001 From: Michael Gratton Date: Thu, 21 Feb 2019 14:22:49 +1100 Subject: [PATCH 2/5] Ensure IMAP and SMTP services notify of auth failure if creds incomplete This avoids attemting to connect and login when we know it is going to fail. --- src/engine/imap/api/imap-client-service.vala | 5 +++++ src/engine/smtp/smtp-client-service.vala | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/engine/imap/api/imap-client-service.vala b/src/engine/imap/api/imap-client-service.vala index aa153cbc..398ff8dd 100644 --- a/src/engine/imap/api/imap-client-service.vala +++ b/src/engine/imap/api/imap-client-service.vala @@ -385,6 +385,11 @@ internal class Geary.Imap.ClientService : Geary.ClientService { private async ClientSession create_new_authorized_session(Cancellable? cancellable) throws Error { debug("[%s] Opening new session", this.account.id); + Credentials? login = this.configuration.credentials; + if (login != null && !login.is_complete()) { + notify_authentication_failed(); + } + ClientSession new_session = new ClientSession(remote); yield new_session.connect_async(cancellable); diff --git a/src/engine/smtp/smtp-client-service.vala b/src/engine/smtp/smtp-client-service.vala index bbead2ad..7ce305fd 100644 --- a/src/engine/smtp/smtp-client-service.vala +++ b/src/engine/smtp/smtp-client-service.vala @@ -236,15 +236,17 @@ internal class Geary.Smtp.ClientService : Geary.ClientService { private async void send_email(Geary.RFC822.Message rfc822, Cancellable? cancellable) throws Error { - Smtp.ClientSession smtp = new Geary.Smtp.ClientSession(this.remote); + Credentials? login = this.account.get_outgoing_credentials(); + if (login != null && !login.is_complete()) { + notify_authentication_failed(); + } + Smtp.ClientSession smtp = new Geary.Smtp.ClientSession(this.remote); sending_monitor.notify_start(); Error? smtp_err = null; try { - yield smtp.login_async( - this.account.get_outgoing_credentials(), cancellable - ); + yield smtp.login_async(login, cancellable); } catch (Error login_err) { debug("SMTP login error: %s", login_err.message); smtp_err = login_err; From 7e868dd06bbc7ec3f6dd9cfb66296c20d1087b48 Mon Sep 17 00:00:00 2001 From: Michael Gratton Date: Thu, 21 Feb 2019 14:26:51 +1100 Subject: [PATCH 3/5] Minor API doc update --- src/engine/api/geary-credentials.vala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/api/geary-credentials.vala b/src/engine/api/geary-credentials.vala index e1b58cf9..f44ad146 100644 --- a/src/engine/api/geary-credentials.vala +++ b/src/engine/api/geary-credentials.vala @@ -107,6 +107,7 @@ public class Geary.Credentials : BaseObject, Gee.Hashable { this.token = token; } + /** Determines if a token has been provided. */ public bool is_complete() { return this.token != null; } From f59fdd050a6b2b7c08208bbf22649fb21b09a06b Mon Sep 17 00:00:00 2001 From: Michael Gratton Date: Thu, 21 Feb 2019 14:27:16 +1100 Subject: [PATCH 4/5] Ensure AccountInformation load credentials methods always (re)load them This prevents exising-but-expired tokens preventing new tokens from being loaded. Fixes #249 for GOA accounts --- src/engine/api/geary-account-information.vala | 31 +++++-------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/src/engine/api/geary-account-information.vala b/src/engine/api/geary-account-information.vala index 4efeab59..c0d0c74e 100644 --- a/src/engine/api/geary-account-information.vala +++ b/src/engine/api/geary-account-information.vala @@ -470,21 +470,12 @@ public class Geary.AccountInformation : BaseObject { * been previously loaded, or false the credentials could not be * loaded and the service's credentials are invalid. */ - public async bool load_outgoing_credentials(GLib.Cancellable? cancellable) + public async void load_outgoing_credentials(GLib.Cancellable? cancellable) throws GLib.Error { - Credentials? creds = get_outgoing_credentials(); - bool loaded = (creds == null || creds.is_complete()); - if (!loaded && creds != null) { - ServiceInformation service = this.outgoing; - if (this.outgoing.credentials_requirement == - Credentials.Requirement.USE_INCOMING) { - service = this.incoming; - } - loaded = yield this.mediator.load_token( - this, service, cancellable - ); + Credentials? creds = this.outgoing.credentials; + if (creds != null) { + yield this.mediator.load_token(this, this.outgoing, cancellable); } - return loaded; } /** @@ -493,21 +484,13 @@ public class Geary.AccountInformation : BaseObject { * Credentials are loaded from the mediator, which may cause the * user to be prompted for the secret, thus it may yield for some * time. - * - * Returns true if the credentials were successfully loaded or had - * been previously loaded, or false the credentials could not be - * loaded and the service's credentials are invalid. */ - public async bool load_incoming_credentials(GLib.Cancellable? cancellable) + public async void load_incoming_credentials(GLib.Cancellable? cancellable) throws GLib.Error { Credentials? creds = this.incoming.credentials; - bool loaded = creds.is_complete(); - if (!loaded) { - loaded = yield this.mediator.load_token( - this, this.incoming, cancellable - ); + if (creds != null) { + yield this.mediator.load_token(this, this.incoming, cancellable); } - return loaded; } public bool equal_to(AccountInformation other) { From c552633adb3db70e04e680071eae28e72d7ededf Mon Sep 17 00:00:00 2001 From: Michael Gratton Date: Thu, 21 Feb 2019 14:28:31 +1100 Subject: [PATCH 5/5] Prompt when loading a libsecret token but it could not be found Fixes #249 for local accounts. --- src/client/application/secret-mediator.vala | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/client/application/secret-mediator.vala b/src/client/application/secret-mediator.vala index 85264ef5..2d541b96 100644 --- a/src/client/application/secret-mediator.vala +++ b/src/client/application/secret-mediator.vala @@ -64,17 +64,13 @@ public class SecretMediator : Geary.CredentialsMediator, Object { service.credentials = service.credentials.copy_with_token(password); loaded = true; - } else { - debug( - "Unable to fetch libsecret password for %s: %s %s", - account.id, - to_proto_value(service.protocol), - service.credentials.user - ); } - } else { + } + + if (!loaded) { loaded = yield prompt_token(account, service, cancellable); } + return loaded; }