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 */
17 #include "imap_private.h"
22 /* this is basically a stripped-down version of the cram-md5 method. */
23 imap_auth_res_t imap_auth_anon (IMAP_DATA * idata, const char *method)
27 if (!mutt_bit_isset (idata->capabilities, AUTH_ANON))
28 return IMAP_AUTH_UNAVAIL;
30 if (mutt_account_getuser (&idata->conn->account))
31 return IMAP_AUTH_FAILURE;
33 if (idata->conn->account.user[0] != '\0')
34 return IMAP_AUTH_UNAVAIL;
36 mutt_message _("Authenticating (anonymous)...");
38 imap_cmd_start (idata, "AUTHENTICATE ANONYMOUS");
41 rc = imap_cmd_step (idata);
42 while (rc == IMAP_CMD_CONTINUE);
44 if (rc != IMAP_CMD_RESPOND) {
45 dprint (1, (debugfile, "Invalid response from server.\n"));
49 mutt_socket_write (idata->conn, "ZHVtbXkK\r\n"); /* base64 ("dummy") */
52 rc = imap_cmd_step (idata);
53 while (rc == IMAP_CMD_CONTINUE);
55 if (rc != IMAP_CMD_OK) {
56 dprint (1, (debugfile, "Error receiving server response.\n"));
60 if (imap_code (idata->cmd.buf))
61 return IMAP_AUTH_SUCCESS;
64 mutt_error _("Anonymous authentication failed.");
66 return IMAP_AUTH_FAILURE;