Changeset 4006:dc0c95e52a22
- Timestamp:
- 2005-06-28 12:26:54 (4 years ago)
- Author:
- Brendan Cully <brendan@…>
- Branch:
- HEAD
- Message:
-
Add $imap_login variable to specify which user to authenticate as
($imap_user controls which user's mail gets accessed). Currently
this can't be specified interactively, since I can't think of a way
to do it that wouldn't annoy users where login == user (the default
value of $imap_login).
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r3873
|
r4006
|
|
| 1 | 1 | /* |
| 2 | | * Copyright (C) 2000-3 Brendan Cully <brendan@kublai.com> |
| | 2 | * Copyright (C) 2000-5 Brendan Cully <brendan@kublai.com> |
| 3 | 3 | * |
| 4 | 4 | * This program is free software; you can redistribute it and/or modify |
| … |
… |
|
| 27 | 27 | #include "url.h" |
| 28 | 28 | |
| 29 | | /* mutt_account_match: compare account info (host/port/user) */ |
| | 29 | /* mutt_account_match: compare account info (host/port/user/login) */ |
| 30 | 30 | int mutt_account_match (const ACCOUNT* a1, const ACCOUNT* a2) |
| 31 | 31 | { |
| 32 | 32 | const char* user = NONULL (Username); |
| | 33 | const char* login = NONULL (Username); |
| 33 | 34 | |
| 34 | 35 | if (a1->type != a2->type) |
| … |
… |
|
| 40 | 41 | |
| 41 | 42 | #ifdef USE_IMAP |
| 42 | | if (a1->type == M_ACCT_TYPE_IMAP && ImapUser) |
| 43 | | user = ImapUser; |
| | 43 | if (a1->type == M_ACCT_TYPE_IMAP) |
| | 44 | { |
| | 45 | if (ImapUser) |
| | 46 | user = ImapUser; |
| | 47 | if (ImapLogin) |
| | 48 | login = ImapLogin; |
| | 49 | } |
| 44 | 50 | #endif |
| 45 | 51 | |
| … |
… |
|
| 127 | 133 | } |
| 128 | 134 | |
| 129 | | /* mutt_account_getuser: retrieve username into ACCOUNT, if neccessary */ |
| | 135 | /* mutt_account_getuser: retrieve username into ACCOUNT, if necessary */ |
| 130 | 136 | int mutt_account_getuser (ACCOUNT* account) |
| 131 | 137 | { |
| … |
… |
|
| 157 | 163 | } |
| 158 | 164 | |
| 159 | | /* mutt_account_getpass: fetch password into ACCOUNT, if neccessary */ |
| | 165 | int mutt_account_getlogin (ACCOUNT* account) |
| | 166 | { |
| | 167 | /* already set */ |
| | 168 | if (account->flags & M_ACCT_LOGIN) |
| | 169 | return 0; |
| | 170 | #ifdef USE_IMAP |
| | 171 | else if (account->type == M_ACCT_TYPE_IMAP) |
| | 172 | { |
| | 173 | if (ImapLogin) |
| | 174 | strfcpy (account->login, ImapLogin, sizeof (account->login)); |
| | 175 | else |
| | 176 | strfcpy (account->login, ImapUser, sizeof (account->login)); |
| | 177 | } |
| | 178 | #endif |
| | 179 | |
| | 180 | account->flags |= M_ACCT_LOGIN; |
| | 181 | |
| | 182 | return 0; |
| | 183 | } |
| | 184 | |
| | 185 | /* mutt_account_getpass: fetch password into ACCOUNT, if necessary */ |
| 160 | 186 | int mutt_account_getpass (ACCOUNT* account) |
| 161 | 187 | { |
| … |
… |
|
| 175 | 201 | { |
| 176 | 202 | snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "), |
| 177 | | account->user, account->host); |
| | 203 | account->login, account->host); |
| 178 | 204 | account->pass[0] = '\0'; |
| 179 | 205 | if (mutt_get_password (prompt, account->pass, sizeof (account->pass))) |
-
|
r3437
|
r4006
|
|
| 1 | 1 | /* |
| 2 | | * Copyright (C) 2000-3 Brendan Cully <brendan@kublai.com> |
| | 2 | * Copyright (C) 2000-5 Brendan Cully <brendan@kublai.com> |
| 3 | 3 | * |
| 4 | 4 | * This program is free software; you can redistribute it and/or modify |
| … |
… |
|
| 33 | 33 | |
| 34 | 34 | /* account flags */ |
| 35 | | #define M_ACCT_PORT (1<<0) |
| 36 | | #define M_ACCT_USER (1<<1) |
| 37 | | #define M_ACCT_PASS (1<<2) |
| 38 | | #define M_ACCT_SSL (1<<3) |
| | 35 | #define M_ACCT_PORT (1<<0) |
| | 36 | #define M_ACCT_USER (1<<1) |
| | 37 | #define M_ACCT_LOGIN (1<<2) |
| | 38 | #define M_ACCT_PASS (1<<3) |
| | 39 | #define M_ACCT_SSL (1<<4) |
| 39 | 40 | |
| 40 | 41 | typedef struct |
| 41 | 42 | { |
| 42 | 43 | char user[64]; |
| | 44 | char login[64]; |
| 43 | 45 | char pass[64]; |
| 44 | 46 | char host[128]; |
| … |
… |
|
| 52 | 54 | void mutt_account_tourl (ACCOUNT* account, ciss_url_t* url); |
| 53 | 55 | int mutt_account_getuser (ACCOUNT* account); |
| | 56 | int mutt_account_getlogin (ACCOUNT* account); |
| 54 | 57 | int mutt_account_getpass (ACCOUNT* account); |
| 55 | 58 | void mutt_account_unsetpass (ACCOUNT* account); |
-
|
r3909
|
r4006
|
|
| 58 | 58 | WHERE char *ImapHeaders; |
| 59 | 59 | WHERE char *ImapHomeNamespace INITVAL (NULL); |
| | 60 | WHERE char *ImapLogin INITVAL (NULL); |
| 60 | 61 | WHERE char *ImapPass INITVAL (NULL); |
| 61 | 62 | WHERE char *ImapUser INITVAL (NULL); |
-
|
r3995
|
r4006
|
|
| 852 | 852 | ** IMAP browser with the \fItoggle-subscribed\fP function. |
| 853 | 853 | */ |
| | 854 | { "imap_login", DT_STR, R_NONE, UL &ImapLogin, UL 0 }, |
| | 855 | /* |
| | 856 | ** .pp |
| | 857 | ** Your login name on the IMAP server. |
| | 858 | ** .pp |
| | 859 | ** This variable defaults to the value of \fIimap_user\fP. |
| | 860 | */ |
| 854 | 861 | { "imap_pass", DT_STR, R_NONE, UL &ImapPass, UL 0 }, |
| 855 | 862 | /* |
| … |
… |
|
| 890 | 897 | /* |
| 891 | 898 | ** .pp |
| 892 | | ** Your login name on the IMAP server. |
| | 899 | ** The name of the user whose mail you intend to access on the IMAP |
| | 900 | ** server. |
| 893 | 901 | ** .pp |
| 894 | 902 | ** This variable defaults to your user name on the local machine. |
-
|
r3957
|
r4006
|
|
| 335 | 335 | callback = mutt_sasl_callbacks; |
| 336 | 336 | |
| 337 | | callback->id = SASL_CB_AUTHNAME; |
| | 337 | callback->id = SASL_CB_USER; |
| 338 | 338 | callback->proc = mutt_sasl_cb_authname; |
| 339 | 339 | callback->context = account; |
| 340 | 340 | callback++; |
| 341 | 341 | |
| 342 | | callback->id = SASL_CB_USER; |
| | 342 | callback->id = SASL_CB_AUTHNAME; |
| 343 | 343 | callback->proc = mutt_sasl_cb_authname; |
| 344 | 344 | callback->context = account; |
| … |
… |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | | /* mutt_sasl_cb_authname: callback to retrieve authname or user (mutt |
| 454 | | * doesn't distinguish, even if some SASL plugins do) from ACCOUNT */ |
| | 453 | /* mutt_sasl_cb_authname: callback to retrieve authname or user from ACCOUNT */ |
| 455 | 454 | static int mutt_sasl_cb_authname (void* context, int id, const char** result, |
| 456 | 455 | unsigned* len) |
| … |
… |
|
| 469 | 468 | account->host, account->port)); |
| 470 | 469 | |
| 471 | | if (mutt_account_getuser (account)) |
| 472 | | return SASL_FAIL; |
| 473 | | |
| 474 | | *result = account->user; |
| 475 | | |
| | 470 | if (id == SASL_CB_AUTHNAME) |
| | 471 | { |
| | 472 | if (mutt_account_getlogin (account)) |
| | 473 | return SASL_FAIL; |
| | 474 | *result = account->login; |
| | 475 | } |
| | 476 | else |
| | 477 | { |
| | 478 | if (mutt_account_getuser (account)) |
| | 479 | return SASL_FAIL; |
| | 480 | *result = account->user; |
| | 481 | } |
| | 482 | |
| 476 | 483 | if (len) |
| 477 | 484 | *len = strlen (*result); |
| … |
… |
|
| 490 | 497 | |
| 491 | 498 | dprint (2, (debugfile, |
| 492 | | "mutt_sasl_cb_pass: getting password for %s@%s:%u\n", account->user, |
| | 499 | "mutt_sasl_cb_pass: getting password for %s@%s:%u\n", account->login, |
| 493 | 500 | account->host, account->port)); |
| 494 | 501 | |