diff options
author | Eduardo Chappa <chappa@washington.edu> | 2020-02-19 00:39:42 -0700 |
---|---|---|
committer | Eduardo Chappa <chappa@washington.edu> | 2020-02-19 00:39:42 -0700 |
commit | cd53b13aa5acaecb776c82cd6566122a6893240d (patch) | |
tree | 4e811c0dfdebf647b564f4f9659c388c87a44f4c /imap/src/c-client/smtp.c | |
parent | 8781af1dfc9fdc1fbc08b281cc418bee8dde604d (diff) | |
download | alpine-cd53b13aa5acaecb776c82cd6566122a6893240d.tar.xz |
* Added support for SALS-IR (rfc 4959) and similar support for other
protocols (SMTP, NNTP, POP3) as some SMTP servers do not support a
round-trip two step authentication. For example, davmail does not
support PLAIN authentication in SMTP using the challenge-response
scheme. Implemented after a report by Geoffrey Bodwin.
Diffstat (limited to 'imap/src/c-client/smtp.c')
-rw-r--r-- | imap/src/c-client/smtp.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/imap/src/c-client/smtp.c b/imap/src/c-client/smtp.c index 96abd5fa..30bfd293 100644 --- a/imap/src/c-client/smtp.c +++ b/imap/src/c-client/smtp.c @@ -59,7 +59,7 @@ /* Function prototypes */ void *smtp_challenge (void *s,unsigned long *len); -long smtp_response (void *s,char *response,unsigned long size); +long smtp_response (void *s,char *base,char *response,unsigned long size); long smtp_auth (SENDSTREAM *stream,NETMBX *mb,char *tmp); long smtp_rcpt (SENDSTREAM *stream,ADDRESS *adr,long *error); long smtp_send (SENDSTREAM *stream,char *command,char *args); @@ -283,7 +283,7 @@ long smtp_auth (SENDSTREAM *stream,NETMBX *mb,char *tmp) { unsigned long trial,auths, authsaved; char *lsterr = NIL; - char usr[MAILTMPLEN]; + char usr[MAILTMPLEN], *base; AUTHENTICATOR *at, *atsaved; long ret = NIL; for (auths = ESMTP.auth, stream->saslcancel = NIL; @@ -311,11 +311,16 @@ long smtp_auth (SENDSTREAM *stream,NETMBX *mb,char *tmp) mm_log (tmp,WARN); fs_give ((void **) &lsterr); } + if(at->flags & AU_SINGLE){ + sprintf(tmp, "AUTH %s", at->name); + base = (char *) tmp; + } + else base = NIL; stream->saslcancel = NIL; - if (smtp_send (stream,"AUTH",at->name) == SMTPAUTHREADY) { + if ((at->flags & AU_SINGLE) || smtp_send (stream,"AUTH",at->name) == SMTPAUTHREADY) { /* hide client authentication responses */ if (!(at->flags & AU_SECURE)) stream->sensitive = T; - if ((*at->client) (smtp_challenge,smtp_response,"smtp",mb,stream, + if ((*at->client) (smtp_challenge,smtp_response,base,"smtp",mb,stream, net_port(stream->netstream),&trial,usr)) { if (stream->replycode == SMTPAUTHED) { ESMTP.auth = NIL; /* disable authenticators */ @@ -375,7 +380,7 @@ void *smtp_challenge (void *s,unsigned long *len) * Returns: T, always */ -long smtp_response (void *s,char *response,unsigned long size) +long smtp_response (void *s,char* base,char *response,unsigned long size) { SENDSTREAM *stream = (SENDSTREAM *) s; unsigned long i,j; @@ -385,13 +390,13 @@ long smtp_response (void *s,char *response,unsigned long size) for (t = (char *) rfc822_binary ((void *) response,size,&i),u = t,j = 0; j < i; j++) if (t[j] > ' ') *u++ = t[j]; *u = '\0'; /* tie off string */ - i = smtp_send (stream,t,NIL); + i = base ? smtp_send(stream, base, t) : smtp_send (stream,t,NIL); fs_give ((void **) &t); } else i = smtp_send (stream,"",NIL); } else { /* abort requested */ - i = smtp_send (stream,"*",NIL); + i = base ? 0L : smtp_send (stream,"*",NIL); stream->saslcancel = T; /* mark protocol-requested SASL cancel */ } return LONGT; |