smtp: Moved the sending of the AUTH command into a separate function
This commit is contained in:
parent
367648d24a
commit
da24fbbc00
47
lib/smtp.c
47
lib/smtp.c
@ -428,6 +428,39 @@ static CURLcode smtp_perform_upgrade_tls(struct connectdata *conn)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* smtp_perform_auth()
|
||||||
|
*
|
||||||
|
* Sends an AUTH command allowing the client to login with the given SASL
|
||||||
|
* authentication mechanism.
|
||||||
|
*/
|
||||||
|
static CURLcode smtp_perform_auth(struct connectdata *conn,
|
||||||
|
const char *mech,
|
||||||
|
const char *initresp, size_t len,
|
||||||
|
smtpstate state1, smtpstate state2)
|
||||||
|
{
|
||||||
|
CURLcode result = CURLE_OK;
|
||||||
|
struct smtp_conn *smtpc = &conn->proto.smtpc;
|
||||||
|
|
||||||
|
if(initresp && 8 + strlen(mech) + len <= 512) { /* AUTH <mech> ...<crlf> */
|
||||||
|
/* Send the AUTH command with the initial response */
|
||||||
|
result = Curl_pp_sendf(&smtpc->pp, "AUTH %s %s", mech, initresp);
|
||||||
|
|
||||||
|
if(!result)
|
||||||
|
state(conn, state2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Send the AUTH command */
|
||||||
|
result = Curl_pp_sendf(&smtpc->pp, "AUTH %s", mech);
|
||||||
|
|
||||||
|
if(!result)
|
||||||
|
state(conn, state1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
*
|
*
|
||||||
* smtp_perform_authentication()
|
* smtp_perform_authentication()
|
||||||
@ -525,19 +558,7 @@ static CURLcode smtp_perform_authentication(struct connectdata *conn)
|
|||||||
if(!result) {
|
if(!result) {
|
||||||
if(mech) {
|
if(mech) {
|
||||||
/* Perform SASL based authentication */
|
/* Perform SASL based authentication */
|
||||||
if(initresp &&
|
result = smtp_perform_auth(conn, mech, initresp, len, state1, state2);
|
||||||
8 + strlen(mech) + len <= 512) { /* AUTH <mech> ...<crlf> */
|
|
||||||
result = Curl_pp_sendf(&smtpc->pp, "AUTH %s %s", mech, initresp);
|
|
||||||
|
|
||||||
if(!result)
|
|
||||||
state(conn, state2);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
result = Curl_pp_sendf(&smtpc->pp, "AUTH %s", mech);
|
|
||||||
|
|
||||||
if(!result)
|
|
||||||
state(conn, state1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Curl_safefree(initresp);
|
Curl_safefree(initresp);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user