2 * Copyright notice from original mutt:
3 * Copyright (C) 1999-2000 Brendan Cully <brendan@kublai.com>
5 * This file is part of mutt-ng, see http://www.muttng.org/.
6 * It's licensed under the GNU General Public License,
7 * please see the file GPL in the top level source directory.
10 /* IMAP login/authentication code */
12 #include <lib-lib/lib-lib.h>
15 #include "imap_private.h"
18 /* this is basically a stripped-down version of the cram-md5 method. */
19 imap_auth_res_t imap_auth_anon (IMAP_DATA * idata, const char *method __attribute__ ((unused)))
23 if (!mutt_bit_isset (idata->capabilities, AUTH_ANON))
24 return IMAP_AUTH_UNAVAIL;
26 if (mutt_account_getuser (&idata->conn->account))
27 return IMAP_AUTH_FAILURE;
29 if (idata->conn->account.user[0] != '\0')
30 return IMAP_AUTH_UNAVAIL;
32 mutt_message _("Authenticating (anonymous)...");
34 imap_cmd_start (idata, "AUTHENTICATE ANONYMOUS");
37 rc = imap_cmd_step (idata);
38 while (rc == IMAP_CMD_CONTINUE);
40 if (rc != IMAP_CMD_RESPOND) {
44 mutt_socket_write (idata->conn, "ZHVtbXkK\r\n"); /* base64 ("dummy") */
47 rc = imap_cmd_step (idata);
48 while (rc == IMAP_CMD_CONTINUE);
50 if (rc != IMAP_CMD_OK) {
54 if (imap_code (idata->cmd.buf))
55 return IMAP_AUTH_SUCCESS;
58 mutt_error _("Anonymous authentication failed.");
60 return IMAP_AUTH_FAILURE;