aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--RELEASE-NOTES4
-rw-r--r--lib/curl_sasl.c13
-rw-r--r--lib/imap.c85
-rw-r--r--lib/pop3.c85
-rw-r--r--lib/smtp.c85
5 files changed, 112 insertions, 160 deletions
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index 3d4b2278c..0a9b3f802 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -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:
diff --git a/lib/curl_sasl.c b/lib/curl_sasl.c
index 09234da10..57a09ff35 100644
--- a/lib/curl_sasl.c
+++ b/lib/curl_sasl.c
@@ -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);
diff --git a/lib/imap.c b/lib/imap.c
index c11e43bd6..60e7489df 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -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;
}
diff --git a/lib/pop3.c b/lib/pop3.c
index b22d66e05..cc067d67c 100644
--- a/lib/pop3.c
+++ b/lib/pop3.c
@@ -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;
}
diff --git a/lib/smtp.c b/lib/smtp.c
index 19fe4ff6e..9ed0e0057 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -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;
}