[Commits] [SCM] claws branch, gtk2, updated. 3.19.1-37-g9c6fc6254
paul at claws-mail.org
paul at claws-mail.org
Tue Feb 21 16:54:33 UTC 2023
The branch, gtk2 has been updated
via 9c6fc6254f4ac316e6416fa49a79be9a40ec0882 (commit)
via aea82d448e3dbdb3516db600d0570815aaaa50dd (commit)
from 867de67c53fc50d648e2c40548539a8c8b4181e4 (commit)
Summary of changes:
AUTHORS | 1 +
src/gtk/authors.h | 1 +
src/oauth2.c | 72 ++++++++++++++++++++++++++++---------------------------
3 files changed, 39 insertions(+), 35 deletions(-)
- Log -----------------------------------------------------------------
commit 9c6fc6254f4ac316e6416fa49a79be9a40ec0882
Author: Paul <paul at claws-mail.org>
Date: Tue Feb 21 16:44:38 2023 +0000
fix bug 4664, 'OAUTH2 overwrites passwords even for plaintext logins'
based on patch by Roland Haas
diff --git a/AUTHORS b/AUTHORS
index 2eb6b0d77..b822e4772 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -344,3 +344,4 @@ contributors (in addition to the above; based on Changelog)
Frank Mueller
JP Guillonneau
Viatrix
+ Roland Haas
diff --git a/src/gtk/authors.h b/src/gtk/authors.h
index 59aef83fb..87000fa66 100644
--- a/src/gtk/authors.h
+++ b/src/gtk/authors.h
@@ -163,6 +163,7 @@ static char *CONTRIBS_LIST[] = {
"Mitko Haralanov",
"Alexander Lyons Harkness",
"Hashimoto",
+"Roland Haas",
"Jacob Head",
"Federico Heinz",
"Geir Helland",
diff --git a/src/oauth2.c b/src/oauth2.c
index 272bda3ff..f9e6ee106 100644
--- a/src/oauth2.c
+++ b/src/oauth2.c
@@ -35,6 +35,7 @@
#include <string.h>
#include <errno.h>
+#include "imap.h"
#include "oauth2.h"
#include "md5.h"
#include "utils.h"
@@ -652,7 +653,9 @@ gint oauth2_check_passwds (PrefsAccount *ac_prefs)
if (ret)
log_message(LOG_PROTOCOL, _("OAuth2 access token not obtained\n"));
else {
- passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_RECV, OAUTH2Data->access_token, FALSE);
+ if (ac_prefs->imap_auth_type == IMAP_AUTH_OAUTH2 ||
+ (ac_prefs->use_pop_auth && ac_prefs->pop_auth_type == POPAUTH_OAUTH2))
+ passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_RECV, OAUTH2Data->access_token, FALSE);
if (ac_prefs->use_smtp_auth && ac_prefs->smtp_auth_type == SMTPAUTH_OAUTH2)
passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_SEND, OAUTH2Data->access_token, FALSE);
passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_OAUTH2_EXPIRY, OAUTH2Data->expiry_str, FALSE);
commit aea82d448e3dbdb3516db600d0570815aaaa50dd
Author: Paul <paul at claws-mail.org>
Date: Tue Feb 21 16:41:18 2023 +0000
code style
diff --git a/src/oauth2.c b/src/oauth2.c
index d65d06ea3..272bda3ff 100644
--- a/src/oauth2.c
+++ b/src/oauth2.c
@@ -1,6 +1,6 @@
/*
- * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2021-2022 the Claws Mail team
+ * Claws Mail -- a GTK based, lightweight, and fast e-mail client
+ * Copyright (C) 2021-2023 the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -625,45 +625,44 @@ gint oauth2_check_passwds (PrefsAccount *ac_prefs)
OAUTH2Data->custom_client_id = ac_prefs->oauth2_client_id;
OAUTH2Data->custom_client_secret = ac_prefs->oauth2_client_secret;
- if(passwd_store_has_password(PWS_ACCOUNT, uid, PWS_ACCOUNT_OAUTH2_EXPIRY)) {
- acc = passwd_store_get_account(ac_prefs->account_id, PWS_ACCOUNT_OAUTH2_EXPIRY);
- expiry = atoi(acc);
- g_free(acc);
- if (expiry > (g_get_real_time () / G_USEC_PER_SEC)){
- g_free(OAUTH2Data);
- log_message(LOG_PROTOCOL, _("OAuth2 access token still fresh\n"));
- g_free(uid);
- return (0);
- }
+ if (passwd_store_has_password(PWS_ACCOUNT, uid, PWS_ACCOUNT_OAUTH2_EXPIRY)) {
+ acc = passwd_store_get_account(ac_prefs->account_id, PWS_ACCOUNT_OAUTH2_EXPIRY);
+ expiry = atoi(acc);
+ g_free(acc);
+ if (expiry > (g_get_real_time () / G_USEC_PER_SEC)) {
+ g_free(OAUTH2Data);
+ log_message(LOG_PROTOCOL, _("OAuth2 access token still fresh\n"));
+ g_free(uid);
+ return (0);
+ }
}
- if(passwd_store_has_password(PWS_ACCOUNT, uid, PWS_ACCOUNT_OAUTH2_REFRESH)) {
- log_message(LOG_PROTOCOL, _("OAuth2 obtaining access token using refresh token\n"));
- OAUTH2Data->refresh_token = passwd_store_get_account(ac_prefs->account_id, PWS_ACCOUNT_OAUTH2_REFRESH);
- ret = oauth2_use_refresh_token (ac_prefs->oauth2_provider, OAUTH2Data);
- }else if (passwd_store_has_password(PWS_ACCOUNT, uid, PWS_ACCOUNT_OAUTH2_AUTH)) {
- log_message(LOG_PROTOCOL, _("OAuth2 trying for fresh access token with authorization code\n"));
- acc = passwd_store_get_account(ac_prefs->account_id, PWS_ACCOUNT_OAUTH2_AUTH);
- ret = oauth2_obtain_tokens (ac_prefs->oauth2_provider, OAUTH2Data, acc);
- g_free(acc);
- }else{
- ret = 1;
- }
+ if (passwd_store_has_password(PWS_ACCOUNT, uid, PWS_ACCOUNT_OAUTH2_REFRESH)) {
+ log_message(LOG_PROTOCOL, _("OAuth2 obtaining access token using refresh token\n"));
+ OAUTH2Data->refresh_token = passwd_store_get_account(ac_prefs->account_id, PWS_ACCOUNT_OAUTH2_REFRESH);
+ ret = oauth2_use_refresh_token (ac_prefs->oauth2_provider, OAUTH2Data);
+ } else if (passwd_store_has_password(PWS_ACCOUNT, uid, PWS_ACCOUNT_OAUTH2_AUTH)) {
+ log_message(LOG_PROTOCOL, _("OAuth2 trying for fresh access token with authorization code\n"));
+ acc = passwd_store_get_account(ac_prefs->account_id, PWS_ACCOUNT_OAUTH2_AUTH);
+ ret = oauth2_obtain_tokens (ac_prefs->oauth2_provider, OAUTH2Data, acc);
+ g_free(acc);
+ } else
+ ret = 1;
- if (ret){
- log_message(LOG_PROTOCOL, _("OAuth2 access token not obtained\n"));
- }else{
- passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_RECV, OAUTH2Data->access_token, FALSE);
- if (ac_prefs->use_smtp_auth && ac_prefs->smtp_auth_type == SMTPAUTH_OAUTH2)
- passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_SEND, OAUTH2Data->access_token, FALSE);
- passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_OAUTH2_EXPIRY, OAUTH2Data->expiry_str, FALSE);
- //Some providers issue replacement refresh tokens with each access token. Re-store whether replaced or not.
- passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_OAUTH2_REFRESH, OAUTH2Data->refresh_token, FALSE);
- log_message(LOG_PROTOCOL, _("OAuth2 access and refresh token updated\n"));
+ if (ret)
+ log_message(LOG_PROTOCOL, _("OAuth2 access token not obtained\n"));
+ else {
+ passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_RECV, OAUTH2Data->access_token, FALSE);
+ if (ac_prefs->use_smtp_auth && ac_prefs->smtp_auth_type == SMTPAUTH_OAUTH2)
+ passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_SEND, OAUTH2Data->access_token, FALSE);
+ passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_OAUTH2_EXPIRY, OAUTH2Data->expiry_str, FALSE);
+ //Some providers issue replacement refresh tokens with each access token. Re-store whether replaced or not.
+ passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_OAUTH2_REFRESH, OAUTH2Data->refresh_token, FALSE);
+ log_message(LOG_PROTOCOL, _("OAuth2 access and refresh token updated\n"));
}
g_free(OAUTH2Data);
- g_free(uid);
+ g_free(uid);
return (ret);
}
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list