mutt stable branch with some hacks
at master 76 lines 2.1 kB view raw
1/* 2 * Copyright (C) 1999-2001,2005 Brendan Cully <brendan@kublai.com> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19/* IMAP login/authentication code */ 20 21#if HAVE_CONFIG_H 22# include "config.h" 23#endif 24 25#include "mutt.h" 26#include "imap_private.h" 27#include "auth.h" 28 29/* this is basically a stripped-down version of the cram-md5 method. */ 30imap_auth_res_t imap_auth_anon (IMAP_DATA* idata, const char* method) 31{ 32 int rc; 33 34 if (!mutt_bit_isset (idata->capabilities, AUTH_ANON)) 35 return IMAP_AUTH_UNAVAIL; 36 37 if (mutt_account_getuser (&idata->conn->account)) 38 return IMAP_AUTH_FAILURE; 39 40 if (idata->conn->account.user[0] != '\0') 41 return IMAP_AUTH_UNAVAIL; 42 43 mutt_message _("Authenticating (anonymous)..."); 44 45 imap_cmd_start (idata, "AUTHENTICATE ANONYMOUS"); 46 47 do 48 rc = imap_cmd_step (idata); 49 while (rc == IMAP_CMD_CONTINUE); 50 51 if (rc != IMAP_CMD_RESPOND) 52 { 53 dprint (1, (debugfile, "Invalid response from server.\n")); 54 goto bail; 55 } 56 57 mutt_socket_write (idata->conn, "ZHVtbXkK\r\n"); /* base64 ("dummy") */ 58 59 do 60 rc = imap_cmd_step (idata); 61 while (rc == IMAP_CMD_CONTINUE); 62 63 if (rc != IMAP_CMD_OK) 64 { 65 dprint (1, (debugfile, "Error receiving server response.\n")); 66 goto bail; 67 } 68 69 if (imap_code (idata->buf)) 70 return IMAP_AUTH_SUCCESS; 71 72 bail: 73 mutt_error _("Anonymous authentication failed."); 74 mutt_sleep (2); 75 return IMAP_AUTH_FAILURE; 76}