From d11323cf349815197d824facf79b6fdbfc9f5a98 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Mon, 27 Oct 2014 21:10:03 +0100 Subject: Allow setting a limit of less than 64 entries for non-ban listmodes via Fixes regression introduced in 234be2f3cb --- src/modules/u_listmode.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/modules') diff --git a/src/modules/u_listmode.h b/src/modules/u_listmode.h index 30bf6a48f..a728eb839 100644 --- a/src/modules/u_listmode.h +++ b/src/modules/u_listmode.h @@ -294,6 +294,8 @@ class ListModeBase : public ModeHandler return MODEACTION_DENY; } } + else + break; } } -- cgit v1.2.3 From c5f19db85c2a2669884eb8ac72362c86afb65617 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sun, 30 Nov 2014 18:24:17 +0100 Subject: Don't submit a reload worker if the module doing the reload is scheduled for unload --- src/commands/cmd_reloadmodule.cpp | 2 +- src/modules/m_globalload.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/commands/cmd_reloadmodule.cpp b/src/commands/cmd_reloadmodule.cpp index 81ecce1cb..eac364f0e 100644 --- a/src/commands/cmd_reloadmodule.cpp +++ b/src/commands/cmd_reloadmodule.cpp @@ -66,7 +66,7 @@ CmdResult CommandReloadmodule::Handle (const std::vector& parameter Module* m = ServerInstance->Modules->Find(parameters[0]); if (m) { - ServerInstance->Modules->Reload(m, new ReloadModuleWorker(user->uuid, parameters[0])); + ServerInstance->Modules->Reload(m, (creator->dying ? NULL : new ReloadModuleWorker(user->uuid, parameters[0]))); return CMD_SUCCESS; } else diff --git a/src/modules/m_globalload.cpp b/src/modules/m_globalload.cpp index 9e0ec7705..aed65045f 100644 --- a/src/modules/m_globalload.cpp +++ b/src/modules/m_globalload.cpp @@ -151,7 +151,7 @@ class CommandGreloadmodule : public Command if (m) { GReloadModuleWorker* worker = NULL; - if (m != creator) + if ((m != creator) && (!creator->dying)) worker = new GReloadModuleWorker(user->nick, user->uuid, parameters[0]); ServerInstance->Modules->Reload(m, worker); } -- cgit v1.2.3 From e4167bc3a150116e4235cfa106ab72ee0d14faca Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Wed, 10 Dec 2014 17:50:31 +0100 Subject: m_httpd On module unload close all connections hooked by the module being unloaded --- src/modules/m_httpd.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index 2a430d967..2b079c6ff 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -348,7 +348,7 @@ class ModuleHttpServer : public Module void init() { HttpModule = this; - Implementation eventlist[] = { I_OnAcceptConnection, I_OnBackgroundTimer, I_OnRehash }; + Implementation eventlist[] = { I_OnAcceptConnection, I_OnBackgroundTimer, I_OnRehash, I_OnUnloadModule }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); OnRehash(NULL); } @@ -397,6 +397,20 @@ class ModuleHttpServer : public Module } } + void OnUnloadModule(Module* mod) + { + for (std::set::const_iterator i = sockets.begin(); i != sockets.end(); ) + { + HttpServerSocket* sock = *i; + ++i; + if (sock->GetIOHook() == mod) + { + sock->cull(); + delete sock; + } + } + } + CullResult cull() { std::set local; -- cgit v1.2.3 From 8365be5414ae0f6d09724bd540db41ba24b2a7fd Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sat, 27 Dec 2014 14:50:22 +0100 Subject: m_check Fix non-standard format specifier %s passed to strftime() causing problems on systems not supporting it (Windows) --- src/modules/m_check.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 96b357f20..9c5c414f1 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -38,8 +38,10 @@ class CommandCheck : public Command { char timebuf[60]; struct tm *mytime = gmtime(&time); - strftime(timebuf, 59, "%Y-%m-%d %H:%M:%S UTC (%s)", mytime); - return std::string(timebuf); + strftime(timebuf, 59, "%Y-%m-%d %H:%M:%S UTC (", mytime); + std::string ret(timebuf); + ret.append(ConvToStr(time)).push_back(')'); + return ret; } void dumpExt(User* user, const std::string& checkstr, Extensible* ext) -- cgit v1.2.3 From e27820683226e3832936bccd537b45bc04208f74 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Sat, 3 Jan 2015 20:33:09 +0000 Subject: Fix a snotice in m_spanningtree incorrectly using an unsigned long. This value can be negative so it should be a signed long not an unsigned long. --- src/modules/m_spanningtree/fjoin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index c8cd768aa..47b394522 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -86,8 +86,8 @@ CmdResult CommandFJoin::Handle(const std::vector& params, User *src time_t ourTS = chan->age; if (TS != ourTS) - ServerInstance->SNO->WriteToSnoMask('d', "Merge FJOIN received for %s, ourTS: %lu, TS: %lu, difference: %lu", - chan->name.c_str(), (unsigned long)ourTS, (unsigned long)TS, (unsigned long)(ourTS - TS)); + ServerInstance->SNO->WriteToSnoMask('d', "Merge FJOIN received for %s, ourTS: %lu, TS: %lu, difference: %ld", + chan->name.c_str(), (unsigned long)ourTS, (unsigned long)TS, (long)(ourTS - TS)); /* If our TS is less than theirs, we dont accept their modes */ if (ourTS < TS) { -- cgit v1.2.3 From ae4017f4459de4945754dae658f731a19fe7fd64 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sat, 17 Jan 2015 15:27:09 +0100 Subject: m_hideoper Fix wrong /WHO output for hidden opers if the channel name contains '*' --- src/modules/m_hideoper.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index b83c7de1a..88b0c4cdf 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -82,7 +82,11 @@ class ModuleHideOper : public Module if (user->IsModeSet('H') && !source->HasPrivPermission("users/auspex")) { // hide the "*" that marks the user as an oper from the /WHO line - std::string::size_type pos = line.find("*"); + std::string::size_type spcolon = line.find(" :"); + if (spcolon == std::string::npos) + return; // Another module hid the user completely + std::string::size_type sp = line.rfind(' ', spcolon-1); + std::string::size_type pos = line.find('*', sp); if (pos != std::string::npos) line.erase(pos, 1); // hide the line completely if doing a "/who * o" query -- cgit v1.2.3 From 17b4151bff2edcec3f3524cc60e536407c70cec6 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Mon, 19 Jan 2015 17:43:58 +0100 Subject: m_operprefix Fix force joined opers not being given the operprefix mode --- src/modules/m_operprefix.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp index 62ddb6c67..9f1f6cc5e 100644 --- a/src/modules/m_operprefix.cpp +++ b/src/modules/m_operprefix.cpp @@ -85,7 +85,7 @@ class ModuleOperPrefixMode : public Module { ServerInstance->Modules->AddService(opm); - Implementation eventlist[] = { I_OnUserPreJoin, I_OnPostOper, I_OnLoadModule, I_OnUnloadModule }; + Implementation eventlist[] = { I_OnUserPreJoin, I_OnPostOper, I_OnLoadModule, I_OnUnloadModule, I_OnPostJoin }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); /* To give clients a chance to learn about the new prefix we don't give +y to opers @@ -110,6 +110,22 @@ class ModuleOperPrefixMode : public Module return MOD_RES_PASSTHRU; } + void OnPostJoin(Membership* memb) + { + if ((!IS_LOCAL(memb->user)) || (!IS_OPER(memb->user)) || (((mw_added) && (memb->user->IsModeSet('H'))))) + return; + + if (memb->hasMode(opm.GetModeChar())) + return; + + // The user was force joined and OnUserPreJoin() did not run. Set the operprefix now. + std::vector modechange; + modechange.push_back(memb->chan->name); + modechange.push_back("+y"); + modechange.push_back(memb->user->nick); + ServerInstance->SendGlobalMode(modechange, ServerInstance->FakeClient); + } + void SetOperPrefix(User* user, bool add) { std::vector modechange; -- cgit v1.2.3 From f8185feff704c19326dc7af767a875b22a8f85e0 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Wed, 21 Jan 2015 19:08:30 +0100 Subject: m_abbreviation Fix typo in numeric text --- src/modules/m_abbreviation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_abbreviation.cpp b/src/modules/m_abbreviation.cpp index a744f55f6..1e8f71176 100644 --- a/src/modules/m_abbreviation.cpp +++ b/src/modules/m_abbreviation.cpp @@ -79,7 +79,7 @@ class ModuleAbbreviation : public Module /* Ambiguous command, list the matches */ if (!matchlist.empty()) { - user->WriteNumeric(420, "%s :Ambiguous abbreviation, posssible matches: %s%s", user->nick.c_str(), foundcommand.c_str(), matchlist.c_str()); + user->WriteNumeric(420, "%s :Ambiguous abbreviation, possible matches: %s%s", user->nick.c_str(), foundcommand.c_str(), matchlist.c_str()); return MOD_RES_DENY; } -- cgit v1.2.3 From f6ace5e8084e2ab23f6797ab9d77a41466ea4a78 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Wed, 4 Feb 2015 18:53:28 +0100 Subject: m_spanningtree Fix TreeRoot UserCount being possibly wrong if loaded after startup --- src/modules/m_spanningtree/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 5f06cad58..967b577b1 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -88,7 +88,7 @@ void ModuleSpanningTree::init() loopCall = false; // update our local user count - Utils->TreeRoot->SetUserCount(ServerInstance->Users->local_users.size()); + Utils->TreeRoot->SetUserCount(ServerInstance->Users->LocalUserCount()); } void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops) -- cgit v1.2.3 From db7b2a603d4a4ce0f9bc71173b379b42d0416759 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Thu, 26 Feb 2015 07:41:46 +0000 Subject: Fix various Clang warnings. - warning: 'register' storage class specifier is deprecated. --- src/hashcomp.cpp | 4 ++-- src/modules/m_md5.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/modules') diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 3fb7f84fb..e0347421b 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -140,7 +140,7 @@ void nspace::strlower(char *n) * only with *x replaced with national_case_insensitive_map[*x]. * This avoids a copy to use hash */ - register size_t t = 0; + size_t t = 0; for (std::string::const_iterator x = s.begin(); x != s.end(); ++x) /* ++x not x++, as its faster */ t = 5 * t + national_case_insensitive_map[(unsigned char)*x]; return t; @@ -149,7 +149,7 @@ void nspace::strlower(char *n) size_t CoreExport irc::hash::operator()(const irc::string &s) const { - register size_t t = 0; + size_t t = 0; for (irc::string::const_iterator x = s.begin(); x != s.end(); ++x) /* ++x not x++, as its faster */ t = 5 * t + national_case_insensitive_map[(unsigned char)*x]; return t; diff --git a/src/modules/m_md5.cpp b/src/modules/m_md5.cpp index 14ccf16a8..c902ee3cb 100644 --- a/src/modules/m_md5.cpp +++ b/src/modules/m_md5.cpp @@ -163,7 +163,7 @@ class MD5Provider : public HashProvider void MD5Transform(word32 buf[4], word32 const in[16]) { - register word32 a, b, c, d; + word32 a, b, c, d; a = buf[0]; b = buf[1]; -- cgit v1.2.3 From 8723866b4cdf100892677ab5c1619fcee9536d9b Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Mon, 13 Apr 2015 15:40:26 +0200 Subject: m_timedbans Store Channel pointer in struct TimedBan --- src/modules/m_timedbans.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/modules') diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index 497ac2569..f633bc3e2 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -32,6 +32,7 @@ class TimedBan std::string channel; std::string mask; time_t expire; + Channel* chan; }; typedef std::vector timedbans; @@ -98,6 +99,7 @@ found: T.channel = channelname; T.mask = mask; T.expire = expire + (IS_REMOTE(user) ? 5 : 0); + T.chan = channel; TimedBanList.push_back(T); // If halfop is loaded, send notice to halfops and above, otherwise send to ops and above -- cgit v1.2.3 From 0243179509eb8a561b62c7845dc1322fcd94654a Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Mon, 13 Apr 2015 15:42:06 +0200 Subject: m_timedbans On channel destruction remove all timed bans belonging to the channel from internal bookkeeping --- src/modules/m_timedbans.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index f633bc3e2..ef1ae4c48 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -116,6 +116,22 @@ found: } }; +class ChannelMatcher +{ + Channel* const chan; + + public: + ChannelMatcher(Channel* ch) + : chan(ch) + { + } + + bool operator()(const TimedBan& tb) const + { + return (tb.chan == chan); + } +}; + class ModuleTimedBans : public Module { CommandTban cmd; @@ -128,7 +144,7 @@ class ModuleTimedBans : public Module void init() { ServerInstance->Modules->AddService(cmd); - Implementation eventlist[] = { I_OnDelBan, I_OnBackgroundTimer }; + Implementation eventlist[] = { I_OnDelBan, I_OnBackgroundTimer, I_OnChannelDelete }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } @@ -185,6 +201,12 @@ class ModuleTimedBans : public Module } } + void OnChannelDelete(Channel* chan) + { + // Remove all timed bans affecting the channel from internal bookkeeping + TimedBanList.erase(std::remove_if(TimedBanList.begin(), TimedBanList.end(), ChannelMatcher(chan)), TimedBanList.end()); + } + virtual Version GetVersion() { return Version("Adds timed bans", VF_COMMON | VF_VENDOR); -- cgit v1.2.3 From b7526f6efd47ed87dc67adfa70f09c9b83adf9a8 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Mon, 13 Apr 2015 15:48:00 +0200 Subject: m_timedbans Extract IsBanSet() to a function --- src/modules/m_timedbans.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index ef1ae4c48..754b4c3a0 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -42,6 +42,16 @@ timedbans TimedBanList; */ class CommandTban : public Command { + static bool IsBanSet(Channel* chan, const std::string& mask) + { + for (BanList::const_iterator i = chan->bans.begin(); i != chan->bans.end(); ++i) + { + if (!strcasecmp(i->data.c_str(), mask.c_str())) + return true; + } + return false; + } + public: CommandTban(Module* Creator) : Command(Creator,"TBAN", 3) { @@ -90,11 +100,9 @@ class CommandTban : public Command // use CallHandler to make it so that the user sets the mode // themselves ServerInstance->Parser->CallHandler("MODE",setban,user); - for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++) - if (!strcasecmp(i->data.c_str(), mask.c_str())) - goto found; - return CMD_FAILURE; -found: + if (!IsBanSet(channel, mask)) + return CMD_FAILURE; + CUList tmp; T.channel = channelname; T.mask = mask; -- cgit v1.2.3 From 4e24fb7c19cff866eda602349fbafce78b7e4c51 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Mon, 13 Apr 2015 15:49:29 +0200 Subject: m_timedbans Notice user when trying to set a ban that's already set --- src/modules/m_timedbans.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/modules') diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index 754b4c3a0..b47327704 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -96,6 +96,13 @@ class CommandTban : public Command user->WriteServ("NOTICE "+user->nick+" :Invalid ban mask"); return CMD_FAILURE; } + + if (IsBanSet(channel, mask)) + { + user->WriteServ("NOTICE %s :Ban already set", user->nick.c_str()); + return CMD_FAILURE; + } + setban.push_back(mask); // use CallHandler to make it so that the user sets the mode // themselves -- cgit v1.2.3 From a0c331eff30434dc648638990f16f546c9467c37 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Thu, 16 Apr 2015 21:13:07 +0200 Subject: m_sasl Add missing validation for server-to-server SASL message --- src/modules/m_sasl.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/modules') diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index 66efcfe4e..b59fd3835 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -99,6 +99,9 @@ class SaslAuthenticator if (msg[0] != this->agent) return this->state; + if (msg.size() < 4) + return this->state; + if (msg[2] == "C") this->user->Write("AUTHENTICATE %s", msg[3].c_str()); else if (msg[2] == "D") -- cgit v1.2.3 From 9f69e159adcc0892f0bdef16ac4617630737b156 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Thu, 16 Apr 2015 23:00:56 +0200 Subject: m_dccallow Validate tokens before use --- src/modules/m_dccallow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/modules') diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index b42d12968..829c1d337 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -339,6 +339,9 @@ class ModuleDCCAllow : public Module while (ss >> buf) tokens.push_back(buf); + if (tokens.size() < 2) + return MOD_RES_PASSTHRU; + irc::string type = tokens[1].c_str(); ConfigTag* conftag = ServerInstance->Config->ConfValue("dccallow"); @@ -346,6 +349,9 @@ class ModuleDCCAllow : public Module if (type == "SEND") { + if (tokens.size() < 3) + return MOD_RES_PASSTHRU; + std::string defaultaction = conftag->getString("action"); std::string filename = tokens[2]; -- cgit v1.2.3 From b3c338c0948a2edec22d36a98d5962cbaae1619e Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Thu, 16 Apr 2015 23:12:47 +0200 Subject: m_sasl Update description, SASL is no longer exclusive to Atheme --- src/modules/m_sasl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index b59fd3835..32c9afc79 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -293,7 +293,7 @@ class ModuleSASL : public Module Version GetVersion() { - return Version("Provides support for IRC Authentication Layer (aka: atheme SASL) via AUTHENTICATE.",VF_VENDOR); + return Version("Provides support for IRC Authentication Layer (aka: SASL) via AUTHENTICATE.", VF_VENDOR); } void OnEvent(Event &ev) -- cgit v1.2.3