From 6cbacba202dd905143b199c5b4734968e172caaa Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sun, 20 Oct 2013 23:56:55 +0200 Subject: [PATCH] Read multiline SMTP-Replies; we need to analyze all of them to detect the proper smtp authentication method. --- citadel/modules/smtp/serv_smtpeventclient.c | 10 ++++++++++ citadel/modules/smtp/smtp_clienthandlers.c | 5 +++++ citadel/modules/smtp/smtp_clienthandlers.h | 1 + 3 files changed, 16 insertions(+) diff --git a/citadel/modules/smtp/serv_smtpeventclient.c b/citadel/modules/smtp/serv_smtpeventclient.c index 209c964b2..be573d73a 100644 --- a/citadel/modules/smtp/serv_smtpeventclient.c +++ b/citadel/modules/smtp/serv_smtpeventclient.c @@ -127,6 +127,7 @@ void DeleteSmtpOutMsg(void *v) Msg->HostLookup.DNSReplyFree(Msg->HostLookup.VParsedDNSReply); FreeURL(&Msg->Relay); FreeStrBuf(&Msg->msgtext); + FreeStrBuf(&Msg->MultiLineBuf); FreeAsyncIOContents(&Msg->IO); memset (Msg, 0, sizeof(SmtpOutMsg)); /* just to be shure... */ free(Msg); @@ -863,7 +864,16 @@ eReadState SMTP_C_ReadServerStatus(AsyncIO *IO) if (StrLength(IO->IOBuf) < 4) continue; if (ChrPtr(IO->IOBuf)[3] == '-') + { + SmtpOutMsg *Msg; + Msg = (SmtpOutMsg *)IO->Data; + if (Msg->MultiLineBuf == NULL) + Msg->MultiLineBuf = NewStrBuf (); + else + StrBufAppendBufPlain(Msg->MultiLineBuf, HKEY("\n"), 0); + StrBufAppendBuf(Msg->MultiLineBuf, IO->IOBuf, 0); Finished = eBufferNotEmpty; + } else return Finished; break; diff --git a/citadel/modules/smtp/smtp_clienthandlers.c b/citadel/modules/smtp/smtp_clienthandlers.c index 70373a896..9e5d61193 100644 --- a/citadel/modules/smtp/smtp_clienthandlers.c +++ b/citadel/modules/smtp/smtp_clienthandlers.c @@ -166,6 +166,11 @@ eNextState SMTPC_read_EHLO_reply(SmtpOutMsg *Msg) { if (strstr(ChrPtr(Msg->IO.IOBuf), "LOGIN") != NULL) Msg->SendLogin = 1; + else if ((Msg->MultiLineBuf != NULL) && + strstr(ChrPtr(Msg->MultiLineBuf), "LOGIN") != NULL) + { + Msg->SendLogin = 1; + } } } /* else we fall back to 'helo' */ diff --git a/citadel/modules/smtp/smtp_clienthandlers.h b/citadel/modules/smtp/smtp_clienthandlers.h index dedab4ba4..28ffac713 100644 --- a/citadel/modules/smtp/smtp_clienthandlers.h +++ b/citadel/modules/smtp/smtp_clienthandlers.h @@ -62,6 +62,7 @@ typedef struct _stmp_out_msg { ParsedURL *pCurrRelay; StrBuf *msgtext; StrBuf *QMsgData; + StrBuf *MultiLineBuf; const char *envelope_from; char user[1024]; -- 2.30.2