NeoMutt  2023-05-17-56-ga67199
Teaching an old dog new tricks
DOXYGEN
auth_anon.c File Reference

IMAP anonymous authentication method. More...

#include "config.h"
#include "private.h"
#include "mutt/lib.h"
#include "conn/lib.h"
#include "adata.h"
#include "auth.h"
+ Include dependency graph for auth_anon.c:

Go to the source code of this file.

Functions

enum ImapAuthRes imap_auth_anon (struct ImapAccountData *adata, const char *method)
 Authenticate anonymously - Implements ImapAuth::authenticate() More...
 

Detailed Description

IMAP anonymous 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_anon.c.

Function Documentation

◆ imap_auth_anon()

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

Authenticate anonymously - Implements ImapAuth::authenticate()

This is basically a stripped-down version of the cram-md5 method.

Definition at line 41 of file auth_anon.c.

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_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
int mutt_account_getuser(struct ConnAccount *cac)
Retrieve username into ConnAccount, if necessary.
Definition: connaccount.c:49
#define mutt_error(...)
Definition: logging2.h:90
#define mutt_message(...)
Definition: logging2.h:89
#define mutt_debug(LEVEL,...)
Definition: logging2.h:87
int imap_cmd_start(struct ImapAccountData *adata, const char *cmdstr)
Given an IMAP command, send it to the server.
Definition: command.c:1095
int imap_cmd_step(struct ImapAccountData *adata)
Reads server responses from an IMAP command.
Definition: command.c:1109
bool imap_code(const char *s)
Was the command successful.
Definition: command.c:1236
#define IMAP_RES_RESPOND
+
Definition: private.h:57
#define IMAP_RES_OK
<tag> OK ...
Definition: private.h:55
#define IMAP_CAP_AUTH_ANONYMOUS
AUTH=ANONYMOUS.
Definition: private.h:128
#define IMAP_RES_CONTINUE
* ...
Definition: private.h:56
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
#define _(a)
Definition: message.h:28
#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
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
+ Here is the call graph for this function: