diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/config.cpp | 70 | ||||
-rw-r--r-- | src/extensible.cpp | 3 | ||||
-rw-r--r-- | src/init.cpp | 4 | ||||
-rw-r--r-- | src/users.cpp | 20 |
4 files changed, 63 insertions, 34 deletions
diff --git a/src/config.cpp b/src/config.cpp index 7e918e079..2fb38107b 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -538,48 +538,58 @@ Conf::Conf() : Block("") /* always enable icase and optimize */ if (regex_flags) regex_flags |= std::regex::icase | std::regex::optimize; +} - /* apply changes from an older config? */ - if (Config) +Conf::~Conf() +{ + for (unsigned i = 0; i < MyOperTypes.size(); ++i) + delete MyOperTypes[i]; + for (unsigned i = 0; i < Opers.size(); ++i) + delete Opers[i]; +} + +void Conf::Post(Conf *old) +{ + /* Apply module changes */ + for (unsigned i = 0; i < old->ModulesAutoLoad.size(); ++i) + if (std::find(this->ModulesAutoLoad.begin(), this->ModulesAutoLoad.end(), old->ModulesAutoLoad[i]) == this->ModulesAutoLoad.end()) + ModuleManager::UnloadModule(ModuleManager::FindModule(old->ModulesAutoLoad[i]), NULL); + for (unsigned i = 0; i < this->ModulesAutoLoad.size(); ++i) + if (std::find(old->ModulesAutoLoad.begin(), old->ModulesAutoLoad.end(), this->ModulesAutoLoad[i]) == old->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) { - /* 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(old->MyOperTypes.begin(), old->MyOperTypes.end(), o->ot) != old->MyOperTypes.end()) { - Oper *o = Oper::opers[i - 1]; + 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]; - /* 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()) + if (o->ot == NULL) { - OperType *ot = o->ot; - o->ot = NULL; + /* Oper block has lost type */ + std::vector<Oper *>::iterator it = std::find(old->Opers.begin(), old->Opers.end(), o); + if (it != old->Opers.end()) + old->Opers.erase(it); - for (unsigned j = 0; j < MyOperTypes.size(); ++j) - if (ot->GetName() == MyOperTypes[j]->GetName()) - o->ot = MyOperTypes[j]; + it = std::find(this->Opers.begin(), this->Opers.end(), o); + if (it != this->Opers.end()) + this->Opers.erase(it); - if (o->ot == NULL) - delete o; /* Oper block has lost type */ + delete o; } } } } -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) diff --git a/src/extensible.cpp b/src/extensible.cpp index 552ad5d2b..37206f7c1 100644 --- a/src/extensible.cpp +++ b/src/extensible.cpp @@ -49,9 +49,6 @@ void Extensible::ExtensibleSerialize(const Extensible *e, const Serializable *s, void Extensible::ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) { - while (!e->extension_items.empty()) - (*e->extension_items.begin())->Unset(e); - for (std::set<ExtensibleBase *>::iterator it = extensible_items.begin(); it != extensible_items.end(); ++it) { ExtensibleBase *eb = *it; diff --git a/src/init.cpp b/src/init.cpp index d31f79767..9b6b42c86 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -127,8 +127,10 @@ void Anope::HandleSignal() try { Configuration::Conf *new_config = new Configuration::Conf(); - delete Config; + Configuration::Conf *old = Config; Config = new_config; + Config->Post(old); + delete old; } catch (const ConfigException &ex) { diff --git a/src/users.cpp b/src/users.cpp index 3b874c0f2..81fd13a33 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -537,8 +537,28 @@ void User::SetModeInternal(const MessageSource &source, UserMode *um, const Anop this->modes[um->name] = param; if (um->name == "OPER") + { ++OperCount; + if (this->IsServicesOper()) + { + if (!this->nc->o->ot->modes.empty()) + { + this->SetModes(NULL, "%s", this->nc->o->ot->modes.c_str()); + this->SendMessage(Me, "Changing your usermodes to \002%s\002", this->nc->o->ot->modes.c_str()); + UserMode *oper = ModeManager::FindUserModeByName("OPER"); + if (oper && !this->HasMode("OPER") && this->nc->o->ot->modes.find(oper->mchar) != Anope::string::npos) + IRCD->SendOper(this); + } + if (IRCD->CanSetVHost && !this->nc->o->vhost.empty()) + { + this->SendMessage(Me, "Changing your vhost to \002%s\002", this->nc->o->vhost.c_str()); + this->SetDisplayedHost(this->nc->o->vhost); + IRCD->SendVhost(this, "", this->nc->o->vhost); + } + } + } + if (um->name == "CLOAK" || um->name == "VHOST") this->UpdateHost(); |