diff options
author | Kevin McCarthy <kevin@8t8.us> | 2021-03-05 18:52:48 -0800 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2021-03-08 14:19:06 -0800 |
commit | 191b0513b43d5e603f99292faa5f8ebcc1be3823 (patch) | |
tree | 835573e952f10cc4912cff6b72b518b7f30f3fc1 /account.c | |
parent | fcc6299184208e9a38890979ebb9f1c1356c18eb (diff) |
Fix $ssl_client_cert usage with SMTP.
The ssl and gnutls client-cert setup code was calling
mutt_account_getuser(). This caused two problems. First, it's not
necessarily the case that there will be a username. Second,
populating the user would cause smtp_open() to check for AUTH
capabilities and call smtp_auth - even if the user is already
authenticated by the cert. The server won't advertize AUTH if they
already authenticated, causing a connection abort.
Remove prompt for mutt_account_getuser() in the ssl and gnutls client
certificate connection code. The SASL code has callbacks, so I don't
understand why it would need this. Let's take it out and see if
anyone screams 8-P. If necessary, we can add a mutt_account_getuser()
call to the very beginning of imap_auth_sasl().
Revamp the openssl ssl_passwd_cb() prompt. From the man pages, it
appears to be used for the cert decryption. There's no need to call
mutt_account_getuser() and use the generic mutt_account_getpass() just
to read a password in. Instead create a callback function version to
customize the prompt for a client cert with just the host.
Change the SMTP authentication test to check if the AUTH capabilities
are set, instead of if the user field is set before calling
smtp_auth().
Diffstat (limited to 'account.c')
-rw-r--r-- | account.c | 25 |
1 files changed, 20 insertions, 5 deletions
@@ -198,8 +198,19 @@ int mutt_account_getlogin (ACCOUNT* account) return 0; } -/* mutt_account_getpass: fetch password into ACCOUNT, if necessary */ -int mutt_account_getpass (ACCOUNT* account) +static void getpass_prompt (char *prompt, size_t prompt_size, ACCOUNT *account) +{ + /* L10N: + Prompt for an account password when connecting. + %s@%s is user@host + */ + snprintf (prompt, prompt_size, _("Password for %s@%s: "), + account->flags & MUTT_ACCT_LOGIN ? account->login : account->user, + account->host); +} + +int _mutt_account_getpass (ACCOUNT* account, + void (*prompt_func) (char *, size_t, ACCOUNT *)) { char prompt[SHORT_STRING]; @@ -221,9 +232,7 @@ int mutt_account_getpass (ACCOUNT* account) return -1; else { - snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "), - account->flags & MUTT_ACCT_LOGIN ? account->login : account->user, - account->host); + prompt_func (prompt, sizeof(prompt), account); account->pass[0] = '\0'; if (mutt_get_password (prompt, account->pass, sizeof (account->pass))) return -1; @@ -234,6 +243,12 @@ int mutt_account_getpass (ACCOUNT* account) return 0; } +/* mutt_account_getpass: fetch password into ACCOUNT, if necessary */ +int mutt_account_getpass (ACCOUNT *account) +{ + return _mutt_account_getpass (account, getpass_prompt); +} + void mutt_account_unsetpass (ACCOUNT* account) { account->flags &= ~MUTT_ACCT_PASS; |