diff options
author | peavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-02-11 03:09:01 +0000 |
---|---|---|
committer | peavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-02-11 03:09:01 +0000 |
commit | 35d20fbabe8babe761e938e4c9a65c47f303f81d (patch) | |
tree | d63df9936c370eae9bea4142a1b11454a229e87e /src | |
parent | 6e470a0c86707d897f61fe98c77e242b6011fe3b (diff) |
Remove/Add cmode h according to <option:allowhalfop>. Fixes bug #715 reported by Strawberry.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11081 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/configreader.cpp | 44 | ||||
-rw-r--r-- | src/mode.cpp | 29 | ||||
-rw-r--r-- | src/modes/cmode_h.cpp | 9 |
3 files changed, 39 insertions, 43 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp index 7f88eefef..0c9510553 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -30,6 +30,7 @@ #include "xline.h" #include "exitcodes.h" #include "commands/cmd_whowas.h" +#include "modes/cmode_h.h" std::vector<std::string> old_module_names, new_module_names, added_modules, removed_modules; @@ -359,6 +360,24 @@ bool ValidateMaxWho(ServerConfig* conf, const char*, const char*, ValueItem &dat return true; } +bool ValidateHalfOp(ServerConfig* conf, const char*, const char*, ValueItem &data) +{ + ModeHandler* mh = conf->GetInstance()->Modes->FindMode('h', MODETYPE_CHANNEL); + if (data.GetBool() && !mh) + { + conf->GetInstance()->Logs->Log("CONFIG",DEFAULT,"Enabling halfop mode."); + mh = new ModeChannelHalfOp(conf->GetInstance()); + conf->GetInstance()->Modes->AddMode(mh); + } + else if (!data.GetBool() && mh) + { + conf->GetInstance()->Logs->Log("CONFIG",DEFAULT,"Disabling halfop mode."); + conf->GetInstance()->Modes->DelMode(mh); + delete mh; + } + return true; +} + bool ValidateMotd(ServerConfig* conf, const char*, const char*, ValueItem &data) { conf->ReadFile(conf->MOTD, data.GetString()); @@ -471,7 +490,7 @@ bool InitConnect(ServerConfig* conf, const char*) if (c->RefCount == 0) { conf->GetInstance()->Logs->Log("CONFIG",DEFAULT, "Removing connect class, refcount is 0!"); - + /* This was causing a crash, because we'd set i to .begin() just here, but then the for loop's increment would * set it to .begin() + 1. Which if it was already the last thing in the list, wasn't good. * Now the increment is in the else { } below. @@ -797,7 +816,7 @@ void ServerConfig::Read(bool bail, const std::string &useruid) {"options", "fixedpart", "", new ValueContainerChar (this->FixedPart), DT_CHARPTR, NoValidation}, {"performance", "netbuffersize","10240", new ValueContainerInt (&this->NetBufferSize), DT_INTEGER, ValidateNetBufferSize}, {"performance", "maxwho", "128", new ValueContainerInt (&this->MaxWhoResults), DT_INTEGER, ValidateMaxWho}, - {"options", "allowhalfop", "0", new ValueContainerBool (&this->AllowHalfop), DT_BOOLEAN, NoValidation}, + {"options", "allowhalfop", "0", new ValueContainerBool (&this->AllowHalfop), DT_BOOLEAN, ValidateHalfOp}, {"dns", "server", "", new ValueContainerChar (this->DNSServer), DT_IPADDRESS,DNSServerValidator}, {"dns", "timeout", "5", new ValueContainerInt (&this->dns_timeout), DT_INTEGER, NoValidation}, {"options", "moduledir", MOD_PATH, new ValueContainerChar (this->ModPath), DT_CHARPTR, NoValidation}, @@ -897,7 +916,7 @@ void ServerConfig::Read(bool bail, const std::string &useruid) {"No reason", "", NULL}, {DT_CHARPTR, DT_CHARPTR}, InitXLine, DoQLine, DoneConfItem}, - + {"badhost", {"reason", "host", NULL}, {"No reason", "", NULL}, @@ -909,7 +928,7 @@ void ServerConfig::Read(bool bail, const std::string &useruid) {"No reason", "", NULL}, {DT_CHARPTR, DT_CHARPTR}, InitXLine, DoELine, DoneELine}, - + {"type", {"name", "classes", NULL}, {"", "", NULL}, @@ -921,7 +940,7 @@ void ServerConfig::Read(bool bail, const std::string &useruid) {"", "", "", "", "", NULL}, {DT_NOSPACES, DT_CHARPTR, DT_CHARPTR, DT_CHARPTR, DT_CHARPTR}, InitClasses, DoClass, DoneClassesAndTypes}, - + {NULL, {NULL}, {NULL}, @@ -940,7 +959,7 @@ void ServerConfig::Read(bool bail, const std::string &useruid) delete errstr; return; } - + delete errstr; /* The stuff in here may throw CoreException, be sure we're in a position to catch it. */ @@ -982,10 +1001,10 @@ void ServerConfig::Read(bool bail, const std::string &useruid) ConfValue(newconfig, Values[Index].tag, Values[Index].value, Values[Index].default_value, 0, item, MAXBUF, allow_newlines); ValueItem vi(item); - + if (!Values[Index].validation_function(this, Values[Index].tag, Values[Index].value, vi)) throw CoreException("One or more values in your configuration file failed to validate. Please see your ircd.log for more information."); - + ServerInstance->Threads->Lock(); switch (dt) { @@ -1511,7 +1530,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, FILE* &conf, const char* fil { // errorstream << "Closing config tag on line " << linenumber << std::endl; in_tag = false; - + /* * If this finds an <include> then ParseLine can simply call * LoadConf() and load the included config into the same ConfigDataHash @@ -1522,7 +1541,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, FILE* &conf, const char* fil last_successful_parse = linenumber; linenumber = bl; - + line.clear(); } else @@ -1667,7 +1686,7 @@ bool ServerConfig::ParseLine(ConfigDataHash &target, const std::string &filename got_key = false; if ((tagname == "include") && (current_key == "file")) - { + { if (!this->DoInclude(target, current_value, errorstream)) return false; } @@ -2007,7 +2026,7 @@ bool ServerConfig::FileExists(const char* file) if ((sb.st_mode & S_IFDIR) > 0) return false; - + FILE *input; if ((input = fopen (file, "r")) == NULL) return false; @@ -2356,4 +2375,3 @@ void ConfigReaderThread::Run() this->SetExitFlag(); ServerInstance->Threads->Unlock(); } - diff --git a/src/mode.cpp b/src/mode.cpp index f2bbb98e5..e7f918e62 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -378,7 +378,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, seq++; mask = MASK_CHANNEL; - + while (mode && *mode) { unsigned char mletter = *mode; @@ -388,7 +388,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, mode++; continue; } - + /* Ensure the user doesnt request the same mode twice, * so they cant flood themselves off out of idiocy. */ @@ -432,7 +432,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, for(ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++) { std::string dummyparam; - + if (!((*watchers)->BeforeMode(user, NULL, targetchannel, dummyparam, true, MODETYPE_CHANNEL))) display = false; } @@ -605,7 +605,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, */ if (needed && !prefixmode) prefixmode = FindPrefix('%'); - + unsigned int neededrank = prefixmode->GetPrefixRank(); /* Compare our rank on the channel against the rank of the required prefix, * allow if >= ours. Because mIRC and xchat throw a tizz if the modes shown @@ -626,7 +626,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, } bool had_parameter = !parameter.empty(); - + for (ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++) { if ((*watchers)->BeforeMode(user, targetuser, targetchannel, parameter, adding, type, servermode) == false) @@ -700,7 +700,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, output_sequence.append(adding ? "+" : "-"); last_successful_state_change = adding; } - + /* Add the mode letter */ output_sequence.push_back(modechar); @@ -931,9 +931,6 @@ std::string ModeParser::ChannelModeList() for (unsigned char mode = 'A'; mode <= 'z'; mode++) { - if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h')) - continue; - unsigned char pos = (mode-65) | MASK_CHANNEL; if (modehandlers[pos]) @@ -950,9 +947,6 @@ std::string ModeParser::ParaModeList() for (unsigned char mode = 'A'; mode <= 'z'; mode++) { - if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h')) - continue; - unsigned char pos = (mode-65) | MASK_CHANNEL; if ((modehandlers[pos]) && (modehandlers[pos]->GetNumParams(true))) @@ -1019,13 +1013,10 @@ std::string ModeParser::GiveModeList(ModeMasks m) for (unsigned char mode = 'A'; mode <= 'z'; mode++) { - if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h')) - continue; - unsigned char pos = (mode-65) | m; /* One parameter when adding */ if (modehandlers[pos]) - { + { if (modehandlers[pos]->GetNumParams(true)) { if ((modehandlers[pos]->IsListMode()) && (!modehandlers[pos]->GetPrefix())) @@ -1055,14 +1046,13 @@ std::string ModeParser::GiveModeList(ModeMasks m) type4 += modehandlers[pos]->GetModeChar(); } } - } return type1 + "," + type2 + "," + type3 + "," + type4; } bool ModeParser::PrefixComparison(prefixtype one, prefixtype two) -{ +{ return one.second > two.second; } @@ -1075,9 +1065,6 @@ std::string ModeParser::BuildPrefixes() for (unsigned char mode = 'A'; mode <= 'z'; mode++) { - if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h')) - continue; - unsigned char pos = (mode-65) | MASK_CHANNEL; if ((modehandlers[pos]) && (modehandlers[pos]->GetPrefix())) diff --git a/src/modes/cmode_h.cpp b/src/modes/cmode_h.cpp index b50459b87..c3bb92576 100644 --- a/src/modes/cmode_h.cpp +++ b/src/modes/cmode_h.cpp @@ -77,15 +77,6 @@ void ModeChannelHalfOp::RemoveMode(User*, irc::modestacker* stack) ModeAction ModeChannelHalfOp::OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding, bool servermode) { - /* If halfops are not enabled in the conf, we don't execute - * anything in this class at all. - */ - if (!ServerInstance->Config->AllowHalfop) - { - parameter = ""; - return MODEACTION_DENY; - } - int status = channel->GetStatus(source); /* Call the correct method depending on wether we're adding or removing the mode */ |