talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit d1d9ffd6c37e25c6e25bfb59571591824122b91e
parent 94019c056e89cdb1b2aeb6b8e1f502e6e95b6211
Author: Paul <paul@claws-mail.org>
Date:   Sun, 24 Jul 2022 11:29:46 +0100

make oauth2 depend on gnutls at build time, but add --disable-oauth2 so the interface can be decluttered for those that will never need oauth2

Diffstat:
Mconfigure.ac | 20++++++++++++++++++++
Msrc/common/smtp.c | 6++++--
Msrc/etpan/imap-thread.c | 2+-
Msrc/gtk/about.c | 10++++++++++
Msrc/imap.c | 4++--
Msrc/inc.c | 4++--
Msrc/oauth2.c | 2+-
Msrc/oauth2.h | 2+-
Msrc/pop.c | 13+++++++++----
Msrc/prefs_account.c | 46+++++++++++++++++++++++++---------------------
Msrc/send_message.c | 7++++---
11 files changed, 79 insertions(+), 37 deletions(-)

diff --git a/configure.ac b/configure.ac @@ -277,6 +277,10 @@ AC_ARG_ENABLE(gnutls, [ --disable-gnutls Do not build GnuTLS support for TLS], [enable_gnutls=$enableval], [enable_gnutls=yes]) +AC_ARG_ENABLE(oauth2, + [ --disable-oauth2 Do not build OAuth2 support], + [enable_oauth2=$enableval], [enable_oauth2=yes]) + AC_ARG_ENABLE(enchant, [ --disable-enchant Do not build Enchant support for spell-checking], [enable_enchant=$enableval], [enable_enchant=yes]) @@ -589,6 +593,21 @@ case $pwd_crypto in ;; esac +AC_MSG_CHECKING([whether GnuTLS support is present for OAuth2]) +if test x"$enable_gnutls" = xyes; then + AC_MSG_RESULT([yes]) + AC_MSG_CHECKING([whether to build oauth2 support]) + if test x"$enable_oauth2" = xyes; then + AC_MSG_RESULT([yes]) + AC_DEFINE(USE_OAUTH2, 1, [Define if OAuth2 is to be activated.]) + else + AC_MSG_RESULT([no]) + enable_oauth2=no + fi +else + AC_MSG_RESULT([no]) + enable_oauth2=no +fi dnl ************************ dnl ** GTK user interface ** @@ -2218,6 +2237,7 @@ else echo "LDAP : $enable_ldap" fi echo "gnuTLS : $enable_gnutls" +echo "OAuth2 : $enable_oauth2" echo "iconv : $am_cv_func_iconv" echo "compface : $enable_compface" echo "IPv6 : $enable_ipv6" diff --git a/src/common/smtp.c b/src/common/smtp.c @@ -42,6 +42,8 @@ static void smtp_session_destroy(Session *session); static gint smtp_auth(SMTPSession *session); #ifdef USE_GNUTLS static gint smtp_starttls(SMTPSession *session); +#endif +#ifdef USE_OAUTH2 static gint smtp_auth_oauth2(SMTPSession *session); #endif static gint smtp_auth_cram_md5(SMTPSession *session); @@ -176,7 +178,7 @@ static gint smtp_auth(SMTPSession *session) && (session->avail_auth_type & SMTPAUTH_PLAIN) != 0) smtp_auth_plain(session); -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 else if ((session->forced_auth_type == SMTPAUTH_OAUTH2 || session->forced_auth_type == 0) && @@ -403,7 +405,7 @@ static gint smtp_auth_plain(SMTPSession *session) return SM_OK; } -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 static gint smtp_auth_oauth2(SMTPSession *session) { gchar buf[MESSAGEBUFSIZE], *b64buf, *out; diff --git a/src/etpan/imap-thread.c b/src/etpan/imap-thread.c @@ -1001,7 +1001,7 @@ static void login_run(struct etpan_thread_op * op) param->type, NULL, NULL, NULL, NULL, param->login, param->password, NULL); -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 else if (!strcmp(param->type, "XOAUTH2")) r = mailimap_oauth2_authenticate(param->imap, param->login, param->password); #endif diff --git a/src/gtk/about.c b/src/gtk/about.c @@ -452,6 +452,16 @@ static GtkWidget *about_create_child_page_features(void) gtk_text_buffer_insert(buffer, &iter, (gchar *)C_("GnuTLS", "adds support for encrypted connections to servers\n"), -1); +#if USE_OAUTH2 + gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf); +#else + gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf); +#endif + gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" OAuth2 "), -1, + "bold", NULL); + gtk_text_buffer_insert(buffer, &iter, + (gchar *)C_("OAuth2", "adds support for OAuth2 authentication\n"), -1); + #if INET6 gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf); #else diff --git a/src/imap.c b/src/imap.c @@ -72,7 +72,7 @@ #include "main.h" #include "passwordstore.h" #include "file-utils.h" -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 #include "oauth2.h" #endif @@ -1330,7 +1330,7 @@ static gint imap_session_authenticate(IMAPSession *session, gboolean failed = FALSE; gint ok = MAILIMAP_NO_ERROR; g_return_val_if_fail(account->userid != NULL, MAILIMAP_ERROR_BAD_STATE); -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 if(account->imap_auth_type == IMAP_AUTH_OAUTH2) oauth2_check_passwds (account); #endif diff --git a/src/inc.c b/src/inc.c @@ -61,7 +61,7 @@ #include "hooks.h" #include "logwindow.h" #include "passwordstore.h" -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 #include "oauth2.h" #endif @@ -635,7 +635,7 @@ static gint inc_start(IncProgressDialog *inc_dialog) manage_window_focus_in (inc_dialog->dialog->window, NULL, NULL); -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 if(pop3_session->ac_prefs->use_pop_auth && pop3_session->ac_prefs->pop_auth_type == POPAUTH_OAUTH2) oauth2_check_passwds (pop3_session->ac_prefs); diff --git a/src/oauth2.c b/src/oauth2.c @@ -22,7 +22,7 @@ #include "claws-features.h" #endif -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 #include <glib.h> #ifdef ENABLE_NLS diff --git a/src/oauth2.h b/src/oauth2.h @@ -21,7 +21,7 @@ #include "claws-features.h" #endif -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 #include <glib.h> diff --git a/src/pop.c b/src/pop.c @@ -178,7 +178,7 @@ static gint pop3_getauth_apop_send(Pop3Session *session) return PS_SUCCESS; } -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 static gint pop3_getauth_oauth2_send(Pop3Session *session) { gchar buf[MESSAGEBUFSIZE], *b64buf, *out; @@ -535,7 +535,7 @@ static void pop3_gen_send(Pop3Session *session, const gchar *format, ...) if (!g_ascii_strncasecmp(buf, "PASS ", 5)) log_print(LOG_PROTOCOL, "POP> PASS ********\n"); -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 else if (!g_ascii_strncasecmp(buf, "AUTH XOAUTH2 ", 13)) log_print(LOG_PROTOCOL, "POP> AUTH XOAUTH2 ********\n"); #endif @@ -993,7 +993,10 @@ static gint pop3_session_recv_msg(Session *session, const gchar *msg) #ifdef USE_GNUTLS if (pop3_session->ac_prefs->ssl_pop == SSL_STARTTLS) val = pop3_stls_send(pop3_session); - else if (pop3_session->ac_prefs->use_pop_auth && pop3_session->ac_prefs->pop_auth_type == POPAUTH_OAUTH2) + else +#endif +#ifdef USE_OAUTH2 + if (pop3_session->ac_prefs->use_pop_auth && pop3_session->ac_prefs->pop_auth_type == POPAUTH_OAUTH2) val = pop3_getauth_oauth2_send(pop3_session); else #endif @@ -1008,8 +1011,10 @@ static gint pop3_session_recv_msg(Session *session, const gchar *msg) return -1; if (pop3_session->ac_prefs->use_pop_auth && pop3_session->ac_prefs->pop_auth_type == POPAUTH_APOP) val = pop3_getauth_apop_send(pop3_session); +#ifdef USE_OAUTH2 else if (pop3_session->ac_prefs->use_pop_auth && pop3_session->ac_prefs->pop_auth_type == POPAUTH_OAUTH2) val = pop3_getauth_oauth2_send(pop3_session); +#endif else val = pop3_getauth_user_send(pop3_session); break; @@ -1019,7 +1024,7 @@ static gint pop3_session_recv_msg(Session *session, const gchar *msg) break; case POP3_GETAUTH_PASS: case POP3_GETAUTH_APOP: -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 case POP3_GETAUTH_OAUTH2: #endif if (!pop3_session->pop_before_smtp) diff --git a/src/prefs_account.c b/src/prefs_account.c @@ -61,7 +61,7 @@ #include "smtp.h" #include "imap.h" #include "pop.h" -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 #include "oauth2.h" #endif #include "remotefolder.h" @@ -104,7 +104,7 @@ struct AutocheckWidgets { static GSList *prefs_pages = NULL; -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 static GTask *oauth2_listener_task; static int oauth2_listener_cancel = 0; static int oauth2_listener_closed = 0; @@ -215,7 +215,7 @@ typedef struct SendPage GtkWidget *pop_auth_minutes_lbl; } SendPage; -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 typedef struct Oauth2Page { PrefsPage page; @@ -389,7 +389,7 @@ typedef struct AdvancedPage static BasicPage basic_page; static ReceivePage receive_page; static SendPage send_page; -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 static Oauth2Page oauth2_page; #endif static ComposePage compose_page; @@ -417,7 +417,7 @@ static char *protocol_names[] = { N_("None (SMTP only)") }; -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 struct Oauth2Listener { int success; Oauth2Service service; @@ -439,7 +439,7 @@ static void prefs_account_smtp_auth_type_set_data_from_optmenu (PrefParam *ppara static void prefs_account_smtp_auth_type_set_optmenu (PrefParam *pparam); static void prefs_account_pop_auth_type_set_data_from_optmenu (PrefParam *pparam); static void prefs_account_pop_auth_type_set_optmenu (PrefParam *pparam); -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 static void prefs_account_oauth2_provider_set_data_from_optmenu (PrefParam *pparam); static void prefs_account_oauth2_provider_set_optmenu (PrefParam *pparam); static void prefs_account_oauth2_copy_url (GtkButton *button, gpointer data); @@ -670,7 +670,7 @@ static PrefParam send_param[] = { }; static PrefParam oauth2_param[] = { -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 {"oauth2_auth_provider", "0", &tmp_ac_prefs.oauth2_provider, P_ENUM, &oauth2_page.oauth2_auth_optmenu, prefs_account_oauth2_provider_set_data_from_optmenu, @@ -1650,9 +1650,11 @@ static void receive_create_widget_func(PrefsPage * _page, COMBOBOX_ADD (menu2, _("Select"), 0); COMBOBOX_ADD (menu2, NULL, 0); COMBOBOX_ADD (menu2, "APOP", POPAUTH_APOP); -#ifdef USE_GNUTLS COMBOBOX_ADD (menu2, "OAuth2", POPAUTH_OAUTH2); +#ifndef USE_OAUTH2 + gtk_list_store_set(menu2, &iter, COMBOBOX_SENS, FALSE, -1); #endif + SET_TOGGLE_SENSITIVITY (pop_auth_checkbtn, vbox5); PACK_CHECK_BUTTON (vbox2, rmmail_checkbtn, @@ -1789,8 +1791,9 @@ static void receive_create_widget_func(PrefsPage * _page, COMBOBOX_ADD (menu, "SCRAM-SHA-1", IMAP_AUTH_SCRAM_SHA1); COMBOBOX_ADD (menu, "PLAIN", IMAP_AUTH_PLAIN); COMBOBOX_ADD (menu, "LOGIN", IMAP_AUTH_LOGIN); -#ifdef USE_GNUTLS COMBOBOX_ADD (menu, "OAUTH2", IMAP_AUTH_OAUTH2); +#ifndef USE_OAUTH2 + gtk_list_store_set(menu, &iter, COMBOBOX_SENS, FALSE, -1); #endif hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8); @@ -2048,8 +2051,9 @@ static void send_create_widget_func(PrefsPage * _page, COMBOBOX_ADD (menu, "PLAIN", SMTPAUTH_PLAIN); COMBOBOX_ADD (menu, "LOGIN", SMTPAUTH_LOGIN); COMBOBOX_ADD (menu, "CRAM-MD5", SMTPAUTH_CRAM_MD5); -#ifdef USE_GNUTLS COMBOBOX_ADD (menu, "OAUTH2", SMTPAUTH_OAUTH2); +#ifndef USE_OAUTH2 + gtk_list_store_set(menu, &iter, COMBOBOX_SENS, FALSE, -1); #endif COMBOBOX_ADD (menu, "DIGEST-MD5", SMTPAUTH_DIGEST_MD5); gtk_list_store_set(menu, &iter, COMBOBOX_SENS, FALSE, -1); @@ -2196,7 +2200,7 @@ static void send_create_widget_func(PrefsPage * _page, page->page.widget = vbox1; } -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 static void oauth2_create_widget_func(PrefsPage * _page, GtkWindow * window, gpointer data) @@ -3645,7 +3649,7 @@ static gint prefs_basic_apply(void) gtk_entry_get_text(GTK_ENTRY(basic_page.pass_entry)), FALSE); -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 /* Manual password change - reset expiry on OAUTH2 tokens*/ passwd_store_set_account(tmp_ac_prefs.account_id, PWS_ACCOUNT_OAUTH2_EXPIRY, "0", FALSE); #endif @@ -3691,7 +3695,7 @@ static gint prefs_send_apply(void) PWS_ACCOUNT_SEND, gtk_entry_get_text(GTK_ENTRY(send_page.smtp_pass_entry)), FALSE); -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 /* Manual password change - reset expiry on OAUTH2 tokens*/ passwd_store_set_account(tmp_ac_prefs.account_id, PWS_ACCOUNT_OAUTH2_EXPIRY, "0", FALSE); #endif @@ -3699,7 +3703,7 @@ static gint prefs_send_apply(void) return 0; } -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 static gint prefs_oauth2_apply(void) { prefs_set_data_from_dialog(oauth2_param); @@ -3811,7 +3815,7 @@ static void send_destroy_widget_func(PrefsPage *_page) /* SendPage *page = (SendPage *) _page; */ } -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 static void oauth2_destroy_widget_func(PrefsPage *_page) { /* Oauth2Page *page = (Oauth2Page *) _page; */ @@ -3885,7 +3889,7 @@ static gboolean send_can_close_func(PrefsPage *_page) return prefs_send_apply() >= 0; } -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 static gboolean oauth2_can_close_func(PrefsPage *_page) { Oauth2Page *page = (Oauth2Page *) _page; @@ -3992,7 +3996,7 @@ static void send_save_func(PrefsPage *_page) cancelled = FALSE; } -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 static void oauth2_save_func(PrefsPage *_page) { Oauth2Page *page = (Oauth2Page *) _page; @@ -4139,7 +4143,7 @@ static void register_send_page(void) prefs_account_register_page((PrefsPage *) &send_page); } -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 static void register_oauth2_page(void) { static gchar *path[3]; @@ -4347,7 +4351,7 @@ void prefs_account_init() hooks_register_hook(SSL_CERT_GET_PASSWORD, sslcert_get_password, NULL); #endif register_proxy_page(); -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 register_oauth2_page(); #endif register_advanced_page(); @@ -5096,7 +5100,7 @@ static void prefs_account_pop_auth_type_set_optmenu(PrefParam *pparam) combobox_select_by_data(optmenu, type); } -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 static void prefs_account_oauth2_provider_set_data_from_optmenu(PrefParam *pparam) { *((Oauth2Service *)pparam->data) = @@ -6050,7 +6054,7 @@ static void prefs_account_receive_itv_spinbutton_value_changed_cb(GtkWidget *w, } } -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 //Automation of the oauth2 authorisation process to receive loopback callback generated by redirect in browser static void prefs_account_oauth2_listener(GTask *task, gpointer source, gpointer task_data, GCancellable *cancellable) { diff --git a/src/send_message.c b/src/send_message.c @@ -57,7 +57,7 @@ #include "log.h" #include "passwordstore.h" #include "file-utils.h" -#ifdef USE_GNUTLS +#ifdef USE_OAUTH2 #include "oauth2.h" #endif @@ -284,9 +284,10 @@ gint send_message_smtp_full(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp, g strlen(ac_prefs->gnutls_priority)) session->gnutls_priority = g_strdup(ac_prefs->gnutls_priority); session->use_tls_sni = ac_prefs->use_tls_sni; - +#ifdef USE_OAUTH2 if (ac_prefs->use_smtp_auth && ac_prefs->smtp_auth_type == SMTPAUTH_OAUTH2) - oauth2_check_passwds (ac_prefs); + oauth2_check_passwds(ac_prefs); +#endif #else if (ac_prefs->ssl_smtp != SSL_NONE) { if (alertpanel_full(_("Insecure connection"),