diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-03-13 20:29:36 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-03-13 20:29:36 +0000 |
commit | 63732f37cba3d493954154c0f2440ddc88d7f207 (patch) | |
tree | 5ca2c614d648cd768a319d7a1ebbdb3918c407ed /src/modules/m_sqlauth.cpp | |
parent | a45254ff4c15ca23b03bb2dbd52a6cd3b30c2662 (diff) |
Handle database not present a bit better, add missing MySQL rehash on init
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12634 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_sqlauth.cpp')
-rw-r--r-- | src/modules/m_sqlauth.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/modules/m_sqlauth.cpp b/src/modules/m_sqlauth.cpp index 29554b031..d87c66de9 100644 --- a/src/modules/m_sqlauth.cpp +++ b/src/modules/m_sqlauth.cpp @@ -87,14 +87,16 @@ class ModuleSQLAuth : public Module void OnRehash(User* user) { - ConfigReader Conf; - - SQL.SetProvider("SQL/" + Conf.ReadValue("sqlauth", "dbid", 0)); /* Database ID, given to the SQL service provider */ - freeformquery = Conf.ReadValue("sqlauth", "query", 0); /* Field name where username can be found */ - killreason = Conf.ReadValue("sqlauth", "killreason", 0); /* Reason to give when access is denied to a user (put your reg details here) */ - allowpattern = Conf.ReadValue("sqlauth", "allowpattern",0 ); /* Allow nicks matching this pattern without requiring auth */ - verbose = Conf.ReadFlag("sqlauth", "verbose", 0); /* Set to true if failed connects should be reported to operators */ - SQL.lookup(); + ConfigTag* conf = ServerInstance->Config->ConfValue("sqlauth"); + std::string dbid = conf->getString("dbid"); + if (dbid.empty()) + SQL.SetProvider("SQL"); + else + SQL.SetProvider("SQL/" + dbid); + freeformquery = conf->getString("query"); + killreason = conf->getString("killreason"); + allowpattern = conf->getString("allowpattern"); + verbose = conf->getBool("verbose"); } ModResult OnUserRegister(LocalUser* user) @@ -110,6 +112,14 @@ class ModuleSQLAuth : public Module if (pendingExt.get(user)) return MOD_RES_PASSTHRU; + if (!SQL) + { + ServerInstance->SNO->WriteGlobalSno('a', "Forbiding connection from %s!%s@%s (SQL database not present)", + user->nick.c_str(), user->ident.c_str(), user->host.c_str()); + ServerInstance->Users->QuitUser(user, killreason); + return MOD_RES_PASSTHRU; + } + pendingExt.set(user, AUTH_STATE_BUSY); ParamM userinfo; |