]> granicus.if.org Git - curl/commitdiff
email: Post graceful SASL authentication cancellation tidy up
authorSteve Holme <steve_holme@hotmail.com>
Wed, 30 Oct 2013 20:56:38 +0000 (20:56 +0000)
committerSteve Holme <steve_holme@hotmail.com>
Wed, 30 Oct 2013 20:58:24 +0000 (20:58 +0000)
RELEASE-NOTES
lib/curl_sasl.c
lib/imap.c
lib/pop3.c
lib/smtp.c

index 3d4b2278c93b0c15c26df4e9459786c4a09cde5a..0a9b3f802212b62dfc3bb633298b0c4f0f953d19 100644 (file)
@@ -10,9 +10,7 @@ Curl and libcurl 7.33.1
 This release includes the following changes:
 
  o SSL: protocol version can be specified more precisely [1]
- o email: Added support for cancelling NTLM authentication
- o email: Added support for cancelling DIGEST-MD5 authentication
- o email: Added support for canceling CRAM-MD5 authentication
+ o imap/pop3/smtp: Added graceful cancellation of SASL authentication
  o Add "Happy Eyeballs" for IPv4/IPv6 dual connect attempts
 
 This release includes the following bugfixes:
index 09234da10d47a1c0798267e30d3fd419a0610de3..57a09ff35a0fdd54f56b92330373e50e8b3200d8 100644 (file)
@@ -559,14 +559,14 @@ CURLcode Curl_sasl_create_ntlm_type3_message(struct SessionHandle *data,
 /*
  * Curl_sasl_create_xoauth2_message()
  *
- * This is used to generate an already encoded XOAUTH2 message ready
- * for sending to the recipient.
+ * This is used to generate an already encoded OAuth 2.0 message ready for
+ * sending to the recipient.
  *
  * Parameters:
  *
  * data    [in]     - The session handle.
  * user    [in]     - The user name.
- * bearer  [in]     - The XOAUTH Bearer token.
+ * bearer  [in]     - The bearer token.
  * outptr  [in/out] - The address where a pointer to newly allocated memory
  *                    holding the result will be stored upon completion.
  * outlen  [out]    - The length of the output message.
@@ -579,16 +579,15 @@ CURLcode Curl_sasl_create_xoauth2_message(struct SessionHandle *data,
                                           char **outptr, size_t *outlen)
 {
   CURLcode result = CURLE_OK;
-  char *xoauth;
+  char *xoauth = NULL;
 
+  /* Generate the message */
   xoauth = aprintf("user=%s\1auth=Bearer %s\1\1", user, bearer);
-
   if(!xoauth)
     return CURLE_OUT_OF_MEMORY;
 
   /* Base64 encode the reply */
-  result = Curl_base64_encode(data, xoauth, strlen(xoauth), outptr,
-                              outlen);
+  result = Curl_base64_encode(data, xoauth, strlen(xoauth), outptr, outlen);
 
   Curl_safefree(xoauth);
 
index c11e43bd661658c94c5b4dab695ce62d0cdfec95..60e7489df3ddc7910e7632d01d7c4feb5d0d6c6f 100644 (file)
@@ -1007,20 +1007,17 @@ static CURLcode imap_state_auth_plain_resp(struct connectdata *conn,
     /* Create the authorisation message */
     result = Curl_sasl_create_plain_message(data, conn->user, conn->passwd,
                                             &plainauth, &len);
+    if(!result && plainauth) {
+      /* Send the message */
+      result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", plainauth);
 
-    /* Send the message */
-    if(!result) {
-      if(plainauth) {
-        result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", plainauth);
-
-        if(!result)
-          state(conn, IMAP_AUTHENTICATE_FINAL);
-      }
-
-      Curl_safefree(plainauth);
+      if(!result)
+        state(conn, IMAP_AUTHENTICATE_FINAL);
     }
   }
 
+  Curl_safefree(plainauth);
+
   return result;
 }
 
@@ -1044,20 +1041,17 @@ static CURLcode imap_state_auth_login_resp(struct connectdata *conn,
     /* Create the user message */
     result = Curl_sasl_create_login_message(data, conn->user,
                                             &authuser, &len);
+    if(!result && authuser) {
+      /* Send the user */
+      result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", authuser);
 
-    /* Send the user */
-    if(!result) {
-      if(authuser) {
-        result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", authuser);
-
-        if(!result)
-          state(conn, IMAP_AUTHENTICATE_LOGIN_PASSWD);
-      }
-
-      Curl_safefree(authuser);
+      if(!result)
+        state(conn, IMAP_AUTHENTICATE_LOGIN_PASSWD);
     }
   }
 
+  Curl_safefree(authuser);
+
   return result;
 }
 
@@ -1081,20 +1075,17 @@ static CURLcode imap_state_auth_login_password_resp(struct connectdata *conn,
     /* Create the password message */
     result = Curl_sasl_create_login_message(data, conn->passwd,
                                             &authpasswd, &len);
+    if(!result && authpasswd) {
+      /* Send the password */
+      result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", authpasswd);
 
-    /* Send the password */
-    if(!result) {
-      if(authpasswd) {
-        result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", authpasswd);
-
-        if(!result)
-          state(conn, IMAP_AUTHENTICATE_FINAL);
-      }
-
-      Curl_safefree(authpasswd);
+      if(!result)
+        state(conn, IMAP_AUTHENTICATE_FINAL);
     }
   }
 
+  Curl_safefree(authpasswd);
+
   return result;
 }
 
@@ -1252,20 +1243,17 @@ static CURLcode imap_state_auth_ntlm_resp(struct connectdata *conn,
     result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd,
                                                  &conn->ntlm,
                                                  &type1msg, &len);
+    if(!result && type1msg) {
+      /* Send the message */
+      result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", type1msg);
 
-    /* Send the message */
-    if(!result) {
-      if(type1msg) {
-        result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", type1msg);
-
-        if(!result)
-          state(conn, IMAP_AUTHENTICATE_NTLM_TYPE2MSG);
-      }
-
-      Curl_safefree(type1msg);
+      if(!result)
+        state(conn, IMAP_AUTHENTICATE_NTLM_TYPE2MSG);
     }
   }
 
+  Curl_safefree(type1msg);
+
   return result;
 }
 
@@ -1341,20 +1329,17 @@ static CURLcode imap_state_auth_xoauth2_resp(struct connectdata *conn,
     result = Curl_sasl_create_xoauth2_message(conn->data, conn->user,
                                               conn->xoauth2_bearer,
                                               &xoauth, &len);
+    if(!result && xoauth) {
+      /* Send the message */
+      result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", xoauth);
 
-    /* Send the message */
-    if(!result) {
-      if(xoauth) {
-        result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", xoauth);
-
-        if(!result)
-          state(conn, IMAP_AUTHENTICATE_FINAL);
-      }
-
-      Curl_safefree(xoauth);
+      if(!result)
+        state(conn, IMAP_AUTHENTICATE_FINAL);
     }
   }
 
+  Curl_safefree(xoauth);
+
   return result;
 }
 
index b22d66e05805a3b7dafd6e26b109ee17d61d64af..cc067d67cdb26bbabcbf2fff1a10ce831c0dc5c6 100644 (file)
@@ -865,20 +865,17 @@ static CURLcode pop3_state_auth_plain_resp(struct connectdata *conn,
     /* Create the authorisation message */
     result = Curl_sasl_create_plain_message(data, conn->user, conn->passwd,
                                             &plainauth, &len);
+    if(!result && plainauth) {
+      /* Send the message */
+      result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", plainauth);
 
-    /* Send the message */
-    if(!result) {
-      if(plainauth) {
-        result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", plainauth);
-
-        if(!result)
-          state(conn, POP3_AUTH_FINAL);
-      }
-
-      Curl_safefree(plainauth);
+      if(!result)
+        state(conn, POP3_AUTH_FINAL);
     }
   }
 
+  Curl_safefree(plainauth);
+
   return result;
 }
 
@@ -902,20 +899,17 @@ static CURLcode pop3_state_auth_login_resp(struct connectdata *conn,
     /* Create the user message */
     result = Curl_sasl_create_login_message(data, conn->user,
                                             &authuser, &len);
+    if(!result && authuser) {
+      /* Send the user */
+      result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", authuser);
 
-    /* Send the user */
-    if(!result) {
-      if(authuser) {
-        result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", authuser);
-
-        if(!result)
-          state(conn, POP3_AUTH_LOGIN_PASSWD);
-      }
-
-      Curl_safefree(authuser);
+      if(!result)
+        state(conn, POP3_AUTH_LOGIN_PASSWD);
     }
   }
 
+  Curl_safefree(authuser);
+
   return result;
 }
 
@@ -939,20 +933,17 @@ static CURLcode pop3_state_auth_login_password_resp(struct connectdata *conn,
     /* Create the password message */
     result = Curl_sasl_create_login_message(data, conn->passwd,
                                             &authpasswd, &len);
+    if(!result && authpasswd) {
+      /* Send the password */
+      result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", authpasswd);
 
-    /* Send the password */
-    if(!result) {
-      if(authpasswd) {
-        result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", authpasswd);
-
-        if(!result)
-          state(conn, POP3_AUTH_FINAL);
-      }
-
-      Curl_safefree(authpasswd);
+      if(!result)
+        state(conn, POP3_AUTH_FINAL);
     }
   }
 
+  Curl_safefree(authpasswd);
+
   return result;
 }
 
@@ -1110,20 +1101,17 @@ static CURLcode pop3_state_auth_ntlm_resp(struct connectdata *conn,
     result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd,
                                                  &conn->ntlm,
                                                  &type1msg, &len);
+    if(!result && type1msg) {
+      /* Send the message */
+      result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", type1msg);
 
-    /* Send the message */
-    if(!result) {
-      if(type1msg) {
-        result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", type1msg);
-
-        if(!result)
-          state(conn, POP3_AUTH_NTLM_TYPE2MSG);
-      }
-
-      Curl_safefree(type1msg);
+      if(!result)
+        state(conn, POP3_AUTH_NTLM_TYPE2MSG);
     }
   }
 
+  Curl_safefree(type1msg);
+
   return result;
 }
 
@@ -1198,20 +1186,17 @@ static CURLcode pop3_state_auth_xoauth2_resp(struct connectdata *conn,
     result = Curl_sasl_create_xoauth2_message(conn->data, conn->user,
                                               conn->xoauth2_bearer,
                                               &xoauth, &len);
+    if(!result && xoauth) {
+      /* Send the message */
+      result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", xoauth);
 
-    /* Send the message */
-    if(!result) {
-      if(xoauth) {
-        result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", xoauth);
-
-        if(!result)
-          state(conn, POP3_AUTH_FINAL);
-      }
-
-      Curl_safefree(xoauth);
+      if(!result)
+        state(conn, POP3_AUTH_FINAL);
     }
   }
 
+  Curl_safefree(xoauth);
+
   return result;
 }
 
index 19fe4ff6e0a5e3b2899aa42b862939ef1c9334b1..9ed0e00574a758ea540c11e653bf28405870f54a 100644 (file)
@@ -845,20 +845,17 @@ static CURLcode smtp_state_auth_plain_resp(struct connectdata *conn,
     /* Create the authorisation message */
     result = Curl_sasl_create_plain_message(conn->data, conn->user,
                                             conn->passwd, &plainauth, &len);
+    if(!result && plainauth) {
+      /* Send the message */
+      result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", plainauth);
 
-    /* Send the message */
-    if(!result) {
-      if(plainauth) {
-        result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", plainauth);
-
-        if(!result)
-          state(conn, SMTP_AUTH_FINAL);
-      }
-
-      Curl_safefree(plainauth);
+      if(!result)
+        state(conn, SMTP_AUTH_FINAL);
     }
   }
 
+  Curl_safefree(plainauth);
+
   return result;
 }
 
@@ -882,20 +879,17 @@ static CURLcode smtp_state_auth_login_resp(struct connectdata *conn,
     /* Create the user message */
     result = Curl_sasl_create_login_message(conn->data, conn->user,
                                             &authuser, &len);
+    if(!result && authuser) {
+      /* Send the user */
+      result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", authuser);
 
-    /* Send the user */
-    if(!result) {
-      if(authuser) {
-        result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", authuser);
-
-        if(!result)
-          state(conn, SMTP_AUTH_LOGIN_PASSWD);
-      }
-
-      Curl_safefree(authuser);
+      if(!result)
+        state(conn, SMTP_AUTH_LOGIN_PASSWD);
     }
   }
 
+  Curl_safefree(authuser);
+
   return result;
 }
 
@@ -919,20 +913,17 @@ static CURLcode smtp_state_auth_login_password_resp(struct connectdata *conn,
     /* Create the password message */
     result = Curl_sasl_create_login_message(conn->data, conn->passwd,
                                             &authpasswd, &len);
+    if(!result && authpasswd) {
+      /* Send the password */
+      result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", authpasswd);
 
-    /* Send the password */
-    if(!result) {
-      if(authpasswd) {
-        result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", authpasswd);
-
-        if(!result)
-          state(conn, SMTP_AUTH_FINAL);
-      }
-
-      Curl_safefree(authpasswd);
+      if(!result)
+        state(conn, SMTP_AUTH_FINAL);
     }
   }
 
+  Curl_safefree(authpasswd);
+
   return result;
 }
 
@@ -1091,20 +1082,17 @@ static CURLcode smtp_state_auth_ntlm_resp(struct connectdata *conn,
     result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd,
                                                  &conn->ntlm,
                                                  &type1msg, &len);
+    if(!result && type1msg) {
+      /* Send the message */
+      result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", type1msg);
 
-    /* Send the message */
-    if(!result) {
-      if(type1msg) {
-        result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", type1msg);
-
-        if(!result)
-          state(conn, SMTP_AUTH_NTLM_TYPE2MSG);
-      }
-
-      Curl_safefree(type1msg);
+      if(!result)
+        state(conn, SMTP_AUTH_NTLM_TYPE2MSG);
     }
   }
 
+  Curl_safefree(type1msg);
+
   return result;
 }
 
@@ -1179,20 +1167,17 @@ static CURLcode smtp_state_auth_xoauth2_resp(struct connectdata *conn,
     result = Curl_sasl_create_xoauth2_message(conn->data, conn->user,
                                               conn->xoauth2_bearer,
                                               &xoauth, &len);
+    if(!result && xoauth) {
+      /* Send the message */
+      result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", xoauth);
 
-    /* Send the message */
-    if(!result) {
-      if(xoauth) {
-        result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", xoauth);
-
-        if(!result)
-          state(conn, SMTP_AUTH_FINAL);
-      }
-
-      Curl_safefree(xoauth);
+      if(!result)
+        state(conn, SMTP_AUTH_FINAL);
     }
   }
 
+  Curl_safefree(xoauth);
+
   return result;
 }