summaryrefslogtreecommitdiff
path: root/modules/core/cs_mode.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-03-12 02:40:08 -0500
committerAdam <Adam@anope.org>2011-03-12 02:40:08 -0500
commit95469fde3055e1a257fd4e1027617892b912d07c (patch)
tree5e0c5fd126c7d0151c1ded6cdbda1bb9e290947e /modules/core/cs_mode.cpp
parent9f46972f19060d2ede624bdec52b9091042e3735 (diff)
Added some access checks to cs_mode and fixed some language strings
Diffstat (limited to 'modules/core/cs_mode.cpp')
-rw-r--r--modules/core/cs_mode.cpp55
1 files changed, 54 insertions, 1 deletions
diff --git a/modules/core/cs_mode.cpp b/modules/core/cs_mode.cpp
index ad43baf70..209ee751f 100644
--- a/modules/core/cs_mode.cpp
+++ b/modules/core/cs_mode.cpp
@@ -15,6 +15,27 @@
class CommandCSMode : public Command
{
+ bool CanSet(User *u, ChannelInfo *ci, ChannelModeName mode)
+ {
+ switch (mode)
+ {
+ case CMODE_OWNER:
+ return check_access(u, ci, CA_OWNER);
+ case CMODE_PROTECT:
+ return check_access(u, ci, CA_PROTECT);
+ case CMODE_OP:
+ return check_access(u, ci, CA_OPDEOP);
+ case CMODE_HALFOP:
+ return check_access(u, ci, CA_HALFOP);
+ case CMODE_VOICE:
+ return check_access(u, ci, CA_VOICE);
+ default:
+ break;
+ }
+
+ return false;
+ }
+
void DoLock(CommandSource &source, const std::vector<Anope::string> &params)
{
User *u = source.u;
@@ -199,15 +220,35 @@ class CommandCSMode : public Command
ci->c->RemoveMode(NULL, cm);
break;
case MODE_STATUS:
+ {
if (!sep.GetToken(param))
break;
+
+ if (!this->CanSet(u, ci, cm->Name))
+ {
+ source.Reply(_("You do not have access to set mode %c."), cm->ModeChar);
+ break;
+ }
+
+ ChanAccess *u_access = ci->GetAccess(u);
+ int16 u_level = u_access ? u_access->level : 0;
+
if (str_is_wildcard(param))
{
for (CUserList::const_iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
{
UserContainer *uc = *it;
- if (Anope::Match(u->GetMask(), param))
+ ChanAccess *targ_access = ci->GetAccess(uc->user);
+ int16 t_level = targ_access ? targ_access->level : 0;
+
+ if (t_level > u_level)
+ {
+ source.Reply(_("You do not have the access to change %s's modes."), uc->user->nick.c_str());
+ continue;
+ }
+
+ if (Anope::Match(uc->user->GetMask(), param))
{
if (adding)
ci->c->SetMode(NULL, cm, uc->user->nick);
@@ -218,12 +259,24 @@ class CommandCSMode : public Command
}
else
{
+ User *target = finduser(param);
+ if (target != NULL)
+ {
+ ChanAccess *targ_access = ci->GetAccess(target);
+ int16 t_level = targ_access ? targ_access->level : 0;
+ if (t_level > u_level)
+ {
+ source.Reply(_("You do not have the access to change %s's modes."), target->nick.c_str());
+ break;
+ }
+ }
if (adding)
ci->c->SetMode(NULL, cm, param);
else
ci->c->RemoveMode(NULL, cm, param);
}
break;
+ }
case MODE_LIST:
if (!sep.GetToken(param))
break;