1
0
mirror of https://github.com/anope/anope.git synced 2026-07-08 21:13:13 +02:00

Added some access checks to cs_mode and fixed some language strings

This commit is contained in:
Adam
2011-03-12 02:40:08 -05:00
parent 9f46972f19
commit 95469fde30
16 changed files with 87 additions and 34 deletions
+54 -1
View File
@@ -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;
+2 -2
View File
@@ -30,12 +30,12 @@ class CommandCSSetKeepTopic : public Command
if (params[1].equals_ci("ON"))
{
ci->SetFlag(CI_KEEPTOPIC);
source.Reply(_("Topic retention option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Topic retention option for %s is now \002on\002."), ci->name.c_str());
}
else if (params[1].equals_ci("OFF"))
{
ci->UnsetFlag(CI_KEEPTOPIC);
source.Reply(_("Topic retention option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Topic retention option for %s is now \002off\002."), ci->name.c_str());
}
else
this->OnSyntaxError(source, "KEEPTOPIC");
+2 -2
View File
@@ -30,12 +30,12 @@ class CommandCSSetOpNotice : public Command
if (params[1].equals_ci("ON"))
{
ci->SetFlag(CI_OPNOTICE);
source.Reply(_("Op-notice option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Op-notice option for %s is now \002on\002."), ci->name.c_str());
}
else if (params[1].equals_ci("OFF"))
{
ci->UnsetFlag(CI_OPNOTICE);
source.Reply(_("Op-notice option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Op-notice option for %s is now \002off\002."), ci->name.c_str());
}
else
this->OnSyntaxError(source, "OPNOTICE");
+2 -2
View File
@@ -30,12 +30,12 @@ class CommandCSSetPeace : public Command
if (params[1].equals_ci("ON"))
{
ci->SetFlag(CI_PEACE);
source.Reply(_("Peace option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Peace option for %s is now \002on\002."), ci->name.c_str());
}
else if (params[1].equals_ci("OFF"))
{
ci->UnsetFlag(CI_PEACE);
source.Reply(_("Peace option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Peace option for %s is now \002off\002."), ci->name.c_str());
}
else
this->OnSyntaxError(source, "PEACE");
+2 -2
View File
@@ -30,12 +30,12 @@ class CommandCSSetPrivate : public Command
if (params[1].equals_ci("ON"))
{
ci->SetFlag(CI_PRIVATE);
source.Reply(_("Private option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Private option for %s is now \002on\002."), ci->name.c_str());
}
else if (params[1].equals_ci("OFF"))
{
ci->UnsetFlag(CI_PRIVATE);
source.Reply(_("Private option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Private option for %s is now \002off\002."), ci->name.c_str());
}
else
this->OnSyntaxError(source, "PRIVATE");
+2 -2
View File
@@ -31,14 +31,14 @@ class CommandCSSetRestricted : public Command
ci->SetFlag(CI_RESTRICTED);
if (ci->levels[CA_NOJOIN] < 0)
ci->levels[CA_NOJOIN] = 0;
source.Reply(_("Restricted access option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Restricted access option for %s is now \002on\002."), ci->name.c_str());
}
else if (params[1].equals_ci("OFF"))
{
ci->UnsetFlag(CI_RESTRICTED);
if (ci->levels[CA_NOJOIN] >= 0)
ci->levels[CA_NOJOIN] = -2;
source.Reply(_("Restricted access option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Restricted access option for %s is now \002off\002."), ci->name.c_str());
}
else
this->OnSyntaxError(source, "RESTRICTED");
+2 -2
View File
@@ -30,12 +30,12 @@ class CommandCSSetSecure : public Command
if (params[1].equals_ci("ON"))
{
ci->SetFlag(CI_SECURE);
source.Reply(_("Secure option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Secure option for %s is now \002on\002."), ci->name.c_str());
}
else if (params[1].equals_ci("OFF"))
{
ci->UnsetFlag(CI_SECURE);
source.Reply(_("Secure option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Secure option for %s is now \002off\002."), ci->name.c_str());
}
else
this->OnSyntaxError(source, "SECURE");
+2 -2
View File
@@ -37,12 +37,12 @@ class CommandCSSetSecureFounder : public Command
if (params[1].equals_ci("ON"))
{
ci->SetFlag(CI_SECUREFOUNDER);
source.Reply(_("Secure founder option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Secure founder option for %s is now \002on\002."), ci->name.c_str());
}
else if (params[1].equals_ci("OFF"))
{
ci->UnsetFlag(CI_SECUREFOUNDER);
source.Reply(_("Secure founder option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Secure founder option for %s is now \002off\002."), ci->name.c_str());
}
else
this->OnSyntaxError(source, "SECUREFOUNDER");
+2 -2
View File
@@ -30,12 +30,12 @@ class CommandCSSetSecureOps : public Command
if (params[1].equals_ci("ON"))
{
ci->SetFlag(CI_SECUREOPS);
source.Reply(_("Secure ops option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Secure ops option for %s is now \002on\002."), ci->name.c_str());
}
else if (params[1].equals_ci("OFF"))
{
ci->UnsetFlag(CI_SECUREOPS);
source.Reply(_("Secure ops option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Secure ops option for %s is now \002off\002."), ci->name.c_str());
}
else
this->OnSyntaxError(source, "SECUREOPS");
+2 -2
View File
@@ -31,7 +31,7 @@ class CommandCSSetSignKick : public Command
{
ci->SetFlag(CI_SIGNKICK);
ci->UnsetFlag(CI_SIGNKICK_LEVEL);
source.Reply(_("Signed kick option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Signed kick option for %s is now \002on\002."), ci->name.c_str());
}
else if (params[1].equals_ci("LEVEL"))
{
@@ -44,7 +44,7 @@ class CommandCSSetSignKick : public Command
{
ci->UnsetFlag(CI_SIGNKICK);
ci->UnsetFlag(CI_SIGNKICK_LEVEL);
source.Reply(_("Signed kick option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Signed kick option for %s is now \002off\002."), ci->name.c_str());
}
else
this->OnSyntaxError(source, "SIGNKICK");
+2 -2
View File
@@ -30,12 +30,12 @@ class CommandCSSetTopicLock : public Command
if (params[1].equals_ci("ON"))
{
ci->SetFlag(CI_TOPICLOCK);
source.Reply(_("Topic lock option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Topic lock option for %s is now \002on\002."), ci->name.c_str());
}
else if (params[1].equals_ci("OFF"))
{
ci->UnsetFlag(CI_TOPICLOCK);
source.Reply(_("Topic lock option for %s is now \002\002."), ci->name.c_str());
source.Reply(_("Topic lock option for %s is now \002off\002."), ci->name.c_str());
}
else
this->OnSyntaxError(source, "TOPICLOCK");
+2 -2
View File
@@ -68,14 +68,14 @@ class CommandCSSetXOP : public Command
}
Log(LOG_COMMAND, u, this, ci) << "to enable XOP";
source.Reply(_("xOP lists system for %s is now \002\002."), ci->name.c_str());
source.Reply(_("xOP lists system for %s is now \002on\002."), ci->name.c_str());
}
else if (params[1].equals_ci("OFF"))
{
ci->UnsetFlag(CI_XOP);
Log(LOG_COMMAND, u, this, ci) << "to disable XOP";
source.Reply(_("xOP lists system for %s is now \002\002."), ci->name.c_str());
source.Reply(_("xOP lists system for %s is now \002off\002."), ci->name.c_str());
}
else
this->OnSyntaxError(source, "XOP");
+4 -4
View File
@@ -36,14 +36,14 @@ class CommandNSSetKill : public Command
nc->SetFlag(NI_KILLPROTECT);
nc->UnsetFlag(NI_KILL_QUICK);
nc->UnsetFlag(NI_KILL_IMMED);
source.Reply(_("Protection is now \002\002 for \002%s\002."), nc->display.c_str());
source.Reply(_("Protection is now \002on\002 for \002%s\002."), nc->display.c_str());
}
else if (param.equals_ci("QUICK"))
{
nc->SetFlag(NI_KILLPROTECT);
nc->SetFlag(NI_KILL_QUICK);
nc->UnsetFlag(NI_KILL_IMMED);
source.Reply(_("Protection is now \002\002 for \002%s\002, with a reduced delay."), nc->display.c_str());
source.Reply(_("Protection is now \002on\002 for \002%s\002, with a reduced delay."), nc->display.c_str());
}
else if (param.equals_ci("IMMED"))
{
@@ -52,7 +52,7 @@ class CommandNSSetKill : public Command
nc->SetFlag(NI_KILLPROTECT);
nc->SetFlag(NI_KILL_IMMED);
nc->UnsetFlag(NI_KILL_QUICK);
source.Reply(_("Protection is now \002\002 for \002%s\002, with no delay."), nc->display.c_str());
source.Reply(_("Protection is now \002on\002 for \002%s\002, with no delay."), nc->display.c_str());
}
else
source.Reply(_("The \002IMMED\002 option is not available on this network."));
@@ -62,7 +62,7 @@ class CommandNSSetKill : public Command
nc->UnsetFlag(NI_KILLPROTECT);
nc->UnsetFlag(NI_KILL_QUICK);
nc->UnsetFlag(NI_KILL_IMMED);
source.Reply(_("Protection is now \002\002 for \002%s\002."), nc->display.c_str());
source.Reply(_("Protection is now \002off\002 for \002%s\002."), nc->display.c_str());
}
else
this->OnSyntaxError(source, "KILL");
+2 -2
View File
@@ -33,12 +33,12 @@ class CommandNSSetPrivate : public Command
if (param.equals_ci("ON"))
{
nc->SetFlag(NI_PRIVATE);
source.Reply(_("Private option is now \002\002 for \002%s\002."), nc->display.c_str());
source.Reply(_("Private option is now \002on\002 for \002%s\002."), nc->display.c_str());
}
else if (param.equals_ci("OFF"))
{
nc->UnsetFlag(NI_PRIVATE);
source.Reply(_("Private option is now \002\002 for \002%s\002."), nc->display.c_str());
source.Reply(_("Private option is now \002off\002 for \002%s\002."), nc->display.c_str());
}
else
this->OnSyntaxError(source, "PRIVATE");
+2 -2
View File
@@ -33,12 +33,12 @@ class CommandNSSetSecure : public Command
if (param.equals_ci("ON"))
{
nc->SetFlag(NI_SECURE);
source.Reply(_("Secure option is now \002\002 for \002%s\002."), nc->display.c_str());
source.Reply(_("Secure option is now \002on\002 for \002%s\002."), nc->display.c_str());
}
else if (param.equals_ci("OFF"))
{
nc->UnsetFlag(NI_SECURE);
source.Reply(_("Secure option is now \002\002 for \002%s\002."), nc->display.c_str());
source.Reply(_("Secure option is now \002off\002 for \002%s\002."), nc->display.c_str());
}
else
this->OnSyntaxError(source, "SECURE");
+3 -3
View File
@@ -56,7 +56,7 @@ class CommandOSSet : public Command
source.Reply(_("Services are now in \002read-write\002 mode."));
}
else
source.Reply(_("Setting for READONLY must be \002\002 or \002\002."));
source.Reply(_("Setting for READONLY must be \002on\002 or \002off\002."));
return MOD_CONT;
}
@@ -94,7 +94,7 @@ class CommandOSSet : public Command
ircdproto->SendGlobops(OperServ, GetString(NULL, _("%s is no longer a Super-Admin")).c_str(), u->nick.c_str());
}
else
source.Reply(_("Setting for SuperAdmin must be \002\002 or \002\002 (must be enabled in services.conf)"));
source.Reply(_("Setting for SuperAdmin must be \002on\002 or \002off\002 (must be enabled in services.conf)"));
return MOD_CONT;
}
@@ -163,7 +163,7 @@ class CommandOSSet : public Command
source.Reply(_("Services are now in \002expire\002 mode."));
}
else
source.Reply(_("Setting for NOEXPIRE must be \002\002 or \002\002."));
source.Reply(_("Setting for NOEXPIRE must be \002on\002 or \002off\002."));
return MOD_CONT;
}