diff options
author | Adam <Adam@anope.org> | 2011-05-23 14:47:14 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-05-23 14:47:14 -0400 |
commit | a45d1555d3f4751f4d42576a93640bc251c1dfe1 (patch) | |
tree | 552c5da8ac6562a05409da5f0af437aaaf96f2c3 | |
parent | 121ae0b189361141a5c4ae731556357c903b2723 (diff) |
Added an IsServicesOper event
-rw-r--r-- | include/modules.h | 8 | ||||
-rw-r--r-- | modules/core/os_login.cpp | 20 | ||||
-rw-r--r-- | src/users.cpp | 6 |
3 files changed, 31 insertions, 3 deletions
diff --git a/include/modules.h b/include/modules.h index c886e9a74..0f58afebb 100644 --- a/include/modules.h +++ b/include/modules.h @@ -626,6 +626,12 @@ class CoreExport Module : public Extensible */ virtual void OnDelXLine(User *u, XLine *x, XLineType Type) { } + /** Called when a user is checked for whether they are a services oper + * @param u The user + * @return EVENT_ALLOW to allow, anything else to deny + */ + virtual EventReturn IsServicesOper(User *u) { return EVENT_CONTINUE; } + /** Called when a server quits * @param server The server */ @@ -1060,7 +1066,7 @@ enum Implementation /* OperServ */ I_OnDefconLevel, I_OnAddAkill, I_OnDelAkill, I_OnExceptionAdd, I_OnExceptionDel, - I_OnAddXLine, I_OnDelXLine, + I_OnAddXLine, I_OnDelXLine, I_IsServicesOper, /* Database */ I_OnPostLoadDatabases, I_OnSaveDatabase, I_OnLoadDatabase, diff --git a/modules/core/os_login.cpp b/modules/core/os_login.cpp index dc9be1f37..4ff97da1f 100644 --- a/modules/core/os_login.cpp +++ b/modules/core/os_login.cpp @@ -78,6 +78,26 @@ class OSLogin : public Module throw ModuleException("OperServ is not loaded!"); this->AddCommand(operserv->Bot(), &commandoslogin); + + ModuleManager::Attach(I_IsServicesOper, this); + } + + ~OSLogin() + { + for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + it->second->Shrink("os_login_password_correct"); + } + + EventReturn IsServicesOper(User *u) + { + if (!u->Account()->o->password.empty()) + { + if (u->GetExt("os_login_password_correct")) + return EVENT_ALLOW; + return EVENT_STOP; + } + + return EVENT_CONTINUE; } }; diff --git a/src/users.cpp b/src/users.cpp index 1b06461ed..fe947d89a 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -443,8 +443,10 @@ bool User::IsServicesOper() else if (!this->nc->o->certfp.empty() && this->fingerprint != this->nc->o->certfp) // Certfp mismatch return false; - else if (!this->nc->o->password.empty() && !this->GetExt("os_login_password_correct")) - // Not identified + + EventReturn MOD_RESULT; + FOREACH_RESULT(I_IsServicesOper, IsServicesOper(this)); + if (MOD_RESULT == EVENT_STOP) return false; return true; |