X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=imap%2Fauth.c;h=04fe6712864f9c496a21ae3e256e7ef97a765fa3;hp=d52f86fb0370b35905eb9dee92e18dc0c593b9ee;hb=c98480f8568e6c1bc927c6c5f2b5e80b4aa6548c;hpb=f404a0ca916be07049af51a3022baaaaab94def6 diff --git a/imap/auth.c b/imap/auth.c index d52f86f..04fe671 100644 --- a/imap/auth.c +++ b/imap/auth.c @@ -1,22 +1,13 @@ /* + * Copyright notice from original mutt: * Copyright (C) 1996-8 Michael R. Elkins * Copyright (C) 1996-9 Brandon Long * Copyright (C) 1999-2001 Brendan Cully - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - */ + * + * This file is part of mutt-ng, see http://www.muttng.org/. + * It's licensed under the GNU General Public License, + * please see the file GPL in the top level source directory. + */ /* IMAP login/authentication code */ @@ -24,90 +15,90 @@ # include "config.h" #endif +#include + +#include +#include +#include "lib/debug.h" + #include "mutt.h" #include "imap_private.h" #include "auth.h" static imap_auth_t imap_authenticators[] = { #ifdef USE_SASL - { imap_auth_sasl, NULL }, + {imap_auth_sasl, NULL}, #else - { imap_auth_anon, "anonymous" }, + {imap_auth_anon, "anonymous"}, #endif #ifdef USE_GSS - { imap_auth_gss, "gssapi" }, + {imap_auth_gss, "gssapi"}, #endif /* SASL includes CRAM-MD5 (and GSSAPI, but that's not enabled by default) */ #ifndef USE_SASL - { imap_auth_cram_md5, "cram-md5" }, + {imap_auth_cram_md5, "cram-md5"}, #endif - { imap_auth_login, "login" }, + {imap_auth_login, "login"}, - { NULL } + {NULL, NULL} }; /* imap_authenticate: Attempt to authenticate using either user-specified * authentication method if specified, or any. */ -int imap_authenticate (IMAP_DATA* idata) +int imap_authenticate (IMAP_DATA * idata) { - imap_auth_t* authenticator; - char* methods; - char* method; - char* delim; + imap_auth_t *authenticator; + char *methods; + char *method; + char *delim; int r = -1; - if (ImapAuthenticators && *ImapAuthenticators) - { + if (ImapAuthenticators && *ImapAuthenticators) { /* Try user-specified list of authentication methods */ - methods = safe_strdup (ImapAuthenticators); + methods = m_strdup(ImapAuthenticators); - for (method = methods; method; method = delim) - { + for (method = methods; method; method = delim) { delim = strchr (method, ':'); if (delim) - *delim++ = '\0'; - if (! method[0]) - continue; - - dprint (2, (debugfile, "imap_authenticate: Trying method %s\n", method)); + *delim++ = '\0'; + if (!method[0]) + continue; + + debug_print (2, ("Trying method %s\n", method)); authenticator = imap_authenticators; - while (authenticator->authenticate) - { - if (!authenticator->method || - !ascii_strcasecmp (authenticator->method, method)) - if ((r = authenticator->authenticate (idata, method)) != - IMAP_AUTH_UNAVAIL) - { - FREE (&methods); - return r; - } - - authenticator++; + while (authenticator->authenticate) { + if (!authenticator->method || + !ascii_strcasecmp (authenticator->method, method)) + if ((r = authenticator->authenticate (idata, method)) != + IMAP_AUTH_UNAVAIL) { + p_delete(&methods); + return r; + } + + authenticator++; } } - FREE (&methods); + p_delete(&methods); } - else - { + else { /* Fall back to default: any authenticator */ - dprint (2, (debugfile, "imap_authenticate: Using any available method.\n")); + debug_print (2, ("Using any available method.\n")); authenticator = imap_authenticators; - while (authenticator->authenticate) - { - if ((r = authenticator->authenticate (idata, NULL)) != IMAP_AUTH_UNAVAIL) - return r; + while (authenticator->authenticate) { + if ((r = + authenticator->authenticate (idata, NULL)) != IMAP_AUTH_UNAVAIL) + return r; authenticator++; } } - if (r == IMAP_AUTH_UNAVAIL) - { + if (r == IMAP_AUTH_UNAVAIL) { mutt_error (_("No authenticators available")); mutt_sleep (1); } - + return r; }