Changeset 4006:dc0c95e52a22

Show
Ignore:
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:
5 modified

Legend:

Unmodified
Added
Removed
  • account.c

    r3873 r4006  
    11/* 
    2  * Copyright (C) 2000-3 Brendan Cully <brendan@kublai.com> 
     2 * Copyright (C) 2000-5 Brendan Cully <brendan@kublai.com> 
    33 *  
    44 *     This program is free software; you can redistribute it and/or modify 
     
    2727#include "url.h" 
    2828 
    29 /* mutt_account_match: compare account info (host/port/user) */ 
     29/* mutt_account_match: compare account info (host/port/user/login) */ 
    3030int mutt_account_match (const ACCOUNT* a1, const ACCOUNT* a2) 
    3131{ 
    3232  const char* user = NONULL (Username); 
     33  const char* login = NONULL (Username); 
    3334 
    3435  if (a1->type != a2->type) 
     
    4041 
    4142#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  } 
    4450#endif 
    4551 
     
    127133} 
    128134 
    129 /* mutt_account_getuser: retrieve username into ACCOUNT, if neccessary */ 
     135/* mutt_account_getuser: retrieve username into ACCOUNT, if necessary */ 
    130136int mutt_account_getuser (ACCOUNT* account) 
    131137{ 
     
    157163} 
    158164 
    159 /* mutt_account_getpass: fetch password into ACCOUNT, if neccessary */ 
     165int 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 */ 
    160186int mutt_account_getpass (ACCOUNT* account) 
    161187{ 
     
    175201  { 
    176202    snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "), 
    177       account->user, account->host); 
     203      account->login, account->host); 
    178204    account->pass[0] = '\0'; 
    179205    if (mutt_get_password (prompt, account->pass, sizeof (account->pass))) 
  • account.h

    r3437 r4006  
    11/* 
    2  * Copyright (C) 2000-3 Brendan Cully <brendan@kublai.com> 
     2 * Copyright (C) 2000-5 Brendan Cully <brendan@kublai.com> 
    33 *  
    44 *     This program is free software; you can redistribute it and/or modify 
     
    3333 
    3434/* 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) 
    3940 
    4041typedef struct 
    4142{ 
    4243  char user[64]; 
     44  char login[64]; 
    4345  char pass[64]; 
    4446  char host[128]; 
     
    5254void mutt_account_tourl (ACCOUNT* account, ciss_url_t* url); 
    5355int mutt_account_getuser (ACCOUNT* account); 
     56int mutt_account_getlogin (ACCOUNT* account); 
    5457int mutt_account_getpass (ACCOUNT* account); 
    5558void mutt_account_unsetpass (ACCOUNT* account); 
  • globals.h

    r3909 r4006  
    5858WHERE char *ImapHeaders; 
    5959WHERE char *ImapHomeNamespace INITVAL (NULL); 
     60WHERE char *ImapLogin INITVAL (NULL); 
    6061WHERE char *ImapPass INITVAL (NULL); 
    6162WHERE char *ImapUser INITVAL (NULL); 
  • init.h

    r3995 r4006  
    852852  ** IMAP browser with the \fItoggle-subscribed\fP function. 
    853853  */ 
     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  */ 
    854861  { "imap_pass",        DT_STR,  R_NONE, UL &ImapPass, UL 0 }, 
    855862  /* 
     
    890897  /* 
    891898  ** .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. 
    893901  ** .pp 
    894902  ** This variable defaults to your user name on the local machine. 
  • mutt_sasl.c

    r3957 r4006  
    335335  callback = mutt_sasl_callbacks; 
    336336 
    337   callback->id = SASL_CB_AUTHNAME; 
     337  callback->id = SASL_CB_USER; 
    338338  callback->proc = mutt_sasl_cb_authname; 
    339339  callback->context = account; 
    340340  callback++; 
    341341 
    342   callback->id = SASL_CB_USER; 
     342  callback->id = SASL_CB_AUTHNAME; 
    343343  callback->proc = mutt_sasl_cb_authname; 
    344344  callback->context = account; 
     
    451451} 
    452452 
    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 */ 
    455454static int mutt_sasl_cb_authname (void* context, int id, const char** result, 
    456455  unsigned* len) 
     
    469468              account->host, account->port)); 
    470469 
    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   
    476483  if (len) 
    477484    *len = strlen (*result); 
     
    490497 
    491498  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, 
    493500    account->host, account->port)); 
    494501