Hello. Some limits can be configured in imapd.conf (such as maxlogins_per_host, maxlogins_per_user, popminpoll). Reaching limits should be logged for properly diagnostic: https://github.com/cyrusimap/cyrus-imapd/issues/2913
I created this issue but encounter a problem to add patches. I put them here. -- Regards, Sergey
diff --git a/imap/imapd.c b/imap/imapd.c index ad29a45da..69f85e2a2 100644 --- a/imap/imapd.c +++ b/imap/imapd.c @@ -2354,17 +2354,24 @@ static int checklimits(const char *tag) if (proc_checklimits(&limits)) { const char *sep = ""; + char part1[1024] = ""; + char part2[1024] = ""; prot_printf(imapd_out, "%s NO Too many open connections (", tag); if (limits.maxhost) { prot_printf(imapd_out, "%s%d of %d from %s", sep, limits.host, limits.maxhost, imapd_clienthost); + snprintf(part1, sizeof(part1), "%s%d of %d from %s", sep, + limits.host, limits.maxhost, imapd_clienthost); sep = ", "; } if (limits.maxuser) { prot_printf(imapd_out, "%s%d of %d for %s", sep, limits.user, limits.maxuser, imapd_userid); + snprintf(part2, sizeof(part2), "%s%d of %d for %s", sep, + limits.user, limits.maxuser, imapd_userid); } prot_printf(imapd_out, ")\r\n"); + syslog(LOG_ERR, "Too many open connections (%s%s)", part1, part2); free(imapd_userid); imapd_userid = NULL; auth_freestate(imapd_authstate); diff --git a/imap/nntpd.c b/imap/nntpd.c index 9d1523bb0..a087059f9 100644 --- a/imap/nntpd.c +++ b/imap/nntpd.c @@ -2249,18 +2249,25 @@ static void cmd_authinfo_sasl(char *cmd, char *mech, char *resp) limits.userid = nntp_userid; if (proc_checklimits(&limits)) { const char *sep = ""; + char part1[1024] = ""; + char part2[1024] = ""; prot_printf(nntp_out, "452 Too many open connections ("); if (limits.maxhost) { prot_printf(nntp_out, "%s%d of %d from %s", sep, limits.host, limits.maxhost, nntp_clienthost); + snprintf(part1, sizeof(part1), "%s%d of %d from %s", sep, + limits.host, limits.maxhost, nntp_clienthost); sep = ", "; } if (limits.maxuser) { prot_printf(nntp_out, "%s%d of %d for %s", sep, limits.user, limits.maxuser, nntp_userid); + snprintf(part2, sizeof(part2), "%s%d of %d for %s", sep, + limits.user, limits.maxuser, nntp_userid); } prot_printf(nntp_out, ")\r\n"); + syslog(LOG_ERR, "Too many open connections (%s%s)", part1, part2); reset_saslconn(&nntp_saslconn); free(nntp_userid); nntp_userid = NULL; diff --git a/imap/pop3d.c b/imap/pop3d.c index ebe4db37f..813f6ea36 100644 --- a/imap/pop3d.c +++ b/imap/pop3d.c @@ -1938,6 +1938,8 @@ int openinbox(void) if ((minpoll = config_getint(IMAPOPT_POPMINPOLL)) && popd_mailbox->i.pop3_last_login + 60*minpoll > popd_login_time) { + syslog(LOG_ERR, "%s: Logins must be at least %d minute%s apart", + inboxname, minpoll, minpoll > 1 ? "s" : ""); prot_printf(popd_out, "-ERR [LOGIN-DELAY] Logins must be at least %d minute%s apart\r\n", minpoll, minpoll > 1 ? "s" : ""); @@ -1990,18 +1992,25 @@ int openinbox(void) limits.userid = proxy_userid; if (proc_checklimits(&limits)) { const char *sep = ""; + char part1[1024] = ""; + char part2[1024] = ""; prot_printf(popd_out, "-ERR Too many open connections ("); if (limits.maxhost) { prot_printf(popd_out, "%s%d of %d from %s", sep, limits.host, limits.maxhost, popd_clienthost); + snprintf(part1, sizeof(part1), "%s%d of %d from %s", sep, + limits.host, limits.maxhost, popd_clienthost); sep = ", "; } if (limits.maxuser) { prot_printf(popd_out, "%s%d of %d for %s", sep, limits.user, limits.maxuser, proxy_userid); + snprintf(part2, sizeof(part2), "%s%d of %d for %s", sep, + limits.user, limits.maxuser, popd_userid); } prot_printf(popd_out, ")\r\n"); + syslog(LOG_ERR, "Too many open connections (%s%s)", part1, part2); mailbox_close(&popd_mailbox); goto fail; }
diff --git a/imap/imapd.c b/imap/imapd.c index 75ab0563f..2e6bcd918 100644 --- a/imap/imapd.c +++ b/imap/imapd.c @@ -2567,17 +2567,24 @@ static int checklimits(const char *tag) if (proc_checklimits(&limits)) { const char *sep = ""; + char part1[1024] = ""; + char part2[1024] = ""; prot_printf(imapd_out, "%s NO Too many open connections (", tag); if (limits.maxhost) { prot_printf(imapd_out, "%s%d of %d from %s", sep, limits.host, limits.maxhost, imapd_clienthost); + snprintf(part1, sizeof(part1), "%s%d of %d from %s", sep, + limits.host, limits.maxhost, imapd_clienthost); sep = ", "; } if (limits.maxuser) { prot_printf(imapd_out, "%s%d of %d for %s", sep, limits.user, limits.maxuser, imapd_userid); + snprintf(part2, sizeof(part2), "%s%d of %d for %s", sep, + limits.user, limits.maxuser, imapd_userid); } prot_printf(imapd_out, ")\r\n"); + syslog(LOG_ERR, "Too many open connections (%s%s)", part1, part2); free(imapd_userid); imapd_userid = NULL; auth_freestate(imapd_authstate); diff --git a/imap/nntpd.c b/imap/nntpd.c index 34ce36b12..3380396c1 100644 --- a/imap/nntpd.c +++ b/imap/nntpd.c @@ -2281,18 +2281,25 @@ static void cmd_authinfo_sasl(char *cmd, char *mech, char *resp) limits.userid = nntp_userid; if (proc_checklimits(&limits)) { const char *sep = ""; + char part1[1024] = ""; + char part2[1024] = ""; prot_printf(nntp_out, "400 Too many open connections ("); if (limits.maxhost) { prot_printf(nntp_out, "%s%d of %d from %s", sep, limits.host, limits.maxhost, nntp_clienthost); + snprintf(part1, sizeof(part1), "%s%d of %d from %s", sep, + limits.host, limits.maxhost, nntp_clienthost); sep = ", "; } if (limits.maxuser) { prot_printf(nntp_out, "%s%d of %d for %s", sep, limits.user, limits.maxuser, nntp_userid); + snprintf(part2, sizeof(part2), "%s%d of %d for %s", sep, + limits.user, limits.maxuser, nntp_userid); } prot_printf(nntp_out, ")\r\n"); + syslog(LOG_ERR, "Too many open connections (%s%s)", part1, part2); reset_saslconn(&nntp_saslconn); free(nntp_userid); nntp_userid = NULL; diff --git a/imap/pop3d.c b/imap/pop3d.c index 0b499222b..3f3043342 100644 --- a/imap/pop3d.c +++ b/imap/pop3d.c @@ -1943,6 +1943,8 @@ int openinbox(void) if ((minpoll = config_getint(IMAPOPT_POPMINPOLL)) && popd_mailbox->i.pop3_last_login + 60*minpoll > popd_login_time) { + syslog(LOG_ERR, "%s: Logins must be at least %d minute%s apart", + mbname_intname(mbname), minpoll, minpoll > 1 ? "s" : ""); prot_printf(popd_out, "-ERR [LOGIN-DELAY] Logins must be at least %d minute%s apart\r\n", minpoll, minpoll > 1 ? "s" : ""); @@ -1994,18 +1996,25 @@ int openinbox(void) limits.userid = popd_userid; if (proc_checklimits(&limits)) { const char *sep = ""; + char part1[1024] = ""; + char part2[1024] = ""; prot_printf(popd_out, "-ERR Too many open connections ("); if (limits.maxhost) { prot_printf(popd_out, "%s%d of %d from %s", sep, limits.host, limits.maxhost, popd_clienthost); + snprintf(part1, sizeof(part1), "%s%d of %d from %s", sep, + limits.host, limits.maxhost, popd_clienthost); sep = ", "; } if (limits.maxuser) { prot_printf(popd_out, "%s%d of %d for %s", sep, limits.user, limits.maxuser, popd_userid); + snprintf(part2, sizeof(part2), "%s%d of %d for %s", sep, + limits.user, limits.maxuser, popd_userid); } prot_printf(popd_out, ")\r\n"); + syslog(LOG_ERR, "Too many open connections (%s%s)", part1, part2); mailbox_close(&popd_mailbox); goto fail; }