summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-22 10:42:11 +0000
committerom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-22 10:42:11 +0000
commitf50ad0454c24560438488e601b96f28b446c8302 (patch)
treecde848cc0e588cc1423bb42aa5f6a294cb98829d
parent6550132711b5e111d2065232ee6ddf463cb9f808 (diff)
Handle queries failing properly, actually work
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4498 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/extra/m_sqlauth.cpp51
1 files changed, 33 insertions, 18 deletions
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");
}