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