From f50ad0454c24560438488e601b96f28b446c8302 Mon Sep 17 00:00:00 2001 From: om Date: Sat, 22 Jul 2006 10:42:11 +0000 Subject: Handle queries failing properly, actually work git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4498 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/extra/m_sqlauth.cpp | 51 ++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 18 deletions(-) (limited to 'src/modules') diff --git a/src/modules/extra/m_sqlauth.cpp b/src/modules/extra/m_sqlauth.cpp index 17381731b..71c9903bd 100644 --- a/src/modules/extra/m_sqlauth.cpp +++ b/src/modules/extra/m_sqlauth.cpp @@ -86,8 +86,6 @@ public: if (!CheckCredentials(user)) { - if (verbose) - WriteOpers("Forbidden connection from %s!%s@%s (invalid login/password)",user->nick,user->ident,user->host); Srv->QuitUser(user,killreason); } } @@ -162,21 +160,6 @@ public: user = iter->second; - log(DEBUG, "Associated query ID %lu with user %s", res->id, user->nick); - - log(DEBUG, "Got result with %d rows and %d columns", res->Rows(), res->Cols()); - - if(res->Rows()) - { - /* We got a row in the result, this is enough really */ - user->Extend("sqlauthed"); - } - else if (verbose) - { - /* No rows in result, this means there was no record matching the user */ - WriteOpers("Forbidden connection from %s!%s@%s (SQL query returned no matches)", user->nick, user->ident, user->host); - } - /* Remove our ID from the lookup table to keep it as small and neat as possible */ qumap.erase(iter); @@ -186,6 +169,30 @@ public: user->Shrink("sqlauth_queryid"); delete id; } + + if(res->error.Id() == NO_ERROR) + { + log(DEBUG, "Associated query ID %lu with user %s", res->id, user->nick); + log(DEBUG, "Got result with %d rows and %d columns", res->Rows(), res->Cols()); + + if(res->Rows()) + { + /* We got a row in the result, this is enough really */ + user->Extend("sqlauthed"); + } + else if (verbose) + { + /* No rows in result, this means there was no record matching the user */ + WriteOpers("Forbidden connection from %s!%s@%s (SQL query returned no matches)", user->nick, user->ident, user->host); + user->Extend("sqlauth_failed"); + } + } + else if (verbose) + { + log(DEBUG, "Query failed: %s", res->error.Str()); + WriteOpers("Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick, user->ident, user->host, res->error.Str()); + user->Extend("sqlauth_failed"); + } } else { @@ -230,11 +237,19 @@ public: user->Shrink("sqlauth_queryid"); delete id; - } + } + + user->Shrink("sqlauthed"); + user->Shrink("sqlauth_failed"); } virtual bool OnCheckReady(userrec* user) { + if(user->GetExt("sqlauth_failed")) + { + Srv->QuitUser(user,killreason); + } + return user->GetExt("sqlauthed"); } -- cgit v1.2.3