Commit 9ea51459 authored by Steve Holme's avatar Steve Holme
Browse files

email: Tidy up of *_perform_authenticate()

Removed the hard returns from imap and pop3 by using the same style for
sending the authentication string as smtp. Moved the "Other mechanisms
not supported" check in smtp to match that of imap and pop3 to provide
consistency between the three email protocols.
parent 1d7c38e1
Loading
Loading
Loading
Loading
+21 −22
Original line number Diff line number Diff line
@@ -596,9 +596,7 @@ static CURLcode imap_perform_authenticate(struct connectdata *conn)
                                              conn->passwd, &initresp, &len);
  }

  if(result)
    return result;

  if(!result) {
    if(mech) {
      /* Perform SASL based authentication */
      if(initresp) {
@@ -624,6 +622,7 @@ static CURLcode imap_perform_authenticate(struct connectdata *conn)
      infof(conn->data, "No known authentication mechanisms supported!\n");
      result = CURLE_LOGIN_DENIED;
    }
  }

  return result;
}
+28 −30
Original line number Diff line number Diff line
@@ -624,9 +624,7 @@ static CURLcode pop3_perform_authenticate(struct connectdata *conn)
    }
  }

  if(result)
    return result;

  if(!result) {
    if(mech && (pop3c->preftype & POP3_TYPE_SASL)) {
      /* Perform SASL based authentication */
      if(initresp &&
@@ -637,7 +635,6 @@ static CURLcode pop3_perform_authenticate(struct connectdata *conn)
          state(conn, state2);
      }
      else {
      /* Perform SASL based authentication */
        result = Curl_pp_sendf(&pop3c->pp, "AUTH %s", mech);

        if(!result)
@@ -661,6 +658,7 @@ static CURLcode pop3_perform_authenticate(struct connectdata *conn)
      infof(conn->data, "No known authentication mechanisms supported!\n");
      result = CURLE_LOGIN_DENIED;
    }
  }

  return result;
}
+19 −17
Original line number Diff line number Diff line
@@ -518,13 +518,9 @@ static CURLcode smtp_perform_authenticate(struct connectdata *conn)
      result = Curl_sasl_create_plain_message(conn->data, conn->user,
                                              conn->passwd, &initresp, &len);
  }
  else {
    /* Other mechanisms not supported */
    infof(conn->data, "No known authentication mechanisms supported!\n");
    result = CURLE_LOGIN_DENIED;
  }

  if(!result) {
    if(mech) {
      /* Perform SASL based authentication */
      if(initresp &&
         8 + strlen(mech) + len <= 512) { /* AUTH <mech> ...<crlf> */
@@ -542,6 +538,12 @@ static CURLcode smtp_perform_authenticate(struct connectdata *conn)

      Curl_safefree(initresp);
    }
    else {
      /* Other mechanisms not supported */
      infof(conn->data, "No known authentication mechanisms supported!\n");
      result = CURLE_LOGIN_DENIED;
    }
  }

  return result;
}