X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_sqlauth.cpp;h=d87c66de980210773340e6395ba30a0ed8a1c98c;hb=cb4c516ace8fef75b8a54a141c3644af9697ac0a;hp=52f0d5d4fea8af52ef70a1711461cded1ecde69e;hpb=11e45f2cb78c0667e2c7c7e2370944bf64b140b8;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_sqlauth.cpp b/src/modules/m_sqlauth.cpp index 52f0d5d4f..d87c66de9 100644 --- a/src/modules/m_sqlauth.cpp +++ b/src/modules/m_sqlauth.cpp @@ -29,10 +29,9 @@ class AuthQuery : public SQLQuery const std::string uid; LocalIntExt& pendingExt; bool verbose; - AuthQuery(Module* me, const std::string& q, const std::string& u, LocalIntExt& e, bool v) - : SQLQuery(me, q), uid(u), pendingExt(e), verbose(v) + AuthQuery(Module* me, const std::string& u, LocalIntExt& e, bool v) + : SQLQuery(me), uid(u), pendingExt(e), verbose(v) { - ServerInstance->Logs->Log("m_sqlauth",DEBUG, "SQLAUTH: query=\"%s\"", q.c_str()); } void OnResult(SQLResult& res) @@ -88,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) @@ -111,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; @@ -125,7 +134,7 @@ class ModuleSQLAuth : public Module if (sha256) userinfo["sha256pass"] = sha256->hexsum(user->password); - SQL->submit(new AuthQuery(this, SQL->FormatQuery(freeformquery, userinfo), user->uuid, pendingExt, verbose)); + SQL->submit(new AuthQuery(this, user->uuid, pendingExt, verbose), freeformquery, userinfo); return MOD_RES_PASSTHRU; }