File xmail-1.27_badsmtplogin.patch of Package XMail
diff -Naru xmail-1.27_orig/MailSvr.cpp xmail-1.27/MailSvr.cpp
--- xmail-1.27_orig/MailSvr.cpp 2010-02-26 12:33:44.000000000 +0900
+++ xmail-1.27/MailSvr.cpp 2014-11-14 18:53:06.446065316 +0900
@@ -80,6 +80,7 @@
#define STD_POP3AUTH_EXPIRE_TIME (15 * 60)
#define FILTER_TIMEOUT 90000
#define SVR_MAX_SERVICES 32
+#define STD_SMTP_BADLOGIN_WAIT 5
enum SvrServices {
@@ -780,6 +781,7 @@
int iMaxRcpts = STD_SMTP_MAX_RCPTS;
unsigned int uPopAuthExpireTime = STD_POP3AUTH_EXPIRE_TIME;
long lMaxThreads = MAX_SMTP_THREADS;
+ int iBadLoginWait = STD_SMTP_BADLOGIN_WAIT;
unsigned long ulFlags = 0;
/*
@@ -841,6 +843,11 @@
case '6':
iFamily = AF_INET6;
break;
+
+ case 'w':
+ if (++i < iArgCount)
+ iBadLoginWait = (unsigned int) atol(pszArgs[i]);
+ break;
}
}
@@ -861,6 +868,7 @@
pSMTPCfg->iTimeout = STD_SERVER_TIMEOUT;
pSMTPCfg->iMaxRcpts = iMaxRcpts;
pSMTPCfg->uPopAuthExpireTime = uPopAuthExpireTime;
+ pSMTPCfg->iBadLoginWait = iBadLoginWait;
ShbUnlock(hShbSMTP);
if (iDisable)
diff -Naru xmail-1.27_orig/SMTPSvr.cpp xmail-1.27/SMTPSvr.cpp
--- xmail-1.27_orig/SMTPSvr.cpp 2010-02-26 12:33:44.000000000 +0900
+++ xmail-1.27/SMTPSvr.cpp 2014-11-14 18:35:05.411405569 +0900
@@ -135,6 +135,7 @@
char *pszCustMsg;
char szRejMapName[256];
char *pszNoTLSAuths;
+ int iBadLoginWait;
};
enum SmtpAuthFields {
@@ -672,6 +673,8 @@
/* Get custom message to append to the SMTP response */
SMTPS.pszNoTLSAuths = SvrGetConfigVar(SMTPS.hSvrConfig, "SmtpNoTLSAuths");
+ SMTPS.iBadLoginWait = SMTPS.pSMTPCfg->iBadLoginWait;
+
return 0;
}
@@ -2447,6 +2450,9 @@
return ErrorPop();
}
if (iExitCode != SVR_SMTP_EXTAUTH_SUCCESS) {
+ SysSleep(SMTPS.iBadLoginWait);
+ SMTPS.iBadLoginWait += SMTPS.iBadLoginWait;
+
SMTPSendError(hBSock, SMTPS, "503 Authentication failed");
ErrSetErrorCode(ERR_BAD_EXTRNPRG_EXITCODE);
@@ -2645,6 +2651,9 @@
SMTPTryApplyUsrPwdAuth(SMTPS, pszUsername, pszPassword) < 0) {
ErrorPush();
+ SysSleep(SMTPS.iBadLoginWait);
+ SMTPS.iBadLoginWait += SMTPS.iBadLoginWait;
+
SMTPSendError(hBSock, SMTPS, "503 Authentication failed");
return ErrorPop();
@@ -2726,6 +2735,9 @@
SMTPTryApplyUsrPwdAuth(SMTPS, szUsername, szPassword) < 0) {
ErrorPush();
+ SysSleep(SMTPS.iBadLoginWait);
+ SMTPS.iBadLoginWait += SMTPS.iBadLoginWait;
+
SMTPSendError(hBSock, SMTPS, "503 Authentication failed");
return ErrorPop();
@@ -2885,6 +2897,9 @@
SMTPTryApplyCMD5Auth(SMTPS, SMTPS.szTimeStamp, pszUsername, pszDigest) < 0) {
ErrorPush();
+ SysSleep(SMTPS.iBadLoginWait);
+ SMTPS.iBadLoginWait += SMTPS.iBadLoginWait;
+
SMTPSendError(hBSock, SMTPS, "503 Authentication failed");
return ErrorPop();
diff -Naru xmail-1.27_orig/SMTPSvr.h xmail-1.27/SMTPSvr.h
--- xmail-1.27_orig/SMTPSvr.h 2010-02-26 12:33:44.000000000 +0900
+++ xmail-1.27/SMTPSvr.h 2014-11-14 17:28:20.532106097 +0900
@@ -39,6 +39,7 @@
int iTimeout;
int iMaxRcpts;
unsigned int uPopAuthExpireTime;
+ int iBadLoginWait;
};
unsigned int SMTPClientThread(void *pThreadData);