From 0015098ab37ec2b67055c8794a4c7818922a259a Mon Sep 17 00:00:00 2001 From: psychon Date: Sat, 7 Mar 2009 12:37:38 +0000 Subject: [PATCH] Always notify the user when someone else tried to login but was rejected Before this, you only got a message from *status when someone tried to login with a bad password and no auth module (imapauth/saslauth) was loaded. With this patch every failed login will generate a message. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1415 726aef4b-f618-498e-8847-2d620e286838 --- Client.cpp | 10 ++++++++++ znc.cpp | 4 ---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Client.cpp b/Client.cpp index b8035459..a514099d 100644 --- a/Client.cpp +++ b/Client.cpp @@ -628,6 +628,16 @@ void CClientAuth::RefusedLogin(const CString& sReason) { } void CAuthBase::RefuseLogin(const CString& sReason) { + CUser* pUser = GetUser(GetUsername()); + + // If the username is valid, notify that user that someone tried to + // login. Use sReason because there are other reasons than "wrong + // password" for a login to be rejected (e.g. fail2ban). + if (pUser) { + pUser->PutStatus("Another client attempted to login as you [" + + sReason + "]."); + } + #ifdef _MODULES CZNC::Get().GetModules().OnFailedLogin(GetUsername(), GetRemoteIP()); #endif diff --git a/znc.cpp b/znc.cpp index e3565ee3..3aac144a 100644 --- a/znc.cpp +++ b/znc.cpp @@ -1750,10 +1750,6 @@ void CZNC::AuthUser(CSmartPtr AuthClass) { CUser* pUser = GetUser(AuthClass->GetUsername()); if (!pUser || !pUser->CheckPass(AuthClass->GetPassword())) { - if (pUser) { - pUser->PutStatus("Another client attempted to login as you, with a bad password."); - } - AuthClass->RefuseLogin("Invalid Password"); return; }