summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorRobby- <robby@chat.be>2013-09-13 04:59:19 +0200
committerAdam <Adam@anope.org>2013-09-27 17:21:20 -0400
commit7545763cd41675ddd37e5b066969da305f1fb68a (patch)
tree878d9054238cb59aed9a152e6321864bac7219bd /modules
parent1818b19ebaa6584cb97455e1a91e51ecfebd4dfc (diff)
Added missing override capabilities and log calls to some ChanServ commands
Diffstat (limited to 'modules')
-rw-r--r--modules/commands/cs_clone.cpp19
-rw-r--r--modules/commands/cs_log.cpp6
-rw-r--r--modules/commands/cs_mode.cpp20
-rw-r--r--modules/commands/cs_sync.cpp5
-rw-r--r--modules/commands/cs_unban.cpp6
-rw-r--r--modules/commands/cs_updown.cpp26
6 files changed, 57 insertions, 25 deletions
diff --git a/modules/commands/cs_clone.cpp b/modules/commands/cs_clone.cpp
index c0d33c742..40ef67b53 100644
--- a/modules/commands/cs_clone.cpp
+++ b/modules/commands/cs_clone.cpp
@@ -35,18 +35,14 @@ public:
User *u = source.GetUser();
ChannelInfo *ci = ChannelInfo::Find(params[0]);
+ bool override = false;
+
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
return;
}
- if (!source.AccessFor(ci).HasPriv("SET"))
- {
- source.Reply(ACCESS_DENIED);
- return;
- }
-
ChannelInfo *target_ci = ChannelInfo::Find(target);
if (!target_ci)
{
@@ -55,8 +51,13 @@ public:
}
if (!source.IsFounder(ci) || !source.IsFounder(target_ci))
{
- source.Reply(ACCESS_DENIED);
- return;
+ if (!source.HasPriv("chanserv/administration"))
+ {
+ source.Reply(ACCESS_DENIED);
+ return;
+ }
+ else
+ override = true;
}
if (what.equals_ci("ALL"))
@@ -151,7 +152,7 @@ public:
return;
}
- Log(LOG_COMMAND, source, this, ci) << "to clone " << (what.empty() ? "everything from it" : what) << " to " << target_ci->name;
+ Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clone " << (what.empty() ? "everything from it" : what) << " to " << target_ci->name;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
diff --git a/modules/commands/cs_log.cpp b/modules/commands/cs_log.cpp
index 1eca31f85..e9fc3916e 100644
--- a/modules/commands/cs_log.cpp
+++ b/modules/commands/cs_log.cpp
@@ -216,15 +216,15 @@ public:
{
if (log->extra == extra)
{
- Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to remove logging for " << (!log->command_name.empty() ? log->command_name : log->service_name) << " with method " << method << (extra == "" ? "" : " ") << extra;
+ Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to remove logging for " << command << " with method " << method << (extra == "" ? "" : " ") << extra;
source.Reply(_("Logging for command %s on %s with log method %s%s%s has been removed."), !log->command_name.empty() ? log->command_name.c_str() : log->service_name.c_str(), !log->command_service.empty() ? log->command_service.c_str() : "any service", method.c_str(), extra.empty() ? "" : " ", extra.empty() ? "" : extra.c_str());
delete log;
}
else
{
log->extra = extra;
- Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to change logging for " << (!log->command_name.empty() ? log->command_name : log->service_name) << " to method " << method << (extra == "" ? "" : " ") << extra;
- source.Reply(_("Logging changed for command %s on %s, now using log method %s%s%s has been removed."), !log->command_name.empty() ? log->command_name.c_str() : log->service_name.c_str(), !log->command_service.empty() ? log->command_service.c_str() : "any service", method.c_str(), extra.empty() ? "" : " ", extra.empty() ? "" : extra.c_str());
+ Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to change logging for " << command << " to method " << method << (extra == "" ? "" : " ") << extra;
+ source.Reply(_("Logging changed for command %s on %s, now using log method %s%s%s."), !log->command_name.empty() ? log->command_name.c_str() : log->service_name.c_str(), !log->command_service.empty() ? log->command_service.c_str() : "any service", method.c_str(), extra.empty() ? "" : " ", extra.empty() ? "" : extra.c_str());
}
return;
}
diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp
index 1cd3f7a08..f586f2c2a 100644
--- a/modules/commands/cs_mode.cpp
+++ b/modules/commands/cs_mode.cpp
@@ -295,7 +295,7 @@ class CommandCSMode : public Command
sep.GetToken(modes);
Anope::string pos = "+", neg = "-", pos_params, neg_params;
-
+
int adding = -1;
for (size_t i = 0; i < modes.length(); ++i)
{
@@ -761,25 +761,35 @@ class CommandCSModes : public Command
AccessGroup u_access = source.AccessFor(ci), targ_access = ci->AccessFor(targ);
const std::pair<bool, Anope::string> &m = modes[source.command];
+ bool can_override = source.HasPriv("chanserv/administration");
+ bool override = false;
+
if (m.second.empty())
{
source.Reply(ACCESS_DENIED);
return;
}
- if (!source.HasPriv("chanserv/administration"))
+ if (u == targ ? !u_access.HasPriv(m.second + "ME") : !u_access.HasPriv(m.second))
{
- if (u == targ ? !u_access.HasPriv(m.second + "ME") : !u_access.HasPriv(m.second))
+ if (!can_override)
{
source.Reply(ACCESS_DENIED);
return;
}
+ else
+ override = true;
+ }
- if (!m.first && u != targ && (targ->IsProtected() || (ci->HasExt("PEACE") && targ_access >= u_access)))
+ if (!override && !m.first && u != targ && (targ->IsProtected() || (ci->HasExt("PEACE") && targ_access >= u_access)))
+ {
+ if (!can_override)
{
source.Reply(ACCESS_DENIED);
return;
}
+ else
+ override = true;
}
if (!ci->c->FindUser(targ))
@@ -793,7 +803,7 @@ class CommandCSModes : public Command
else
ci->c->RemoveMode(NULL, m.second, targ->GetUID());
- Log(LOG_COMMAND, source, this, ci) << "on " << targ->nick;
+ Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "on " << targ->nick;
}
const Anope::string GetDesc(CommandSource &source) const anope_override
diff --git a/modules/commands/cs_sync.cpp b/modules/commands/cs_sync.cpp
index 4b854bd45..bf7182424 100644
--- a/modules/commands/cs_sync.cpp
+++ b/modules/commands/cs_sync.cpp
@@ -28,11 +28,12 @@ class CommandCSSync : public Command
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
else if (ci->c == NULL)
source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str());
- else if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE"))
+ else if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && !source.HasPriv("chanserv/administration"))
source.Reply(ACCESS_DENIED);
else
{
- Log(LOG_COMMAND, source, this, ci);
+ bool override = !source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/kick");
+ Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci);
for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
ci->c->SetCorrectModes(it->second->user, true);
diff --git a/modules/commands/cs_unban.cpp b/modules/commands/cs_unban.cpp
index 59d2dfeaa..333592109 100644
--- a/modules/commands/cs_unban.cpp
+++ b/modules/commands/cs_unban.cpp
@@ -42,6 +42,7 @@ class CommandCSUnban : public Command
++count;
}
+ Log(LOG_COMMAND, source, this, NULL) << "on all channels";
source.Reply(_("You have been unbanned from %d channels."), count);
return;
@@ -60,7 +61,7 @@ class CommandCSUnban : public Command
return;
}
- if (!source.AccessFor(ci).HasPriv("UNBAN"))
+ if (!source.AccessFor(ci).HasPriv("UNBAN") && !source.HasPriv("chanserv/kick"))
{
source.Reply(ACCESS_DENIED);
return;
@@ -76,7 +77,8 @@ class CommandCSUnban : public Command
return;
}
- Log(LOG_COMMAND, source, this, ci) << "to unban " << u2->nick;
+ bool override = !source.AccessFor(ci).HasPriv("UNBAN") && source.HasPriv("chanserv/kick");
+ Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unban " << u2->nick;
ci->c->Unban(u2, source.GetUser() == u2);
if (u2 == source.GetUser())
diff --git a/modules/commands/cs_updown.cpp b/modules/commands/cs_updown.cpp
index ab00d5d5d..bcf912e09 100644
--- a/modules/commands/cs_updown.cpp
+++ b/modules/commands/cs_updown.cpp
@@ -31,6 +31,7 @@ class CommandCSUp : public Command
Channel *c = it->second->chan;
c->SetCorrectModes(source.GetUser(), true);
}
+ Log(LOG_COMMAND, source, this, NULL) << "on all channels to update their status modes";
}
else
{
@@ -51,6 +52,8 @@ class CommandCSUp : public Command
}
User *u = User::Find(nick, true);
+ bool override = false;
+
if (u == NULL)
{
source.Reply(NICK_X_NOT_IN_USE, nick.c_str());
@@ -65,11 +68,17 @@ class CommandCSUp : public Command
{
if (c->ci->AccessFor(u) > c->ci->AccessFor(source.GetUser()))
{
- source.Reply(ACCESS_DENIED);
- return;
+ if (source.HasPriv("chanserv/administration"))
+ override = true;
+ else
+ {
+ source.Reply(ACCESS_DENIED);
+ return;
+ }
}
}
+ Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci) << "to update the status modes of " << u->nick;
c->SetCorrectModes(u, true);
}
@@ -114,6 +123,7 @@ class CommandCSDown : public Command
Channel *c = it->second->chan;
RemoveAll(source.GetUser(), c);
}
+ Log(LOG_COMMAND, source, this, NULL) << "on all channels to remove their status modes";
}
else
{
@@ -134,6 +144,8 @@ class CommandCSDown : public Command
}
User *u = User::Find(nick, true);
+ bool override = false;
+
if (u == NULL)
{
source.Reply(NICK_X_NOT_IN_USE, nick.c_str());
@@ -148,11 +160,17 @@ class CommandCSDown : public Command
{
if (c->ci->AccessFor(u) > c->ci->AccessFor(source.GetUser()))
{
- source.Reply(ACCESS_DENIED);
- return;
+ if (source.HasPriv("chanserv/administration"))
+ override = true;
+ else
+ {
+ source.Reply(ACCESS_DENIED);
+ return;
+ }
}
}
+ Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci) << "to remove the status modes from " << u->nick;
RemoveAll(u, c);
}
}