Changeset 3437:71b9f5245f22

Show
Ignore:
Timestamp:
2003-07-16 04:18:12 (5 years ago)
Author:
Brendan Cully <brendan@…>
Branch:
HEAD
Message:

I noticed that my mutt hung when I tried SASL DIGEST-MD5
authentication (I'm not sure when this started). I believe this
patch should solve that problem in a reliable way.

This patch also attempts to reuse connections even when
authentication fails, instead of just throwing away a perfectly good
socket.

Files:
4 modified

Legend:

Unmodified
Added
Removed
  • account.c

    r3423 r3437  
    11/* 
    2  * Copyright (C) 2000 Brendan Cully <brendan@kublai.com> 
     2 * Copyright (C) 2000-3 Brendan Cully <brendan@kublai.com> 
    33 *  
    44 *     This program is free software; you can redistribute it and/or modify 
     
    181181  return 0; 
    182182} 
     183 
     184void mutt_account_unsetpass (ACCOUNT* account) 
     185{ 
     186  account->flags &= !M_ACCT_PASS; 
     187} 
  • account.h

    r2766 r3437  
    11/* 
    2  * Copyright (C) 2000 Brendan Cully <brendan@kublai.com> 
     2 * Copyright (C) 2000-3 Brendan Cully <brendan@kublai.com> 
    33 *  
    44 *     This program is free software; you can redistribute it and/or modify 
     
    5353int mutt_account_getuser (ACCOUNT* account); 
    5454int mutt_account_getpass (ACCOUNT* account); 
     55void mutt_account_unsetpass (ACCOUNT* account); 
    5556 
    5657#endif /* _MUTT_ACCOUNT_H_ */ 
  • imap/auth_sasl.c

    r3421 r3437  
    11/* 
    2  * Copyright (C) 2000-2 Brendan Cully <brendan@kublai.com> 
     2 * Copyright (C) 2000-3 Brendan Cully <brendan@kublai.com> 
    33 *  
    44 *     This program is free software; you can redistribute it and/or modify 
     
    110110  } 
    111111 
    112   mutt_message _("Authenticating (SASL)..."); 
     112  mutt_message (_("Authenticating (%s)..."), mech); 
    113113 
    114114  snprintf (buf, sizeof (buf), "AUTHENTICATE %s", mech); 
     
    154154 
    155155    /* send out response, or line break if none needed */ 
    156     if (pc) 
     156    if (olen) 
    157157    { 
    158158      if (sasl_encode64 (pc, olen, buf, sizeof (buf), &olen) != SASL_OK) 
     
    169169    } 
    170170     
    171     if (olen || rc == SASL_CONTINUE) 
     171    if (irc == IMAP_CMD_RESPOND) 
    172172    { 
    173173      strfcpy (buf + olen, "\r\n", sizeof (buf) - olen); 
  • imap/imap.c

    r3433 r3437  
    341341  /* don't open a new connection if one isn't wanted */ 
    342342  if (flags & M_IMAP_CONN_NONEW) 
    343     if (!idata || idata->state == IMAP_DISCONNECTED) 
    344       goto err_conn; 
     343  { 
     344    if (!idata) 
     345    { 
     346      mutt_socket_free (conn); 
     347      return NULL; 
     348    } 
     349    if (idata->state < IMAP_AUTHENTICATED) 
     350      return NULL; 
     351  } 
    345352   
    346353  if (!idata) 
     
    348355    /* The current connection is a new connection */ 
    349356    if (! (idata = imap_new_idata ())) 
    350       goto err_conn; 
     357    { 
     358      mutt_socket_free (conn); 
     359      return NULL; 
     360    } 
    351361 
    352362    conn->data = idata; 
    353363    idata->conn = conn; 
    354364  } 
     365 
    355366  if (idata->state == IMAP_DISCONNECTED) 
    356     if (imap_open_connection (idata) != 0) 
    357       goto err_idata; 
     367    imap_open_connection (idata); 
     368  if (idata->state == IMAP_CONNECTED) 
     369  { 
     370    if (!imap_authenticate (idata)) 
     371    { 
     372      idata->state = IMAP_AUTHENTICATED; 
     373      if (idata->conn->ssf) 
     374        dprint (2, (debugfile, "Communication encrypted at %d bits\n", 
     375                    idata->conn->ssf)); 
     376      imap_get_delim (idata); 
     377    } 
     378    else 
     379      mutt_account_unsetpass (&idata->conn->account); 
     380     
     381    FREE (&idata->capstr); 
     382  } 
    358383   
    359384  return idata; 
    360  
    361  err_idata: 
    362   imap_free_idata (&idata); 
    363  err_conn: 
    364   mutt_socket_free (conn); 
    365  
    366   return NULL; 
    367385} 
    368386 
     
    376394  idata->state = IMAP_CONNECTED; 
    377395 
    378   if (imap_cmd_step (idata) != IMAP_CMD_CONTINUE) 
    379     goto bail; 
     396  if (imap_cmd_step (idata) != IMAP_CMD_CONTINUE) { 
     397    mutt_error (_("Unexpected response received from server: %s"), idata->cmd.buf); 
     398    mutt_sleep (1); 
     399 
     400    mutt_socket_close (idata->conn); 
     401    idata->state = IMAP_DISCONNECTED; 
     402    return -1; 
     403  } 
    380404 
    381405  if (ascii_strncasecmp ("* OK", idata->cmd.buf, 4) == 0) 
     
    414438    } 
    415439#endif     
    416     if (imap_authenticate (idata)) 
    417       goto bail; 
    418     if (idata->conn->ssf) 
    419       dprint (2, (debugfile, "Communication encrypted at %d bits\n", 
    420         idata->conn->ssf)); 
    421440  } 
    422441  else if (ascii_strncasecmp ("* PREAUTH", idata->cmd.buf, 9) == 0) 
    423442  { 
     443    idata->state = IMAP_AUTHENTICATED; 
    424444    if (imap_check_capabilities (idata) != 0) 
    425445      goto bail; 
     446    FREE (&idata->capstr); 
    426447  }  
    427448  else 
     
    431452  } 
    432453 
    433   FREE (&idata->capstr); 
    434   idata->state = IMAP_AUTHENTICATED; 
    435  
    436   imap_get_delim (idata); 
    437454  return 0; 
    438455 
     
    441458 bail: 
    442459  FREE (&idata->capstr); 
    443   idata->state = IMAP_DISCONNECTED; 
    444460  return -1; 
    445461} 
     
    521537  if (!(idata = imap_conn_find (&(mx.account), M_IMAP_CONN_NOSELECT))) 
    522538    goto fail_noidata; 
     539  if (idata->state < IMAP_AUTHENTICATED) 
     540    goto fail; 
     541 
    523542  conn = idata->conn; 
    524543