1
0
mirror of https://github.com/anope/anope.git synced 2026-06-12 19:14:47 +02:00

Don't leak opers and opertypes on /os reload, fix not updating opertypes on non conf opers on rehash

This commit is contained in:
Adam
2013-12-19 21:34:21 -05:00
parent ab6cd3b26c
commit c0cd76a0a5
6 changed files with 42 additions and 13 deletions
+1
View File
@@ -129,6 +129,7 @@ namespace Configuration
Anope::map<Anope::string> bots;
Conf();
~Conf();
void LoadConf(File &file);
-2
View File
@@ -25,8 +25,6 @@ struct CoreExport Oper
bool require_oper;
Anope::string password;
Anope::string certfp;
/* True if this operator is set in the config */
bool config;
/* Hosts allowed to use this operator block */
std::vector<Anope::string> hosts;
Anope::string vhost;
+1 -1
View File
@@ -145,7 +145,7 @@ class CommandOSOper : public Command
continue;
source.Reply(_("%-8s %s"), nc->o->name.c_str(), nc->o->ot->GetName().c_str());
if (nc->o->config)
if (std::find(Config->Opers.begin(), Config->Opers.end(), nc->o) != Config->Opers.end())
source.Reply(_(" This oper is configured in the configuration file."));
for (std::list<User *>::const_iterator uit = nc->users.begin(); uit != nc->users.end(); ++uit)
{
+1 -1
View File
@@ -49,7 +49,7 @@ class SQLOperResult : public SQL::Interface
BotInfo *OperServ = Config->GetClient("OperServ");
if (opertype.empty())
{
if (user->Account() && user->Account()->o && !user->Account()->o->config && dynamic_cast<SQLOper *>(user->Account()->o))
if (user->Account() && user->Account()->o && dynamic_cast<SQLOper *>(user->Account()->o))
{
delete user->Account()->o;
user->Account()->o = NULL;
+38 -8
View File
@@ -295,7 +295,6 @@ Conf::Conf() : Block("")
Oper *o = new Oper(nname, ot);
o->require_oper = require_oper;
o->config = true;
o->password = password;
o->certfp = certfp;
spacesepstream(host).GetTokens(o->hosts);
@@ -492,12 +491,15 @@ Conf::Conf() : Block("")
/* Below here can't throw */
for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
{
NickCore *nc = it->second;
if (nc->o && nc->o->config)
nc->o = NULL;
}
if (Config)
/* Clear existing conf opers */
for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
{
NickCore *nc = it->second;
if (nc->o && std::find(Config->Opers.begin(), Config->Opers.end(), nc->o) != Config->Opers.end())
nc->o = NULL;
}
/* Apply new opers */
for (unsigned i = 0; i < this->Opers.size(); ++i)
{
Oper *o = this->Opers[i];
@@ -556,18 +558,46 @@ Conf::Conf() : Block("")
}
#endif
/* Apply module chnages */
if (Config)
{
/* Apply module chnages */
for (unsigned i = 0; i < Config->ModulesAutoLoad.size(); ++i)
if (std::find(this->ModulesAutoLoad.begin(), this->ModulesAutoLoad.end(), Config->ModulesAutoLoad[i]) == this->ModulesAutoLoad.end())
ModuleManager::UnloadModule(ModuleManager::FindModule(Config->ModulesAutoLoad[i]), NULL);
for (unsigned i = 0; i < this->ModulesAutoLoad.size(); ++i)
if (std::find(Config->ModulesAutoLoad.begin(), Config->ModulesAutoLoad.end(), this->ModulesAutoLoad[i]) == Config->ModulesAutoLoad.end())
ModuleManager::LoadModule(this->ModulesAutoLoad[i], NULL);
/* Apply opertype changes, as non-conf opers still point to the old oper types */
for (unsigned i = Oper::opers.size(); i > 0; --i)
{
Oper *o = Oper::opers[i - 1];
/* Oper's type is in the old config, so update it */
if (std::find(Config->MyOperTypes.begin(), Config->MyOperTypes.end(), o->ot) != Config->MyOperTypes.end())
{
OperType *ot = o->ot;
o->ot = NULL;
for (unsigned j = 0; j < MyOperTypes.size(); ++j)
if (ot->GetName() == MyOperTypes[j]->GetName())
o->ot = MyOperTypes[j];
if (o->ot == NULL)
delete o; /* Oper block has lost type */
}
}
}
}
Conf::~Conf()
{
for (unsigned i = 0; i < MyOperTypes.size(); ++i)
delete MyOperTypes[i];
for (unsigned i = 0; i < Opers.size(); ++i)
delete Opers[i];
}
Block *Conf::GetModule(Module *m)
{
if (!m)
+1 -1
View File
@@ -14,7 +14,7 @@
std::vector<Oper *> Oper::opers;
Oper::Oper(const Anope::string &n, OperType *o) : name(n), ot(o), require_oper(false), config(false)
Oper::Oper(const Anope::string &n, OperType *o) : name(n), ot(o), require_oper(false)
{
opers.push_back(this);
}