NeoMutt  2022-04-29-249-gaae397
Teaching an old dog new tricks
DOXYGEN
auth_anon.c
Go to the documentation of this file.
1
29#include "config.h"
30#include "private.h"
31#include "mutt/lib.h"
32#include "conn/lib.h"
33#include "adata.h"
34#include "auth.h"
35
41enum ImapAuthRes imap_auth_anon(struct ImapAccountData *adata, const char *method)
42{
43 int rc;
44
46 return IMAP_AUTH_UNAVAIL;
47
48 if (mutt_account_getuser(&adata->conn->account) < 0)
49 return IMAP_AUTH_FAILURE;
50
51 if (adata->conn->account.user[0] != '\0')
52 return IMAP_AUTH_UNAVAIL;
53
54 // L10N: (%s) is the method name, e.g. Anonymous, CRAM-MD5, GSSAPI, SASL
55 mutt_message(_("Authenticating (%s)..."), "anonymous");
56
57 imap_cmd_start(adata, "AUTHENTICATE ANONYMOUS");
58
59 do
60 {
61 rc = imap_cmd_step(adata);
62 } while (rc == IMAP_RES_CONTINUE);
63
64 if (rc != IMAP_RES_RESPOND)
65 {
66 mutt_debug(LL_DEBUG1, "Invalid response from server\n");
67 goto bail;
68 }
69
70 mutt_socket_send(adata->conn, "ZHVtbXkK\r\n"); /* base64 ("dummy") */
71
72 do
73 {
74 rc = imap_cmd_step(adata);
75 } while (rc == IMAP_RES_CONTINUE);
76
77 if (rc != IMAP_RES_OK)
78 {
79 mutt_debug(LL_DEBUG1, "Error receiving server response\n");
80 goto bail;
81 }
82
83 if (imap_code(adata->buf))
84 return IMAP_AUTH_SUCCESS;
85
86bail:
87 // L10N: %s is the method name, e.g. Anonymous, CRAM-MD5, GSSAPI, SASL
88 mutt_error(_("%s authentication failed"), "anonymous");
89 return IMAP_AUTH_FAILURE;
90}
IMAP authenticator multiplexor.
ImapAuthRes
Results of IMAP Authentication.
Definition: auth.h:38
@ IMAP_AUTH_FAILURE
Authentication failed.
Definition: auth.h:40
@ IMAP_AUTH_SUCCESS
Authentication successful.
Definition: auth.h:39
@ IMAP_AUTH_UNAVAIL
Authentication method not permitted.
Definition: auth.h:41
enum ImapAuthRes imap_auth_anon(struct ImapAccountData *adata, const char *method)
Authenticate anonymously - Implements ImapAuth::authenticate()
Definition: auth_anon.c:41
Connection Library.
int mutt_account_getuser(struct ConnAccount *cac)
Retrieve username into ConnAccount, if necessary.
Definition: connaccount.c:50
#define mutt_error(...)
Definition: logging.h:87
#define mutt_message(...)
Definition: logging.h:86
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
int imap_cmd_start(struct ImapAccountData *adata, const char *cmdstr)
Given an IMAP command, send it to the server.
Definition: command.c:1062
int imap_cmd_step(struct ImapAccountData *adata)
Reads server responses from an IMAP command.
Definition: command.c:1076
bool imap_code(const char *s)
Was the command successful.
Definition: command.c:1199
#define IMAP_RES_RESPOND
+
Definition: private.h:58
#define IMAP_RES_OK
<tag> OK ...
Definition: private.h:56
#define IMAP_CAP_AUTH_ANONYMOUS
AUTH=ANONYMOUS.
Definition: private.h:130
#define IMAP_RES_CONTINUE
* ...
Definition: private.h:57
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
Convenience wrapper for the library headers.
#define _(a)
Definition: message.h:28
Pop-specific Account data.
GUI display the mailboxes in a side panel.
#define mutt_socket_send(conn, buf)
Definition: socket.h:59
char user[128]
Username.
Definition: connaccount.h:56
struct ConnAccount account
Account details: username, password, etc.
Definition: connection.h:50
IMAP-specific Account data -.
Definition: adata.h:40
ImapCapFlags capabilities
Capability flags.
Definition: adata.h:55
char * buf
Definition: adata.h:59
struct Connection * conn
Connection to IMAP server.
Definition: adata.h:41