NeoMutt  2020-06-26-250-g349c94
Teaching an old dog new tricks
DOXYGEN
auth_login.c File Reference

IMAP login authentication method. More...

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include "private.h"
#include "mutt/lib.h"
#include "conn/lib.h"
#include "auth.h"
#include "mutt_logging.h"
+ Include dependency graph for auth_login.c:

Go to the source code of this file.

Functions

enum ImapAuthRes imap_auth_login (struct ImapAccountData *adata, const char *method)
 Plain LOGIN support - Implements ImapAuth::authenticate() More...
 

Detailed Description

IMAP login authentication method.

Authors
  • Brendan Cully

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file auth_login.c.

Function Documentation

◆ imap_auth_login()

enum ImapAuthRes imap_auth_login ( struct ImapAccountData adata,
const char *  method 
)

Plain LOGIN support - Implements ImapAuth::authenticate()

Parameters
adataImap Account data
methodName of this authentication method
Return values
ImapAuthResResult, e.g. IMAP_AUTH_SUCCESS

Definition at line 44 of file auth_login.c.

45 {
46  char q_user[256], q_pass[256];
47  char buf[1024];
48 
49  if ((adata->capabilities & IMAP_CAP_LOGINDISABLED))
50  {
51  mutt_message(_("LOGIN disabled on this server"));
52  return IMAP_AUTH_UNAVAIL;
53  }
54 
55  if (mutt_account_getuser(&adata->conn->account) < 0)
56  return IMAP_AUTH_FAILURE;
57  if (mutt_account_getpass(&adata->conn->account) < 0)
58  return IMAP_AUTH_FAILURE;
59 
60  mutt_message(_("Logging in..."));
61 
62  imap_quote_string(q_user, sizeof(q_user), adata->conn->account.user, false);
63  imap_quote_string(q_pass, sizeof(q_pass), adata->conn->account.pass, false);
64 
65  /* don't print the password unless we're at the ungodly debugging level
66  * of 5 or higher */
67 
69  mutt_debug(LL_DEBUG2, "Sending LOGIN command for %s\n", adata->conn->account.user);
70 
71  snprintf(buf, sizeof(buf), "LOGIN %s %s", q_user, q_pass);
72  if (imap_exec(adata, buf, IMAP_CMD_PASS) == IMAP_EXEC_SUCCESS)
73  {
75  return IMAP_AUTH_SUCCESS;
76  }
77 
78  mutt_error(_("Login failed"));
79  return IMAP_AUTH_FAILURE;
80 }
int mutt_account_getuser(struct ConnAccount *cac)
Retrieve username into ConnAccount, if necessary.
Definition: connaccount.c:48
struct ConnAccount account
Account details: username, password, etc.
Definition: connection.h:36
#define mutt_message(...)
Definition: logging.h:83
char user[128]
Username.
Definition: connaccount.h:55
#define _(a)
Definition: message.h:28
#define IMAP_LOG_PASS
Definition: private.h:50
Authentication method not permitted.
Definition: auth.h:40
Imap command executed or queued successfully.
Definition: private.h:83
Log at debug level 2.
Definition: logging.h:41
char pass[256]
Password.
Definition: connaccount.h:56
Authentication failed.
Definition: auth.h:39
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
int imap_exec(struct ImapAccountData *adata, const char *cmdstr, ImapCmdFlags flags)
Execute a command and wait for the response from the server.
Definition: command.c:1247
short C_DebugLevel
Config: Logging level for debug logs.
Definition: mutt_logging.c:48
#define IMAP_CAP_LOGINDISABLED
RFC2595: LOGINDISABLED.
Definition: private.h:132
#define IMAP_CMD_PASS
Command contains a password. Suppress logging.
Definition: private.h:73
ImapCapFlags capabilities
Definition: private.h:185
#define mutt_error(...)
Definition: logging.h:84
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
Authentication successful.
Definition: auth.h:38
void imap_quote_string(char *dest, size_t dlen, const char *src, bool quote_backtick)
quote string according to IMAP rules
Definition: util.c:971
int mutt_account_getpass(struct ConnAccount *cac)
Fetch password into ConnAccount, if necessary.
Definition: connaccount.c:111
struct Connection * conn
Definition: private.h:171
+ Here is the call graph for this function: