Skip to content

Commit

Permalink
Fix oper override triggering upon viewing list modes (resolves inspir…
Browse files Browse the repository at this point in the history
  • Loading branch information
B00mX0r committed Jan 31, 2019
1 parent a580cac commit 942a758
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/modules/m_hidelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@


#include "inspircd.h"
#include "modules/hidelist.h"

class ListWatcher : public ModeWatcher
{
// Minimum rank required to view the list
const unsigned int minrank;
Events::ModuleEventProvider evprov;

public:
ListWatcher(Module* mod, const std::string& modename, unsigned int rank)
: ModeWatcher(mod, modename, MODETYPE_CHANNEL)
, minrank(rank)
, evprov(mod, "event/hidelist")
{
}

Expand All @@ -46,6 +49,12 @@ class ListWatcher : public ModeWatcher
if (user->HasPrivPermission("channels/auspex"))
return true;

ModResult MOD_RESULT;
FOREACH_MOD_CUSTOM(evprov, HideListEventListener, OnListDeny, (user, chan, GetModeName()));
if (MOD_RESULT == MOD_RES_ALLOW)
return true;


user->WriteNumeric(ERR_CHANOPRIVSNEEDED, chan->name, InspIRCd::Format("You do not have access to view the %s list", GetModeName().c_str()));
return false;
}
Expand Down
29 changes: 26 additions & 3 deletions src/modules/m_override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "inspircd.h"
#include "modules/invite.h"
#include "modules/hidelist.h"

class Override : public SimpleUserModeHandler
{
Expand All @@ -38,7 +39,7 @@ class Override : public SimpleUserModeHandler
}
};

class ModuleOverride : public Module
class ModuleOverride : public Module, public HideListEventListener
{
bool RequireKey;
bool NoisyOverride;
Expand Down Expand Up @@ -78,7 +79,8 @@ class ModuleOverride : public Module

public:
ModuleOverride()
: UmodeEnabled(false)
: HideListEventListener(this)
, UmodeEnabled(false)
, ou(this)
, topiclock(this, "topiclock")
, inviteonly(this, "inviteonly")
Expand Down Expand Up @@ -174,8 +176,14 @@ class ModuleOverride : public Module
{
const Modes::Change& item = *i;
if (!item.param.empty())
{
params.append(1, ' ').append(item.param);

}
else if (item.mh->IsListMode())
{
// Listmode overrides are dealt with in OnListDeny
return MOD_RES_PASSTHRU;
}
char wanted_pm = (item.adding ? '+' : '-');
if (wanted_pm != pm)
{
Expand All @@ -192,6 +200,21 @@ class ModuleOverride : public Module
return MOD_RES_PASSTHRU;
}

ModResult OnListDeny(User* user, Channel* chan, const std::string& modename) CXX11_OVERRIDE
{
if (!user->IsOper() || !IS_LOCAL(user))
return MOD_RES_PASSTHRU;

if (CanOverride(user, "MODE"))
{
const std::string msg = user->nick + " overriding hidelist: " + modename;

ServerInstance->SNO->WriteGlobalSno('v', msg);
return MOD_RES_ALLOW;
}
return MOD_RES_PASSTHRU;
}

ModResult OnUserPreJoin(LocalUser* user, Channel* chan, const std::string& cname, std::string& privs, const std::string& keygiven) CXX11_OVERRIDE
{
if (user->IsOper())
Expand Down

0 comments on commit 942a758

Please sign in to comment.