static int mutt_sasl_cb_pass (sasl_conn_t* conn, void* context, int id, sasl_secret_t** psecret) { ACCOUNT* account = (ACCOUNT*) context; int len; if (!account || !psecret) return SASL_BADPARAM; dprint (2, (debugfile, "mutt_sasl_cb_pass: getting password for %s@%s:%u\n", account->login, account->host, account->port)); if (mutt_account_getpass (account)) return SASL_FAIL; len = strlen (account->pass); safe_realloc (&secret_ptr, sizeof (sasl_secret_t) + len); memcpy ((char *) secret_ptr->data, account->pass, (size_t) len); secret_ptr->len = len; *psecret = secret_ptr; return SASL_OK; }
/* imap_auth_login: Plain LOGIN support */ imap_auth_res_t imap_auth_login (IMAP_DATA* idata, const char* method) { char q_user[SHORT_STRING], q_pass[SHORT_STRING]; char buf[STRING]; int rc; if (bit_val(idata->capabilities, LOGINDISABLED)) { mutt_message("LOGIN disabled on this server."); return IMAP_AUTH_UNAVAIL; } if (mutt_account_getuser (&idata->conn->account)) return IMAP_AUTH_FAILURE; if (mutt_account_getpass (&idata->conn->account)) return IMAP_AUTH_FAILURE; mutt_message("Logging in..."); imap_quote_string (q_user, sizeof (q_user), idata->conn->account.user); imap_quote_string (q_pass, sizeof (q_pass), idata->conn->account.pass); snprintf (buf, sizeof (buf), "LOGIN %s %s", q_user, q_pass); rc = imap_exec (idata, buf, IMAP_CMD_FAIL_OK | IMAP_CMD_PASS); if (!rc) { mutt_clear_error(); /* clear "Logging in...". fixes #3524 */ return IMAP_AUTH_SUCCESS; } mutt_error("Login failed."); mutt_sleep (2); return IMAP_AUTH_FAILURE; }
static int mutt_sasl_cb_pass(sasl_conn_t *conn, void *context, int id, sasl_secret_t **psecret) { ACCOUNT *account = (ACCOUNT *)context; int len; if (!account || !psecret) return SASL_BADPARAM; dprint(2, "mutt_sasl_cb_pass: getting password for %s@%s:%u\n", account->login, account->host, account->port); if (mutt_account_getpass(account)) return SASL_FAIL; len = strlen(account->pass); *psecret = (sasl_secret_t *)safe_malloc(sizeof(sasl_secret_t) + len); (*psecret)->len = len; strcpy((char *)(*psecret)->data, account->pass); /* __STRCPY_CHECKED__ */ return SASL_OK; }
static int ssl_passwd_cb(char *buf, int size, int rwflag, void *userdata) { ACCOUNT *account = (ACCOUNT*)userdata; if (mutt_account_getuser (account)) return 0; dprint (2, (debugfile, "ssl_passwd_cb: getting password for %s@%s:%u\n", account->user, account->host, account->port)); if (mutt_account_getpass (account)) return 0; return snprintf(buf, size, "%s", account->pass); }
/** * ssl_passwd_cb - Callback to get a password * @param buf Buffer for the password * @param buflen Length of the buffer * @param rwflag 0 if writing, 1 if reading (UNUSED) * @param userdata ConnAccount whose password is requested * @retval >0 Success, number of chars written to buf * @retval 0 Error */ static int ssl_passwd_cb(char *buf, int buflen, int rwflag, void *userdata) { struct ConnAccount *account = userdata; if (mutt_account_getuser(account) < 0) return 0; mutt_debug(LL_DEBUG2, "getting password for %s@%s:%u\n", account->user, account->host, account->port); if (mutt_account_getpass(account) < 0) return 0; return snprintf(buf, buflen, "%s", account->pass); }
/* imap_auth_login: Plain LOGIN support */ imap_auth_res_t imap_auth_login (IMAP_DATA* idata, const char* method) { char q_user[SHORT_STRING], q_pass[SHORT_STRING]; char buf[STRING]; int rc; if (mutt_bit_isset (idata->capabilities, LOGINDISABLED)) { mutt_message _("LOGIN disabled on this server."); return IMAP_AUTH_UNAVAIL; } if (mutt_account_getuser (&idata->conn->account)) return IMAP_AUTH_FAILURE; if (mutt_account_getpass (&idata->conn->account)) return IMAP_AUTH_FAILURE; mutt_message _("Logging in..."); imap_quote_string (q_user, sizeof (q_user), idata->conn->account.user); imap_quote_string (q_pass, sizeof (q_pass), idata->conn->account.pass); #ifdef DEBUG /* don't print the password unless we're at the ungodly debugging level * of 5 or higher */ if (debuglevel < IMAP_LOG_PASS) dprint (2, (debugfile, "Sending LOGIN command for %s...\n", idata->conn->account.user)); #endif snprintf (buf, sizeof (buf), "LOGIN %s %s", q_user, q_pass); rc = imap_exec (idata, buf, IMAP_CMD_FAIL_OK | IMAP_CMD_PASS); if (!rc) return IMAP_AUTH_SUCCESS; mutt_error _("Login failed."); mutt_sleep (2); return IMAP_AUTH_FAILURE; }