X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_sasl.cpp;h=3c3b1d2a00112dbd7f780bfb5e375953f0348f2c;hb=04cfaea87edd1b4b742cb607ea69ece760c460aa;hp=42d9084676123816af6cdd8c2ed141ca0002cb1e;hpb=e80a1296a096ff2c495b3cd2a3913d5e5f6ec450;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index 42d908467..3c3b1d2a0 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * InspIRCd: (C) 2002-2010 InspIRCd Development Team * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see @@ -23,7 +23,7 @@ enum SaslResult { SASL_OK, SASL_FAIL, SASL_ABORT }; /** * Tracks SASL authentication state like charybdis does. --nenolod */ -class SaslAuthenticator : public classbase +class SaslAuthenticator { private: InspIRCd *ServerInstance; @@ -185,7 +185,7 @@ class CommandSASL : public Command SimpleExtItem& authExt; CommandSASL(Module* Creator, SimpleExtItem& ext) : Command(Creator, "SASL", 2), authExt(ext) { - this->disabled = true; // should not be called by users + this->flags_needed = FLAG_SERVERONLY; // should not be called by users } CmdResult Handle(const std::vector& parameters, User *user) @@ -226,18 +226,17 @@ class ModuleSASL : public Module ModuleSASL() : authExt("sasl_auth", this), cap(this, "sasl"), auth(this, authExt, cap), sasl(this, authExt) { - Implementation eventlist[] = { I_OnEvent, I_OnUserRegister, I_OnPostConnect, I_OnUserDisconnect }; - ServerInstance->Modules->Attach(eventlist, this, 4); + Implementation eventlist[] = { I_OnEvent, I_OnUserRegister, I_OnSetConnectClass }; + ServerInstance->Modules->Attach(eventlist, this, 3); - ServerInstance->AddCommand(&auth); - ServerInstance->AddCommand(&sasl); + ServiceProvider* providelist[] = { &auth, &sasl, &authExt }; + ServerInstance->Modules->AddServices(providelist, 3); - ServerInstance->Extensions.Register(&authExt); if (!ServerInstance->Modules->Find("m_services_account.so") || !ServerInstance->Modules->Find("m_cap.so")) ServerInstance->Logs->Log("m_sasl", DEFAULT, "WARNING: m_services_account.so and m_cap.so are not loaded! m_sasl.so will NOT function correctly until these two modules are loaded!"); } - ModResult OnUserRegister(User *user) + ModResult OnUserRegister(LocalUser *user) { SaslAuthenticator *sasl_ = authExt.get(user); if (sasl_) @@ -249,13 +248,24 @@ class ModuleSASL : public Module return MOD_RES_PASSTHRU; } + ModResult OnSetConnectClass(LocalUser* user, ConnectClass* myclass) + { + if (myclass->config->getBool("requiresasl")) + { + const AccountExtItem* ext = GetAccountExtItem(); + if (ext && !ext->get(user)) + return MOD_RES_DENY; + } + return MOD_RES_PASSTHRU; + } + ~ModuleSASL() { } Version GetVersion() { - return Version("Provides support for IRC Authentication Layer (aka: atheme SASL) via AUTHENTICATE.",VF_VENDOR,API_VERSION); + return Version("Provides support for IRC Authentication Layer (aka: atheme SASL) via AUTHENTICATE.",VF_VENDOR); } void OnEvent(Event &ev)