summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/opertype.h5
-rw-r--r--modules/commands/hs_request.cpp4
-rw-r--r--modules/commands/ns_group.cpp4
-rw-r--r--modules/commands/ns_register.cpp4
-rw-r--r--modules/commands/os_oper.cpp7
-rw-r--r--modules/extra/m_sql_oper.cpp27
-rw-r--r--src/messages.cpp4
-rw-r--r--src/opertype.cpp18
8 files changed, 53 insertions, 20 deletions
diff --git a/include/opertype.h b/include/opertype.h
index 9dd74e193..f40f4722a 100644
--- a/include/opertype.h
+++ b/include/opertype.h
@@ -31,9 +31,10 @@ struct CoreExport Oper
std::vector<Anope::string> hosts;
Anope::string vhost;
- Oper(const Anope::string &n, OperType *o) : name(n), ot(o), require_oper(false), config(false) { }
+ Oper(const Anope::string &n, OperType *o);
+ virtual ~Oper();
- virtual ~Oper() { }
+ static std::vector<Oper *> opers;
/** Find an oper block by name
* @param name The name
diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp
index 24e13b176..2e503b0d7 100644
--- a/modules/commands/hs_request.cpp
+++ b/modules/commands/hs_request.cpp
@@ -373,9 +373,9 @@ static void req_send_memos(Module *me, CommandSource &source, const Anope::strin
host = vHost;
if (Config->GetModule(me)->Get<bool>("memooper") && memoserv)
- for (unsigned i = 0; i < Config->Opers.size(); ++i)
+ for (unsigned i = 0; i < Oper::opers.size(); ++i)
{
- Oper *o = Config->Opers[i];
+ Oper *o = Oper::opers[i];
const NickAlias *na = NickAlias::Find(o->name);
if (!na)
diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp
index c40b5bf89..848416fe8 100644
--- a/modules/commands/ns_group.cpp
+++ b/modules/commands/ns_group.cpp
@@ -99,9 +99,9 @@ class CommandNSGroup : public Command
}
if (Config->GetModule("nickserv")->Get<bool>("restrictopernicks"))
- for (unsigned i = 0; i < Config->Opers.size(); ++i)
+ for (unsigned i = 0; i < Oper::opers.size(); ++i)
{
- Oper *o = Config->Opers[i];
+ Oper *o = Oper::opers[i];
if (!u->HasMode("OPER") && u->nick.find_ci(o->name) != Anope::string::npos)
{
diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp
index a88306fe0..b38cf750d 100644
--- a/modules/commands/ns_register.cpp
+++ b/modules/commands/ns_register.cpp
@@ -160,9 +160,9 @@ class CommandNSRegister : public Command
}
if (Config->GetModule("nickserv")->Get<bool>("restrictopernicks"))
- for (unsigned i = 0; i < Config->Opers.size(); ++i)
+ for (unsigned i = 0; i < Oper::opers.size(); ++i)
{
- Oper *o = Config->Opers[i];
+ Oper *o = Oper::opers[i];
if (!source.IsOper() && u_nick.find_ci(o->name) != Anope::string::npos)
{
diff --git a/modules/commands/os_oper.cpp b/modules/commands/os_oper.cpp
index 9bc9326fb..e4eafe2df 100644
--- a/modules/commands/os_oper.cpp
+++ b/modules/commands/os_oper.cpp
@@ -244,10 +244,13 @@ class OSOper : public Module
{
for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
{
- const NickCore *nc = it->second;
+ NickCore *nc = it->second;
- if (nc->o && !nc->o->config)
+ if (nc->o && dynamic_cast<MyOper *>(nc->o))
+ {
delete nc->o;
+ nc->o = NULL;
+ }
}
}
};
diff --git a/modules/extra/m_sql_oper.cpp b/modules/extra/m_sql_oper.cpp
index 772d484c6..85e5d8f7d 100644
--- a/modules/extra/m_sql_oper.cpp
+++ b/modules/extra/m_sql_oper.cpp
@@ -1,6 +1,11 @@
#include "module.h"
#include "modules/sql.h"
+struct SQLOper : Oper
+{
+ SQLOper(const Anope::string &n, OperType *o) : Oper(n, o) { }
+};
+
class SQLOperResult : public SQL::Interface
{
Reference<User> user;
@@ -44,13 +49,11 @@ class SQLOperResult : public SQL::Interface
BotInfo *OperServ = Config->GetClient("OperServ");
if (opertype.empty())
{
- if (user->Account() && user->Account()->o && !user->Account()->o->config)
+ if (user->Account() && user->Account()->o && !user->Account()->o->config && dynamic_cast<SQLOper *>(user->Account()->o))
{
- std::vector<Oper *>::iterator it = std::find(Config->Opers.begin(), Config->Opers.end(), user->Account()->o);
- if (it != Config->Opers.end())
- Config->Opers.erase(it);
delete user->Account()->o;
user->Account()->o = NULL;
+
Log(this->owner) << "m_sql_oper: Removed services operator from " << user->nick << " (" << user->Account()->display << ")";
user->RemoveMode(OperServ, "OPER"); // Probably not set, just incase
}
@@ -67,8 +70,7 @@ class SQLOperResult : public SQL::Interface
if (!user->Account()->o || user->Account()->o->ot != ot)
{
Log(this->owner) << "m_sql_oper: Tieing oper " << user->nick << " to type " << opertype;
- user->Account()->o = new Oper(user->Account()->display, ot);
- Config->Opers.push_back(user->Account()->o);
+ user->Account()->o = new SQLOper(user->Account()->display, ot);
}
if (!user->HasMode("OPER"))
@@ -97,7 +99,20 @@ class ModuleSQLOper : public Module
public:
ModuleSQLOper(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR)
{
+ }
+ ~ModuleSQLOper()
+ {
+ for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
+ {
+ NickCore *nc = it->second;
+
+ if (nc->o && dynamic_cast<SQLOper *>(nc->o))
+ {
+ delete nc->o;
+ nc->o = NULL;
+ }
+ }
}
void OnReload(Configuration::Conf *conf) anope_override
diff --git a/src/messages.cpp b/src/messages.cpp
index b757dde8f..639b07a58 100644
--- a/src/messages.cpp
+++ b/src/messages.cpp
@@ -405,9 +405,9 @@ void Stats::Run(MessageSource &source, const std::vector<Anope::string> &params)
IRCD->SendNumeric(219, source.GetSource(), "%c :End of /STATS report.", params[0][0]);
else
{
- for (unsigned i = 0; i < Config->Opers.size(); ++i)
+ for (unsigned i = 0; i < Oper::opers.size(); ++i)
{
- Oper *o = Config->Opers[i];
+ Oper *o = Oper::opers[i];
const NickAlias *na = NickAlias::Find(o->name);
if (na)
diff --git a/src/opertype.cpp b/src/opertype.cpp
index 0db17464d..153b735ab 100644
--- a/src/opertype.cpp
+++ b/src/opertype.cpp
@@ -12,11 +12,25 @@
#include "opertype.h"
#include "config.h"
+std::vector<Oper *> Oper::opers;
+
+Oper::Oper(const Anope::string &n, OperType *o) : name(n), ot(o), require_oper(false), config(false)
+{
+ opers.push_back(this);
+}
+
+Oper::~Oper()
+{
+ std::vector<Oper *>::iterator it = std::find(opers.begin(), opers.end(), this);
+ if (it != opers.end())
+ opers.erase(it);
+}
+
Oper *Oper::Find(const Anope::string &name)
{
- for (unsigned i = 0; i < Config->Opers.size(); ++i)
+ for (unsigned i = 0; i < opers.size(); ++i)
{
- Oper *o = Config->Opers[i];
+ Oper *o = opers[i];
if (o->name.equals_ci(name))
return o;