summaryrefslogtreecommitdiff
path: root/lib/smtp.c
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2014-03-28 18:21:27 +0000
committerSteve Holme <steve_holme@hotmail.com>2014-03-28 18:21:27 +0000
commitfe260b75e74fed56573d133dd64d2424660743cb (patch)
tree9a4ef874bf0fccbf74c64df564423e4b185628ac /lib/smtp.c
parent2dc63c72dc86029e4586aab48517297626f2e455 (diff)
downloadcurl-fe260b75e74fed56573d133dd64d2424660743cb.tar.gz
smtp: Fixed login denied when server doesn't support AUTH capability
Specifying user credentials when the SMTP server doesn't support authentication would cause curl to display "No known authentication mechanisms supported!" and return CURLE_LOGIN_DENIED. Reported-by: Tom Sparrow Bug: http://curl.haxx.se/mail/lib-2014-03/0173.html
Diffstat (limited to 'lib/smtp.c')
-rw-r--r--lib/smtp.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/smtp.c b/lib/smtp.c
index 616481d8b..cc1f2ad56 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -349,10 +349,11 @@ static CURLcode smtp_perform_ehlo(struct connectdata *conn)
CURLcode result = CURLE_OK;
struct smtp_conn *smtpc = &conn->proto.smtpc;
- smtpc->authmechs = 0; /* No known authentication mechanisms yet */
- smtpc->authused = 0; /* Clear the authentication mechanism used
- for esmtp connections */
- smtpc->tls_supported = FALSE; /* Clear the TLS capability */
+ smtpc->authmechs = 0; /* No known authentication mechanisms yet */
+ smtpc->authused = 0; /* Clear the authentication mechanism used
+ for esmtp connections */
+ smtpc->tls_supported = FALSE; /* Clear the TLS capability */
+ smtpc->auth_supported = FALSE; /* Clear the AUTH capability */
/* Send the EHLO command */
result = Curl_pp_sendf(&smtpc->pp, "EHLO %s", smtpc->domain);
@@ -475,15 +476,16 @@ static CURLcode smtp_perform_auth(struct connectdata *conn,
static CURLcode smtp_perform_authentication(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
+ struct smtp_conn *smtpc = &conn->proto.smtpc;
const char *mech = NULL;
char *initresp = NULL;
size_t len = 0;
smtpstate state1 = SMTP_STOP;
smtpstate state2 = SMTP_STOP;
- /* Check we have a username and password to authenticate with and end the
- connect phase if we don't */
- if(!conn->bits.user_passwd) {
+ /* Check we have a username and password to authenticate with, and the
+ server supports authentiation, and end the connect phase if not */
+ if(!conn->bits.user_passwd || !smtpc->auth_supported) {
state(conn, SMTP_STOP);
return result;
@@ -739,8 +741,11 @@ static CURLcode smtp_state_ehlo_resp(struct connectdata *conn, int smtpcode,
else if(len >= 4 && !memcmp(line, "SIZE", 4))
smtpc->size_supported = TRUE;
- /* Do we have the authentication mechanism list? */
+ /* Does the server support authentication? */
else if(len >= 5 && !memcmp(line, "AUTH ", 5)) {
+ smtpc->auth_supported = TRUE;
+
+ /* Advance past the AUTH keyword */
line += 5;
len -= 5;