/*
- * Copyright (C) 2000-3 Brendan Cully <brendan@kublai.com>
+ * Copyright (C) 2000-5 Brendan Cully <brendan@kublai.com>
*
* 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
#include "account.h"
#include "url.h"
-/* mutt_account_match: compare account info (host/port/user) */
+/* mutt_account_match: compare account info (host/port/user/login) */
int mutt_account_match (const ACCOUNT* a1, const ACCOUNT* a2)
{
const char* user = NONULL (Username);
+ const char* login = NONULL (Username);
if (a1->type != a2->type)
return 0;
return 0;
#ifdef USE_IMAP
- if (a1->type == M_ACCT_TYPE_IMAP && ImapUser)
- user = ImapUser;
+ if (a1->type == M_ACCT_TYPE_IMAP)
+ {
+ if (ImapUser)
+ user = ImapUser;
+ if (ImapLogin)
+ login = ImapLogin;
+ }
#endif
#ifdef USE_POP
url->pass = account->pass;
}
-/* mutt_account_getuser: retrieve username into ACCOUNT, if neccessary */
+/* mutt_account_getuser: retrieve username into ACCOUNT, if necessary */
int mutt_account_getuser (ACCOUNT* account)
{
char prompt[SHORT_STRING];
return 0;
}
-/* mutt_account_getpass: fetch password into ACCOUNT, if neccessary */
+int mutt_account_getlogin (ACCOUNT* account)
+{
+ /* already set */
+ if (account->flags & M_ACCT_LOGIN)
+ return 0;
+#ifdef USE_IMAP
+ else if (account->type == M_ACCT_TYPE_IMAP)
+ {
+ if (ImapLogin)
+ strfcpy (account->login, ImapLogin, sizeof (account->login));
+ else
+ strfcpy (account->login, ImapUser, sizeof (account->login));
+ }
+#endif
+
+ account->flags |= M_ACCT_LOGIN;
+
+ return 0;
+}
+
+/* mutt_account_getpass: fetch password into ACCOUNT, if necessary */
int mutt_account_getpass (ACCOUNT* account)
{
char prompt[SHORT_STRING];
else
{
snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "),
- account->user, account->host);
+ account->login, account->host);
account->pass[0] = '\0';
if (mutt_get_password (prompt, account->pass, sizeof (account->pass)))
return -1;
/*
- * Copyright (C) 2000-3 Brendan Cully <brendan@kublai.com>
+ * Copyright (C) 2000-5 Brendan Cully <brendan@kublai.com>
*
* 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
};
/* account flags */
-#define M_ACCT_PORT (1<<0)
-#define M_ACCT_USER (1<<1)
-#define M_ACCT_PASS (1<<2)
-#define M_ACCT_SSL (1<<3)
+#define M_ACCT_PORT (1<<0)
+#define M_ACCT_USER (1<<1)
+#define M_ACCT_LOGIN (1<<2)
+#define M_ACCT_PASS (1<<3)
+#define M_ACCT_SSL (1<<4)
typedef struct
{
char user[64];
+ char login[64];
char pass[64];
char host[128];
unsigned short port;
int mutt_account_fromurl (ACCOUNT* account, ciss_url_t* url);
void mutt_account_tourl (ACCOUNT* account, ciss_url_t* url);
int mutt_account_getuser (ACCOUNT* account);
+int mutt_account_getlogin (ACCOUNT* account);
int mutt_account_getpass (ACCOUNT* account);
void mutt_account_unsetpass (ACCOUNT* account);
WHERE char *ImapDelimChars INITVAL (NULL);
WHERE char *ImapHeaders;
WHERE char *ImapHomeNamespace INITVAL (NULL);
+WHERE char *ImapLogin INITVAL (NULL);
WHERE char *ImapPass INITVAL (NULL);
WHERE char *ImapUser INITVAL (NULL);
#endif
** only subscribed folders or all folders. This can be toggled in the
** IMAP browser with the \fItoggle-subscribed\fP function.
*/
+ { "imap_login", DT_STR, R_NONE, UL &ImapLogin, UL 0 },
+ /*
+ ** .pp
+ ** Your login name on the IMAP server.
+ ** .pp
+ ** This variable defaults to the value of \fIimap_user\fP.
+ */
{ "imap_pass", DT_STR, R_NONE, UL &ImapPass, UL 0 },
/*
** .pp
{ "imap_user", DT_STR, R_NONE, UL &ImapUser, UL 0 },
/*
** .pp
- ** Your login name on the IMAP server.
+ ** The name of the user whose mail you intend to access on the IMAP
+ ** server.
** .pp
** This variable defaults to your user name on the local machine.
*/
callback = mutt_sasl_callbacks;
- callback->id = SASL_CB_AUTHNAME;
+ callback->id = SASL_CB_USER;
callback->proc = mutt_sasl_cb_authname;
callback->context = account;
callback++;
- callback->id = SASL_CB_USER;
+ callback->id = SASL_CB_AUTHNAME;
callback->proc = mutt_sasl_cb_authname;
callback->context = account;
callback++;
return SASL_OK;
}
-/* mutt_sasl_cb_authname: callback to retrieve authname or user (mutt
- * doesn't distinguish, even if some SASL plugins do) from ACCOUNT */
+/* mutt_sasl_cb_authname: callback to retrieve authname or user from ACCOUNT */
static int mutt_sasl_cb_authname (void* context, int id, const char** result,
unsigned* len)
{
id == SASL_CB_AUTHNAME ? "authname" : "user",
account->host, account->port));
- if (mutt_account_getuser (account))
- return SASL_FAIL;
-
- *result = account->user;
-
+ if (id == SASL_CB_AUTHNAME)
+ {
+ if (mutt_account_getlogin (account))
+ return SASL_FAIL;
+ *result = account->login;
+ }
+ else
+ {
+ if (mutt_account_getuser (account))
+ return SASL_FAIL;
+ *result = account->user;
+ }
+
if (len)
*len = strlen (*result);
return SASL_BADPARAM;
dprint (2, (debugfile,
- "mutt_sasl_cb_pass: getting password for %s@%s:%u\n", account->user,
+ "mutt_sasl_cb_pass: getting password for %s@%s:%u\n", account->login,
account->host, account->port));
if (mutt_account_getpass (account))