]> granicus.if.org Git - neomutt/commitdiff
More IMAP clean-up.
authorThomas Roessler <roessler@does-not-exist.org>
Thu, 6 Jul 2000 18:40:53 +0000 (18:40 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Thu, 6 Jul 2000 18:40:53 +0000 (18:40 +0000)
imap/auth.c
imap/auth_gss.c
imap/browse.c
imap/command.c
imap/imap.c
imap/imap_private.h
imap/imap_socket.h
imap/message.c
imap/socket.c

index c729da5dbd31653878e753b8dc904cf94f4b950a..0f6254d2cf4bab8d1863468a7e365da800d6afb3 100644 (file)
@@ -98,7 +98,7 @@ static int imap_auth_cram_md5 (IMAP_DATA* idata, const char* user,
   char ibuf[LONG_STRING], obuf[LONG_STRING];
   unsigned char hmac_response[MD5_DIGEST_LEN];
   int len;
-  char seq[16];
+  char seq[SEQLEN+1];
 
   dprint (2, (debugfile, "Attempting CRAM-MD5 login...\n"));
   mutt_message _("Authenticating (CRAM-MD5)...");
@@ -112,7 +112,7 @@ static int imap_auth_cram_md5 (IMAP_DATA* idata, const char* user,
    * primary host name of the server. The syntax of the unencoded form must
    * correspond to that of an RFC 822 'msg-id' [RFC822] as described in [POP3].
    */
-  if (mutt_socket_read_line_d (ibuf, LONG_STRING, idata->conn) < 0)
+  if (mutt_socket_readln (ibuf, LONG_STRING, idata->conn) < 0)
   {
     dprint (1, (debugfile, "Error receiving server response.\n"));
 
@@ -162,7 +162,7 @@ static int imap_auth_cram_md5 (IMAP_DATA* idata, const char* user,
   strcpy (ibuf + strlen (ibuf), "\r\n");
   mutt_socket_write (idata->conn, ibuf);
 
-  if (mutt_socket_read_line_d (ibuf, LONG_STRING, idata->conn) < 0)
+  if (mutt_socket_readln (ibuf, LONG_STRING, idata->conn) < 0)
   {
     dprint (1, (debugfile, "Error receiving server response.\n"));
 
@@ -185,7 +185,7 @@ static int imap_auth_cram_md5 (IMAP_DATA* idata, const char* user,
 static int imap_auth_anon (IMAP_DATA* idata)
 {
   char ibuf[LONG_STRING], obuf[LONG_STRING];
-  char seq[16];
+  char seq[SEQLEN+1];
 
   dprint (2, (debugfile, "Attempting anonymous login...\n"));
   mutt_message _("Authenticating (anonymous)...");
@@ -193,7 +193,7 @@ static int imap_auth_anon (IMAP_DATA* idata)
   snprintf (obuf, LONG_STRING, "%s AUTHENTICATE ANONYMOUS\r\n", seq);
   mutt_socket_write (idata->conn, obuf);
 
-  if (mutt_socket_read_line_d (ibuf, LONG_STRING, idata->conn) < 0)
+  if (mutt_socket_readln (ibuf, LONG_STRING, idata->conn) < 0)
   {
     dprint (1, (debugfile, "Error receiving server response.\n"));
 
@@ -211,7 +211,7 @@ static int imap_auth_anon (IMAP_DATA* idata)
 
   mutt_socket_write (idata->conn, ibuf);
 
-  if (mutt_socket_read_line_d (ibuf, LONG_STRING, idata->conn) < 0)
+  if (mutt_socket_readln (ibuf, LONG_STRING, idata->conn) < 0)
   {
     dprint (1, (debugfile, "Error receiving server response.\n"));
 
@@ -352,12 +352,11 @@ int imap_authenticate (IMAP_DATA *idata, CONNECTION *conn)
       if (!ImapPass)
       {
        pass[0]=0;
-       snprintf (buf, sizeof (buf), _("Password for %s@%s: "), user, conn->mx.host);
+       snprintf (buf, sizeof (buf), _("Password for %s@%s: "), user,
+          conn->mx.host);
        if (mutt_get_field (buf, pass, sizeof (pass), M_PASS) != 0 ||
            !pass[0])
-       {
-         return (-1);
-       }
+         return -1;
       }
       else
        strfcpy (pass, ImapPass, sizeof (pass));
@@ -369,8 +368,18 @@ int imap_authenticate (IMAP_DATA *idata, CONNECTION *conn)
     imap_quote_string (q_pass, sizeof (q_pass), pass);
 
     mutt_message _("Logging in...");
+
+#ifdef DEBUG
+    /* don't print the password unless we're at the ungodly debugging level
+     * of 5 or higher */
+
+    if (debuglevel < IMAP_LOG_PASS)
+      dprint (2, (debugfile, "Sending LOGIN command for %s...\n", user));
+#endif
+
     snprintf (buf, sizeof (buf), "LOGIN %s %s", q_user, q_pass);
-    r = imap_exec (buf, sizeof (buf), idata, buf, IMAP_OK_FAIL);
+    r = imap_exec (buf, sizeof (buf), idata, buf,
+      IMAP_CMD_FAIL_OK | IMAP_CMD_PASS);
     if (r == -1)
     {
       /* connection or protocol problem */
index 1b3e855045e45deb99c31855cae9654809f4aa08..d334a0ad35791fe06ddf2f6430c75f7bde8a16c1 100644 (file)
@@ -86,7 +86,7 @@ int imap_auth_gss (IMAP_DATA* idata, const char* user)
   mutt_socket_write (idata->conn, buf1);
 
   /* expect a null continuation response ("+") */
-  if (mutt_socket_read_line_d (buf1, sizeof (buf1), idata->conn) < 0)
+  if (mutt_socket_readln (buf1, sizeof (buf1), idata->conn) < 0)
   {
     dprint (1, (debugfile, "Error receiving server response.\n"));
     gss_release_name (&min_stat, &target_name);
@@ -128,7 +128,7 @@ int imap_auth_gss (IMAP_DATA* idata, const char* user)
       gss_release_name (&min_stat, &target_name);
       /* end authentication attempt */
       mutt_socket_write (idata->conn, "*\r\n");
-      mutt_socket_read_line_d (buf1, sizeof (buf1), idata->conn);
+      mutt_socket_readln (buf1, sizeof (buf1), idata->conn);
 
       return -1;
     }
@@ -142,7 +142,7 @@ int imap_auth_gss (IMAP_DATA* idata, const char* user)
 
     if (maj_stat == GSS_S_CONTINUE_NEEDED)
     {
-      if (mutt_socket_read_line_d (buf1, sizeof (buf1), idata->conn) < 0)
+      if (mutt_socket_readln (buf1, sizeof (buf1), idata->conn) < 0)
       {
         dprint (1, (debugfile, "Error receiving server response.\n"));
         gss_release_name (&min_stat, &target_name);
@@ -160,7 +160,7 @@ int imap_auth_gss (IMAP_DATA* idata, const char* user)
   gss_release_name (&min_stat, &target_name);
 
   /* get security flags and buffer size */
-  if (mutt_socket_read_line_d (buf1, sizeof (buf1), idata->conn) < 0)
+  if (mutt_socket_readln (buf1, sizeof (buf1), idata->conn) < 0)
   {
     dprint (1, (debugfile, "Error receiving server response.\n"));
 
@@ -226,7 +226,7 @@ int imap_auth_gss (IMAP_DATA* idata, const char* user)
   mutt_socket_write (idata->conn, buf1);
 
   /* Joy of victory or agony of defeat? */
-  if (mutt_socket_read_line_d (buf1, GSS_BUFSIZE, idata->conn) < 0)
+  if (mutt_socket_readln (buf1, GSS_BUFSIZE, idata->conn) < 0)
   {
     dprint (1, (debugfile, "Error receiving server response.\n"));
 
index 5e6c85b6429bdbc062a23a32c86945e1efd5acce..f08414b8c72b094a421f275c89c43e4b7d39d375 100644 (file)
@@ -394,7 +394,7 @@ static int get_namespace (IMAP_DATA *idata, char *nsbuf, int nsblen,
   mutt_socket_write (idata->conn, buf);
   do 
   {
-    if (mutt_socket_read_line_d (buf, sizeof (buf), idata->conn) < 0)
+    if (mutt_socket_readln (buf, sizeof (buf), idata->conn) < 0)
       return -1;
 
     if (buf[0] == '*') 
index 28c6bee9c8f879c98006043cd7b333d5cd31031b..977636701b48e990c14ee36ff150d102858baadf 100644 (file)
@@ -101,9 +101,11 @@ int imap_code (const char *s)
 }
 
 /* imap_exec: execute a command, and wait for the response from the server.
- * Also, handle untagged responses
- * If flags == IMAP_OK_FAIL, then the calling procedure can handle a response 
- * failing, this is used for checking for a mailbox on append and login
+ * Also, handle untagged responses.
+ * Flags:
+ *   IMAP_CMD_FAIL_OK: the calling procedure can handle failure. This is used
+ *     for checking for a mailbox on append and login
+ *   IMAP_CMD_PASS: command contains a password. Suppress logging.
  * Return 0 on success, -1 on Failure, -2 on OK Failure
  */
 int imap_exec (char* buf, size_t buflen, IMAP_DATA* idata, const char* cmd,
@@ -120,17 +122,18 @@ int imap_exec (char* buf, size_t buflen, IMAP_DATA* idata, const char* cmd,
   out = (char*) safe_malloc (outlen);
   snprintf (out, outlen, "%s %s\r\n", seq, cmd);
 
-  mutt_socket_write (idata->conn, out);
+  mutt_socket_write_d (idata->conn, out,
+    flags & IMAP_CMD_PASS ? IMAP_LOG_PASS : IMAP_LOG_CMD);
 
   safe_free ((void**) &out);
 
   do
   {
-    if (mutt_socket_read_line_d (buf, buflen, idata->conn) < 0)
-      return (-1);
+    if (mutt_socket_readln (buf, buflen, idata->conn) < 0)
+      return -1;
 
     if (buf[0] == '*' && imap_handle_untagged (idata, buf) != 0)
-      return (-1);
+      return -1;
   }
   while (mutt_strncmp (buf, seq, SEQLEN) != 0);
 
@@ -140,15 +143,17 @@ int imap_exec (char* buf, size_t buflen, IMAP_DATA* idata, const char* cmd,
   {
     char *pc;
 
-    if (flags == IMAP_OK_FAIL)
-      return (-2);
-    dprint (1, (debugfile, "imap_exec(): command failed: %s\n", buf));
+    if (flags & IMAP_CMD_FAIL_OK)
+      return -2;
+
+    dprint (1, (debugfile, "imap_exec: command failed: %s\n", buf));
     pc = buf + SEQLEN;
     SKIPWS (pc);
     pc = imap_next_word (pc);
     mutt_error (pc);
     sleep (1);
-    return (-1);
+
+    return -1;
   }
 
   return 0;
index 67a8ebbce4bdd86f6b3acb46909af1626eb402f6..7ca19053fd24a2f94e7fb55eed9a5d39d50772eb 100644 (file)
@@ -127,9 +127,10 @@ int imap_read_bytes (FILE *fp, CONNECTION *conn, long bytes)
 
   for (pos = 0; pos < bytes; )
   {
-    len = mutt_socket_read_line (buf, sizeof (buf), conn);
+    len = mutt_socket_readln_d (buf, sizeof (buf), conn, IMAP_LOG_HDR);
     if (len < 0)
-      return (-1);
+      return -1;
+
     pos += len;
     fputs (buf, fp);
     fputs ("\n", fp);
@@ -212,7 +213,7 @@ int imap_reopen_mailbox (CONTEXT *ctx, int *index_hint)
 
   do
   {
-    if (mutt_socket_read_line_d (buf, sizeof (buf), CTX_DATA->conn) < 0)
+    if (mutt_socket_readln (buf, sizeof (buf), CTX_DATA->conn) < 0)
       break;
 
     if (buf[0] == '*')
@@ -353,7 +354,7 @@ static int imap_get_delim (IMAP_DATA *idata, CONNECTION *conn)
 
   do 
   {
-    if (mutt_socket_read_line_d (buf, sizeof (buf), conn) < 0)
+    if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
     {
       return (-1);
     }
@@ -426,7 +427,7 @@ int imap_open_connection (IMAP_DATA *idata, CONNECTION *conn)
 
   idata->state = IMAP_CONNECTED;
 
-  if (mutt_socket_read_line_d (buf, sizeof (buf), conn) < 0)
+  if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
   {
     mutt_socket_close (conn);
     idata->state = IMAP_DISCONNECTED;
@@ -590,7 +591,7 @@ int imap_open_mailbox (CONTEXT *ctx)
   {
     char *pc;
     
-    if (mutt_socket_read_line_d (buf, sizeof (buf), conn) < 0)
+    if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
       break;
 
     if (buf[0] == '*')
@@ -791,30 +792,27 @@ int imap_open_mailbox_append (CONTEXT *ctx)
   }
   else
   {
-    /* STATUS not supported
-     * The thing to do seems to be:
-     *  - Open a *new* IMAP session, select, and then close it. Report the
-     * error if the mailbox did not exist. */
+    /* STATUS not supported */
     mutt_message _("Unable to append to IMAP mailboxes at this server");
+
     return -1;
   }
 
-  r = imap_exec (buf, sizeof (buf), idata, buf, IMAP_OK_FAIL);
+  r = imap_exec (buf, sizeof (buf), idata, buf, IMAP_CMD_FAIL_OK);
   if (r == -2)
   {
     /* command failed cause folder doesn't exist */
     snprintf (buf, sizeof (buf), _("Create %s?"), mailbox);
     if (option (OPTCONFIRMCREATE) && mutt_yesorno (buf, 1) < 1)
-      return (-1);
+      return -1;
 
     if (imap_create_mailbox (ctx, mailbox) < 0)
-      return (-1);
+      return -1;
   }
   else if (r == -1)
-  {
     /* Hmm, some other failure */
     return -1;
-  }
+
   return 0;
 }
 
@@ -833,7 +831,7 @@ int imap_close_connection (CONTEXT *ctx)
     mutt_socket_write (CTX_DATA->conn, buf);
     do
     {
-      if (mutt_socket_read_line_d (buf, sizeof (buf), CTX_DATA->conn) < 0)
+      if (mutt_socket_readln (buf, sizeof (buf), CTX_DATA->conn) < 0)
        break;
     }
     while (mutt_strncmp (seq, buf, SEQLEN) != 0);
@@ -1254,7 +1252,7 @@ int imap_mailbox_check (char *path, int new)
 
   do 
   {
-    if (mutt_socket_read_line_d (buf, sizeof (buf), conn) < 0)
+    if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
       return -1;
 
     if (buf[0] == '*') 
@@ -1300,10 +1298,9 @@ int imap_parse_list_response(CONNECTION *conn, char *buf, int buflen,
   long bytes;
 
   *name = NULL;
-  if (mutt_socket_read_line_d (buf, buflen, conn) < 0)
-  {
-    return (-1);
-  }
+
+  if (mutt_socket_readln (buf, buflen, conn) < 0)
+    return -1;
 
   if (buf[0] == '*')
   {
@@ -1349,10 +1346,10 @@ int imap_parse_list_response(CONNECTION *conn, char *buf, int buflen,
        int len;
        
        if (imap_get_literal_count(buf, &bytes) < 0)
-         return (-1);
-       len = mutt_socket_read_line (buf, buflen, conn);
+         return -1;
+       len = mutt_socket_readln (buf, buflen, conn);
        if (len < 0)
-         return (-1);
+         return -1;
        *name = buf;
       }
       else
@@ -1361,10 +1358,11 @@ int imap_parse_list_response(CONNECTION *conn, char *buf, int buflen,
     else
     {
       if (imap_handle_untagged (idata, buf) != 0)
-       return (-1);
+       return -1;
     }
   }
-  return (0);
+
+  return 0;
 }
 
 int imap_subscribe (char *path, int subscribe)
index ae5847daa308bea4e7978a07d274781b26ceafdf..08fd34128f83db0100b770494cb67ad56de2985d 100644 (file)
 #define IMAP_PORT 143
 #define IMAP_SSL_PORT 993
 
+/* logging levels */
+#define IMAP_LOG_CMD  2
+#define IMAP_LOG_HDR  3
+#define IMAP_LOG_BODY 4
+#define IMAP_LOG_PASS 5
+
 /* number of entries in the hash table */
 #define IMAP_CACHE_LEN 10
 
 #define IMAP_REOPEN_PENDING  (1<<1)
 #define IMAP_NEWMAIL_PENDING (1<<2)
 
+/* imap_exec flags (see imap_exec) */
+#define IMAP_CMD_FAIL_OK (1<<0)
+#define IMAP_CMD_PASS    (1<<1)
+
 enum
 {
   IMAP_FATAL = 1,
   IMAP_NEW_MAIL,
   IMAP_EXPUNGE,
   IMAP_BYE,
-  IMAP_OK_FAIL,
   IMAP_REOPENED,
   IMAP_LOGOUT
 };
index d868fd6e48aa9a76e42f27e10bacfffc1720cf83..a5145427bac063e2c68ab95be654f03e95993ff3 100644 (file)
 typedef struct _connection
 {
   IMAP_MBOX mx;
-  char *preconnect; /* Actually specific to server, not connection */
-  int fd;
   char inbuf[LONG_STRING];
   int bufpos;
+
+  int fd;
   int available;
   void *data;
+
   struct _connection *next;
 
   void *sockdata;
@@ -38,15 +39,17 @@ typedef struct _connection
   int (*close) (struct _connection *conn);
 
   /* status bits */
-  int up : 1;
+  
+  int up : 1; /* is the connection up? */
 } CONNECTION;
 
 int mutt_socket_open (CONNECTION* conn);
 int mutt_socket_close (CONNECTION* conn);
 int mutt_socket_readchar (CONNECTION *conn, char *c);
-int mutt_socket_read_line (char *buf, size_t buflen, CONNECTION *conn);
-int mutt_socket_read_line_d (char *buf, size_t buflen, CONNECTION *conn);
-int mutt_socket_write (CONNECTION *conn, const char *buf);
+#define mutt_socket_readln(A,B,C) mutt_socket_readln_d(A,B,C,IMAP_LOG_CMD)
+int mutt_socket_readln_d (char *buf, size_t buflen, CONNECTION *conn, int dbg);
+#define mutt_socket_write(A,B) mutt_socket_write_d(A,B,IMAP_LOG_CMD);
+int mutt_socket_write_d (CONNECTION *conn, const char *buf, int dbg);
 
 CONNECTION* mutt_socket_find (const IMAP_MBOX* mx, int newconn);
 
index 197edba25d64d41b035b47dde09495d4d1902c14..c6b46b7f104be82264fecb7e5a23d7ae9bd3a856 100644 (file)
@@ -116,7 +116,7 @@ int imap_read_headers (CONTEXT *ctx, int msgbegin, int msgend)
 
     do
     {
-      if (mutt_socket_read_line_d (buf, sizeof (buf), CTX_DATA->conn) < 0)
+      if (mutt_socket_readln (buf, sizeof (buf), CTX_DATA->conn) < 0)
       {
        fclose (fp);
         return -1;
@@ -174,7 +174,7 @@ int imap_read_headers (CONTEXT *ctx, int msgbegin, int msgend)
             * (eg Domino puts FLAGS here). Nothing wrong with that, either.
             * This all has to go - we should accept literals and nonliterals
             * interchangeably at any time. */
-           if (mutt_socket_read_line_d (buf, sizeof (buf), CTX_DATA->conn)
+           if (mutt_socket_readln (buf, sizeof (buf), CTX_DATA->conn)
                < 0)
            {
              fclose (fp);
@@ -324,7 +324,7 @@ int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
   mutt_socket_write (CTX_DATA->conn, buf);
   do
   {
-    if (mutt_socket_read_line_d (buf, sizeof (buf), CTX_DATA->conn) < 0)
+    if (mutt_socket_readln (buf, sizeof (buf), CTX_DATA->conn) < 0)
       goto bail;
 
     if (buf[0] == '*')
@@ -350,14 +350,16 @@ int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
            }
            for (pos = 0; pos < bytes; )
            {
-             len = mutt_socket_read_line (buf, sizeof (buf), CTX_DATA->conn);
+             len = mutt_socket_readln_d (buf, sizeof (buf), CTX_DATA->conn,
+                3);
              if (len < 0)
                goto bail;
              pos += len;
              fputs (buf, msg->fp);
              fputs ("\n", msg->fp);
            }
-           if (mutt_socket_read_line (buf, sizeof (buf), CTX_DATA->conn) < 0)
+           if (mutt_socket_readln_d (buf, sizeof (buf), CTX_DATA->conn, 3)
+                < 0)
              goto bail;
            pc = buf;
          }
@@ -455,7 +457,8 @@ bail:
     unlink (cache->path);
     FREE (&cache->path);
   }
-  return (-1);
+
+  return -1;
 }
 
 int imap_append_message (CONTEXT *ctx, MESSAGE *msg)
@@ -499,7 +502,7 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg)
 
   do 
   {
-    if (mutt_socket_read_line_d (buf, sizeof (buf), CTX_DATA->conn) < 0)
+    if (mutt_socket_readln (buf, sizeof (buf), CTX_DATA->conn) < 0)
     {
       fclose (fp);
       return (-1);
@@ -549,7 +552,7 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg)
 
   do
   {
-    if (mutt_socket_read_line_d (buf, sizeof (buf), CTX_DATA->conn) < 0)
+    if (mutt_socket_readln (buf, sizeof (buf), CTX_DATA->conn) < 0)
       return (-1);
 
     if (buf[0] == '*' && imap_handle_untagged (CTX_DATA, buf) != 0)
@@ -624,7 +627,7 @@ int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete)
   /* let's get it on */
   strncpy (mbox, cmd, sizeof (mbox));
   snprintf (cmd, sizeof (cmd), "COPY %s \"%s\"", buf, mbox);
-  rc = imap_exec (buf, sizeof (buf), CTX_DATA, cmd, IMAP_OK_FAIL);
+  rc = imap_exec (buf, sizeof (buf), CTX_DATA, cmd, IMAP_CMD_FAIL_OK);
   if (rc == -2)
   {
     /* bail out if command failed for reasons other than nonexistent target */
index adf7b3e580268590dda48f39ee03c5288d7418d3..d06131565505ba3c2da1580833c7cadff2c34038 100644 (file)
@@ -62,9 +62,10 @@ int mutt_socket_close (CONNECTION* conn)
   return conn->close (conn);
 }
 
-int mutt_socket_write (CONNECTION *conn, const char *buf)
+int mutt_socket_write_d (CONNECTION *conn, const char *buf, int dbg)
 {
-  dprint (1,(debugfile,"> %s", buf));
+  dprint (dbg, (debugfile,"> %s", buf));
+
   return conn->write (conn, buf);
 }
 
@@ -83,7 +84,7 @@ int mutt_socket_readchar (CONNECTION *conn, char *c)
   return 1;
 }
 
-int mutt_socket_read_line (char *buf, size_t buflen, CONNECTION *conn)
+int mutt_socket_readln_d (char* buf, size_t buflen, CONNECTION* conn, int dbg)
 {
   char ch;
   int i;
@@ -100,14 +101,10 @@ int mutt_socket_read_line (char *buf, size_t buflen, CONNECTION *conn)
     buf[i-1] = '\0';
   else
     buf[i] = '\0';
-  return (i + 1);
-}
 
-int mutt_socket_read_line_d (char *buf, size_t buflen, CONNECTION *conn)
-{
-  int r = mutt_socket_read_line (buf, buflen, conn);
-  dprint (1,(debugfile,"< %s\n", buf));
-  return r;
+  dprint (dbg, (debugfile, "< %s\n", buf));
+  
+  return (i + 1);
 }
 
 CONNECTION* mutt_socket_find (const IMAP_MBOX* mx, int newconn)
@@ -174,7 +171,7 @@ void imap_logout_all (void)
 
       do
       {
-       if (mutt_socket_read_line_d (buf, sizeof (buf), conn) < 0)
+       if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
          break;
       }
       while (mutt_strncmp (buf, seq, SEQLEN) != 0);
@@ -229,7 +226,6 @@ static CONNECTION* socket_new_conn ()
   CONNECTION* conn;
 
   conn = (CONNECTION *) safe_calloc (1, sizeof (CONNECTION));
-  conn->preconnect = safe_strdup (ImapPreconnect);
   conn->fd = -1;
 
   return conn;
@@ -257,8 +253,7 @@ int raw_socket_open (CONNECTION *conn)
   struct sockaddr_in sin;
   struct hostent *he;
   int    verbose;
-  char *pc = conn->preconnect;
-  int  do_preconnect = (pc && strlen (pc) > 0);
+  int  do_preconnect = mutt_strlen (ImapPreconnect) > 0;
   /* This might be a config variable */
   int first_try_without_preconnect = TRUE; 
 
@@ -286,15 +281,16 @@ int raw_socket_open (CONNECTION *conn)
   {
     int ret;
 
-    dprint (1,(debugfile,"Preconnect to server %s:\n", conn->mx.host));
-    dprint (1,(debugfile,"\t%s\n", conn->preconnect));
+    dprint (1, (debugfile, "Preconnect to server %s:\n", conn->mx.host));
+    dprint (1, (debugfile, "\t%s\n", ImapPreconnect));
     /* Execute preconnect command */
-    ret = mutt_system (conn->preconnect) < 0;
-    dprint (1,(debugfile,"\t%s: %d\n", "Exit status", ret));
+    ret = mutt_system (ImapPreconnect) < 0;
+    dprint (1, (debugfile, "\t%s: %d\n", "Exit status", ret));
     if (ret < 0)
     {
-      mutt_perror(_("preconnect command failed"));
+      mutt_perror (_("IMAP Preconnect command failed"));
       sleep (1);
+
       return ret;
     }
   }