if (id == SASL_CB_AUTHNAME)
{
- if (mutt_account_getlogin(account))
+ if (mutt_account_getlogin(account) < 0)
return SASL_FAIL;
*result = account->login;
}
else
{
- if (mutt_account_getuser(account))
+ if (mutt_account_getuser(account) < 0)
return SASL_FAIL;
*result = account->user;
}
mutt_debug(2, "mutt_sasl_cb_pass: getting password for %s@%s:%u\n",
account->login, account->host, account->port);
- if (mutt_account_getpass(account))
+ if (mutt_account_getpass(account) < 0)
return SASL_FAIL;
len = strlen(account->pass);
{
struct Account *account = (struct Account *) userdata;
- if (mutt_account_getuser(account))
+ if (mutt_account_getuser(account) < 0)
return 0;
mutt_debug(2, "ssl_passwd_cb: getting password for %s@%s:%u\n", account->user,
account->host, account->port);
- if (mutt_account_getpass(account))
+ if (mutt_account_getpass(account) < 0)
return 0;
return snprintf(buf, size, "%s", account->pass);
SSL_CTX_use_PrivateKey_file(ssldata->ctx, SslClientCert, SSL_FILETYPE_PEM);
/* if we are using a client cert, SASL may expect an external auth name */
- mutt_account_getuser(&conn->account);
+ if (mutt_account_getuser(&conn->account) < 0)
+ mutt_debug(1, "Couldn't get user info\n");
}
}
*cnend = '\0';
/* if we are using a client cert, SASL may expect an external auth name */
- mutt_account_getuser(&conn->account);
+ if (mutt_account_getuser(&conn->account) < 0)
+ mutt_debug(1, "Couldn't get user info\n");
err_dn:
FREE(&dn);
if (!mutt_bit_isset(idata->capabilities, AUTH_ANON))
return IMAP_AUTH_UNAVAIL;
- if (mutt_account_getuser(&idata->conn->account))
+ if (mutt_account_getuser(&idata->conn->account) < 0)
return IMAP_AUTH_FAILURE;
if (idata->conn->account.user[0] != '\0')
mutt_message(_("Authenticating (CRAM-MD5)..."));
/* get auth info */
- if (mutt_account_getlogin(&idata->conn->account))
+ if (mutt_account_getlogin(&idata->conn->account) < 0)
return IMAP_AUTH_FAILURE;
- if (mutt_account_getpass(&idata->conn->account))
+ if (mutt_account_getpass(&idata->conn->account) < 0)
return IMAP_AUTH_FAILURE;
imap_cmd_start(idata, "AUTHENTICATE CRAM-MD5");
if (!mutt_bit_isset(idata->capabilities, AGSSAPI))
return IMAP_AUTH_UNAVAIL;
- if (mutt_account_getuser(&idata->conn->account))
+ if (mutt_account_getuser(&idata->conn->account) < 0)
return IMAP_AUTH_FAILURE;
/* get an IMAP service ticket for the server */
return IMAP_AUTH_UNAVAIL;
}
- if (mutt_account_getuser(&idata->conn->account))
+ if (mutt_account_getuser(&idata->conn->account) < 0)
return IMAP_AUTH_FAILURE;
- if (mutt_account_getpass(&idata->conn->account))
+ if (mutt_account_getpass(&idata->conn->account) < 0)
return IMAP_AUTH_FAILURE;
mutt_message(_("Logging in..."));
enum ImapAuthRes res = IMAP_AUTH_SUCCESS;
char buf[STRING];
- if (mutt_account_getuser(&idata->conn->account))
+ if (mutt_account_getuser(&idata->conn->account) < 0)
return IMAP_AUTH_FAILURE;
- if (mutt_account_getpass(&idata->conn->account))
+ if (mutt_account_getpass(&idata->conn->account) < 0)
return IMAP_AUTH_FAILURE;
mutt_message(_("Logging in..."));
* 2. attempt sasl_client_start with only "AUTH=ANONYMOUS" capability
* 3. if sasl_client_start fails, fall through... */
- if (mutt_account_getuser(&idata->conn->account))
+ if (mutt_account_getuser(&idata->conn->account) < 0)
return IMAP_AUTH_FAILURE;
if (mutt_bit_isset(idata->capabilities, AUTH_ANON) &&
#include "url.h"
/**
- * mutt_account_match - compare account info (host/port/user)
+ * mutt_account_match - Compare account info (host/port/user)
+ * @param a1 First Account
+ * @param a2 Second Account
+ * @retval 0 Accounts match
*/
int mutt_account_match(const struct Account *a1, const struct Account *a2)
{
}
/**
- * mutt_account_fromurl - fill account with information from url
+ * mutt_account_fromurl - Fill Account with information from url
+ * @param account Account to fill
+ * @param url Url to parse
+ * @retval 0 Success
+ * @retval -1 Error
*/
int mutt_account_fromurl(struct Account *account, struct Url *url)
{
}
/**
- * mutt_account_tourl - fill URL with info from account
+ * mutt_account_tourl - Fill URL with info from account
+ * @param account Source Account
+ * @param url Url to fill
*
* The URL information is a set of pointers into account - don't free or edit
* account until you've finished with url (make a copy of account if you need
}
/**
- * mutt_account_getuser - retrieve username into Account, if necessary
+ * mutt_account_getuser - Retrieve username into Account, if necessary
+ * @param account Account to fill
+ * @retval 0 Success
+ * @retval -1 Failure
*/
int mutt_account_getuser(struct Account *account)
{
return 0;
}
+/**
+ * mutt_account_getlogin - Retrieve login info into Account, if necessary
+ * @param account Account to fill
+ * @retval 0 Success
+ * @retval -1 Failure
+ */
int mutt_account_getlogin(struct Account *account)
{
/* already set */
if (!(account->flags & MUTT_ACCT_LOGIN))
{
- mutt_account_getuser(account);
- strfcpy(account->login, account->user, sizeof(account->login));
+ if (mutt_account_getuser(account) == 0)
+ {
+ strfcpy(account->login, account->user, sizeof(account->login));
+ account->flags |= MUTT_ACCT_LOGIN;
+ }
+ else
+ {
+ mutt_debug(1, "Couldn't get user info\n");
+ return -1;
+ }
}
- account->flags |= MUTT_ACCT_LOGIN;
-
return 0;
}
/**
- * mutt_account_getpass - fetch password into Account, if necessary
+ * mutt_account_getpass - Fetch password into Account, if necessary
+ * @param account Account to fill
+ * @retval 0 Success
+ * @retval -1 Failure
*/
int mutt_account_getpass(struct Account *account)
{
return 0;
}
+/**
+ * mutt_account_unsetpass - Unset Account's password
+ * @param account Account to modify
+ */
void mutt_account_unsetpass(struct Account *account)
{
account->flags &= ~MUTT_ACCT_PASS;
};
/* account flags */
-#define MUTT_ACCT_PORT (1 << 0)
-#define MUTT_ACCT_USER (1 << 1)
+#define MUTT_ACCT_PORT (1 << 0)
+#define MUTT_ACCT_USER (1 << 1)
#define MUTT_ACCT_LOGIN (1 << 2)
-#define MUTT_ACCT_PASS (1 << 3)
-#define MUTT_ACCT_SSL (1 << 4)
+#define MUTT_ACCT_PASS (1 << 3)
+#define MUTT_ACCT_SSL (1 << 4)
int mutt_account_match(const struct Account *a1, const struct Account *m2);
int mutt_account_fromurl(struct Account *account, struct Url *url);
while (true)
{
/* get login and password */
- if (mutt_account_getuser(&conn->account) || !conn->account.user[0] ||
- mutt_account_getpass(&conn->account) || !conn->account.pass[0])
+ if ((mutt_account_getuser(&conn->account) < 0) || (conn->account.user[0] == '\0') ||
+ (mutt_account_getpass(&conn->account) < 0) || (conn->account.pass[0] == '\0'))
break;
/* get list of authenticators */
int attempts = 0;
int ret = POP_A_UNAVAIL;
- if (mutt_account_getuser(acct) || !acct->user[0] ||
- mutt_account_getpass(acct) || !acct->pass[0])
+ if ((mutt_account_getuser(acct) < 0) || (acct->user[0] == '\0') ||
+ (mutt_account_getpass(acct) < 0) || (acct->pass[0] == '\0'))
return -3;
if (PopAuthenticators && *PopAuthenticators)
if (mutt_strncasecmp(method, "plain", 5) == 0)
{
/* Get username and password. Bail out of any cannot be retrieved. */
- if (mutt_account_getuser(&conn->account) || mutt_account_getpass(&conn->account))
+ if ((mutt_account_getuser(&conn->account) < 0) ||
+ (mutt_account_getpass(&conn->account) < 0))
{
goto error;
}