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_sqloper.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_sqloper.cpp')
-rw-r--r-- | src/modules/m_sqloper.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/modules/m_sqloper.cpp b/src/modules/m_sqloper.cpp index 92e402811..bded0ea04 100644 --- a/src/modules/m_sqloper.cpp +++ b/src/modules/m_sqloper.cpp @@ -146,19 +146,27 @@ public: { ConfigTag* tag = ServerInstance->Config->ConfValue("sqloper"); - SQL.SetProvider("SQL/" + tag->getString("dbid")); - SQL.lookup(); + std::string dbid = tag->getString("dbid"); + if (dbid.empty()) + SQL.SetProvider("SQL"); + else + SQL.SetProvider("SQL/" + dbid); + hashtype = tag->getString("hash"); query = tag->getString("query", "SELECT hostname as host, type FROM ircd_opers WHERE username='$username' AND password='$password'"); } ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line) { - if (validated && command == "OPER" && parameters.size() == 2 && SQL) + if (validated && command == "OPER" && parameters.size() >= 2) { - LookupOper(user, parameters[0], parameters[1]); - /* Query is in progress, it will re-invoke OPER if needed */ - return MOD_RES_DENY; + if (SQL) + { + LookupOper(user, parameters[0], parameters[1]); + /* Query is in progress, it will re-invoke OPER if needed */ + return MOD_RES_DENY; + } + ServerInstance->Logs->Log("m_sqloper",DEFAULT, "SQLOPER: database not present"); } return MOD_RES_PASSTHRU; } |