X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=imap%2Fauth_sasl.c;h=8544352878bc97cf9f5a79a6585cff3eb56c53e9;hb=0dbe922d4298aed78dcba64b7c770f315a64505e;hp=88001d44c63dbd23f78b9b6e71d929b241a147ff;hpb=b85f52d2ec4d820ab5c4b577857548bec294bb27;p=apps%2Fmadmutt.git diff --git a/imap/auth_sasl.c b/imap/auth_sasl.c index 88001d4..8544352 100644 --- a/imap/auth_sasl.c +++ b/imap/auth_sasl.c @@ -13,20 +13,18 @@ # include "config.h" #endif +#include +#include + #include "mutt.h" -#include "ascii.h" #include "mutt_sasl.h" #include "imap_private.h" #include "auth.h" -#include "lib/mem.h" -#include "lib/intl.h" -#include "lib/debug.h" +#include -#ifdef USE_SASL #include #include -#endif /* imap_auth_sasl: Default authenticator if available. */ imap_auth_res_t imap_auth_sasl (IMAP_DATA * idata, const char *method) @@ -37,14 +35,11 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA * idata, const char *method) char buf[HUGE_STRING]; const char *mech; -#ifdef USE_SASL const char *pc = NULL; -#endif unsigned int len, olen; unsigned char client_start; if (mutt_sasl_client_new (idata->conn, &saslconn) < 0) { - debug_print (1, ("Error allocating SASL connection.\n")); return IMAP_AUTH_FAILURE; } @@ -65,18 +60,14 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA * idata, const char *method) if (mutt_bit_isset (idata->capabilities, AUTH_ANON) && (!idata->conn->account.user[0] || !ascii_strncmp (idata->conn->account.user, "anonymous", 9))) -#ifdef USE_SASL rc = sasl_client_start (saslconn, "AUTH=ANONYMOUS", NULL, &pc, &olen, &mech); -#endif } if (rc != SASL_OK && rc != SASL_CONTINUE) do { -#ifdef USE_SASL rc = sasl_client_start (saslconn, method, &interaction, &pc, &olen, &mech); -#endif if (rc == SASL_INTERACT) mutt_sasl_interact (interaction); } @@ -85,12 +76,7 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA * idata, const char *method) client_start = (olen > 0); if (rc != SASL_OK && rc != SASL_CONTINUE) { - if (method) - debug_print (2, ("%s unavailable\n", method)); - else - debug_print (1, ("Failure starting authentication exchange. No shared mechanisms?\n")); /* SASL doesn't support LOGIN, so fall back */ - return IMAP_AUTH_UNAVAIL; } @@ -107,7 +93,6 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA * idata, const char *method) while (irc == IMAP_CMD_CONTINUE); if (method && irc == IMAP_CMD_NO) { - debug_print (2, ("%s failed\n", method)); sasl_dispose (&saslconn); return IMAP_AUTH_UNAVAIL; } @@ -116,13 +101,8 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA * idata, const char *method) goto bail; if (irc == IMAP_CMD_RESPOND) { -#ifdef USE_SASL - if (sasl_decode64 - (idata->cmd.buf + 2, str_len (idata->cmd.buf + 2), buf, - LONG_STRING - 1, -#endif - &len) != SASL_OK) { - debug_print (1, ("error base64-decoding server response.\n")); + if (sasl_decode64(idata->cmd.buf + 2, m_strlen(idata->cmd.buf + 2), buf, + LONG_STRING - 1, &len) != SASL_OK) { goto bail; } } @@ -144,26 +124,18 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA * idata, const char *method) /* send out response, or line break if none needed */ if (olen) { if (sasl_encode64 (pc, olen, buf, sizeof (buf), &olen) != SASL_OK) { - debug_print (1, ("error base64-encoding client response.\n")); goto bail; } - - /* sasl_client_st(art|ep) allocate pc with malloc, expect me to - * free it */ -#ifndef USE_SASL - mem_free (&pc); -#endif } if (irc == IMAP_CMD_RESPOND) { - strfcpy (buf + olen, "\r\n", sizeof (buf) - olen); + m_strcpy(buf + olen, sizeof(buf) - olen, "\r\n"); mutt_socket_write (idata->conn, buf); } /* If SASL has errored out, send an abort string to the server */ if (rc < 0) { mutt_socket_write (idata->conn, "*\r\n"); - debug_print (1, ("sasl_client_step error %d\n", rc)); } olen = 0;