[gnome-online-accounts/gnome-3-18] imap-smtp: Always return FALSE on failure
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/gnome-3-18] imap-smtp: Always return FALSE on failure
- Date: Tue, 3 May 2016 17:15:00 +0000 (UTC)
commit 5ac12a61ac19802d0052bc65de0712dd5a9a8a7f
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Jan 22 16:07:26 2016 +0100
imap-smtp: Always return FALSE on failure
Bad things will happen if we set the GError to indicate failure, but
don't return FALSE.
We are setting the ret variable on each intermediate step, and if we
failed to look up smtp-password, it will be set to TRUE, which we will
return even if the GError is set. Let's only update the ret variable
when everything is done.
https://bugzilla.gnome.org/show_bug.cgi?id=760991
src/goabackend/goaimapsmtpprovider.c | 43 +++++++++++++++------------------
1 files changed, 20 insertions(+), 23 deletions(-)
---
diff --git a/src/goabackend/goaimapsmtpprovider.c b/src/goabackend/goaimapsmtpprovider.c
index 0359042..92fe097 100644
--- a/src/goabackend/goaimapsmtpprovider.c
+++ b/src/goabackend/goaimapsmtpprovider.c
@@ -1,6 +1,6 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
- * Copyright (C) 2011, 2013, 2014 Red Hat, Inc.
+ * Copyright (C) 2011, 2013, 2014, 2015, 2016 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -368,15 +368,14 @@ ensure_credentials_sync (GoaProvider *provider,
imap_tls_type = get_tls_type_from_object (object, "ImapUseSsl", "ImapUseTls");
imap_auth = goa_imap_auth_login_new (NULL, NULL, imap_username, imap_password);
- ret = goa_mail_client_check_sync (mail_client,
- imap_server,
- imap_tls_type,
- imap_accept_ssl_errors,
- (imap_tls_type == GOA_TLS_TYPE_SSL) ? 993 : 143,
- imap_auth,
- cancellable,
- error);
- if (!ret)
+ if (!goa_mail_client_check_sync (mail_client,
+ imap_server,
+ imap_tls_type,
+ imap_accept_ssl_errors,
+ (imap_tls_type == GOA_TLS_TYPE_SSL) ? 993 : 143,
+ imap_auth,
+ cancellable,
+ error))
{
if (error != NULL)
{
@@ -400,10 +399,7 @@ ensure_credentials_sync (GoaProvider *provider,
/* SMTP */
if (!goa_util_lookup_keyfile_boolean (object, "SmtpUseAuth"))
- {
- ret = TRUE;
- goto smtp_done;
- }
+ goto smtp_done;
if (!g_variant_lookup (credentials, "smtp-password", "s", &smtp_password))
{
@@ -428,15 +424,14 @@ ensure_credentials_sync (GoaProvider *provider,
email_address = goa_util_lookup_keyfile_string (object, "EmailAddress");
goa_utils_parse_email_address (email_address, NULL, &domain);
smtp_auth = goa_smtp_auth_new (NULL, NULL, domain, smtp_username, smtp_password);
- ret = goa_mail_client_check_sync (mail_client,
- smtp_server,
- smtp_tls_type,
- smtp_accept_ssl_errors,
- (smtp_tls_type == GOA_TLS_TYPE_SSL) ? 465 : 587,
- smtp_auth,
- cancellable,
- error);
- if (!ret)
+ if (!goa_mail_client_check_sync (mail_client,
+ smtp_server,
+ smtp_tls_type,
+ smtp_accept_ssl_errors,
+ (smtp_tls_type == GOA_TLS_TYPE_SSL) ? 465 : 587,
+ smtp_auth,
+ cancellable,
+ error))
{
if (error != NULL)
{
@@ -462,6 +457,8 @@ ensure_credentials_sync (GoaProvider *provider,
if (out_expires_in != NULL)
*out_expires_in = 0;
+ ret = TRUE;
+
out:
g_clear_object (&imap_auth);
g_clear_object (&smtp_auth);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]