summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/access.h1
-rw-r--r--include/modules.h9
-rw-r--r--include/users.h3
-rw-r--r--modules/commands/ns_logout.cpp2
-rw-r--r--modules/commands/os_set.cpp4
-rw-r--r--src/access.cpp10
-rw-r--r--src/chanserv.cpp2
-rw-r--r--src/regchannel.cpp7
-rw-r--r--src/users.cpp4
9 files changed, 31 insertions, 11 deletions
diff --git a/include/access.h b/include/access.h
index 69f8f4bc7..7caee6e5c 100644
--- a/include/access.h
+++ b/include/access.h
@@ -78,6 +78,7 @@ class CoreExport ChanAccess
class AccessGroup : public std::vector<ChanAccess *>
{
public:
+ bool SuperAdmin;
AccessGroup();
bool HasPriv(ChannelAccess priv) const;
ChanAccess *Highest() const;
diff --git a/include/modules.h b/include/modules.h
index baf437ff8..7fd477b32 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -741,6 +741,13 @@ class CoreExport Module : public Extensible
*/
virtual void OnFindChan(const Anope::string &chname) { }
+ /** Checks if access has the channel privilege 'priv'.
+ * @param access THe access struct
+ * @param priv The privilege being checked for
+ * @return EVENT_ALLOW for yes, EVENT_STOP to stop all processing
+ */
+ virtual EventReturn OnCheckPriv(ChanAccess *access, ChannelAccess priv) { return EVENT_CONTINUE; }
+
/** Called when a nick is dropped
* @param u The user dropping the nick
* @param na The nick
@@ -1025,7 +1032,7 @@ enum Implementation
I_OnChanForbidden, I_OnChanSuspend, I_OnChanDrop, I_OnPreChanExpire, I_OnChanExpire, I_OnAccessAdd,
I_OnAccessDel, I_OnAccessClear, I_OnLevelChange, I_OnChanRegistered, I_OnChanUnsuspend, I_OnDelChan, I_OnChannelCreate,
I_OnChannelDelete, I_OnAkickAdd, I_OnAkickDel, I_OnCheckKick,
- I_OnChanInfo, I_OnFindChan,
+ I_OnChanInfo, I_OnFindChan, I_OnCheckPriv,
/* BotServ */
I_OnBotJoin, I_OnBotKick, I_OnBotCreate, I_OnBotChange, I_OnBotDelete, I_OnBotAssign, I_OnBotUnAssign,
diff --git a/include/users.h b/include/users.h
index d6a0866ee..b02705bda 100644
--- a/include/users.h
+++ b/include/users.h
@@ -54,8 +54,7 @@ class CoreExport User : public Extensible
Server *server; /* Server user is connected to */
time_t timestamp; /* Timestamp of the nick */
time_t my_signon; /* When did _we_ see the user? */
-
- int isSuperAdmin; /* is SuperAdmin on or off? */
+ bool SuperAdmin; /* is SuperAdmin on or off? */
/* Channels the user is in */
UChannelList chans;
diff --git a/modules/commands/ns_logout.cpp b/modules/commands/ns_logout.cpp
index 476330a11..3000c030d 100644
--- a/modules/commands/ns_logout.cpp
+++ b/modules/commands/ns_logout.cpp
@@ -42,7 +42,7 @@ class CommandNSLogout : public Command
if (!nick.empty() && !param.empty() && param.equals_ci("REVALIDATE") && nickserv)
nickserv->Validate(u2);
- u2->isSuperAdmin = 0; /* Dont let people logout and remain a SuperAdmin */
+ u2->SuperAdmin = 0; /* Dont let people logout and remain a SuperAdmin */
Log(LOG_COMMAND, u, this) << "to logout " << u2->nick;
/* Remove founder status from this user in all channels */
diff --git a/modules/commands/os_set.cpp b/modules/commands/os_set.cpp
index 2a50f851c..abee78e77 100644
--- a/modules/commands/os_set.cpp
+++ b/modules/commands/os_set.cpp
@@ -81,14 +81,14 @@ class CommandOSSet : public Command
source.Reply(_("SuperAdmin setting not enabled in services.conf"));
else if (setting.equals_ci("ON"))
{
- u->isSuperAdmin = 1;
+ u->SuperAdmin = true;
source.Reply(_("You are now a SuperAdmin"));
Log(LOG_ADMIN, u, this) << "SUPERADMIN ON";
ircdproto->SendGlobops(source.owner, _("%s is now a Super-Admin"), u->nick.c_str());
}
else if (setting.equals_ci("OFF"))
{
- u->isSuperAdmin = 0;
+ u->SuperAdmin = false;
source.Reply(_("You are no longer a SuperAdmin"));
Log(LOG_ADMIN, u, this) << "SUPERADMIN OFF";
ircdproto->SendGlobops(source.owner, _("%s is no longer a Super-Admin"), u->nick.c_str());
diff --git a/src/access.cpp b/src/access.cpp
index 5fba02c98..07e82159c 100644
--- a/src/access.cpp
+++ b/src/access.cpp
@@ -75,13 +75,21 @@ bool ChanAccess::operator<=(ChanAccess &other)
AccessGroup::AccessGroup() : std::vector<ChanAccess *>()
{
+ this->SuperAdmin = false;
}
bool AccessGroup::HasPriv(ChannelAccess priv) const
{
+ if (this->SuperAdmin)
+ return true;
for (unsigned i = this->size(); i > 0; --i)
- if (this->at(i - 1)->HasPriv(priv))
+ {
+ ChanAccess *access = this->at(i - 1);
+ EventReturn MOD_RESULT;
+ FOREACH_RESULT(I_OnCheckPriv, OnCheckPriv(access, priv));
+ if (MOD_RESULT == EVENT_ALLOW || access->HasPriv(priv))
return true;
+ }
return false;
}
diff --git a/src/chanserv.cpp b/src/chanserv.cpp
index c7bbe11f8..f515e3680 100644
--- a/src/chanserv.cpp
+++ b/src/chanserv.cpp
@@ -124,7 +124,7 @@ bool IsFounder(User *user, ChannelInfo *ci)
if (!user || !ci)
return false;
- if (user->isSuperAdmin)
+ if (user->SuperAdmin)
return true;
if (user->Account() && user->Account() == ci->GetFounder())
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 1528a6ce5..a13e47009 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -215,6 +215,9 @@ bool ChannelInfo::HasPriv(User *u, ChannelAccess priv)
{
AccessGroup group = this->AccessFor(u);
+ if (u->SuperAdmin)
+ return true;
+
if (this->founder && u->Account() == this->founder)
{
switch (priv)
@@ -257,6 +260,8 @@ AccessGroup ChannelInfo::AccessFor(User *u)
if (this->access[i]->Matches(u, nc))
group.push_back(this->access[i]);
+ group.SuperAdmin = u->SuperAdmin;
+
return group;
}
@@ -707,7 +712,7 @@ bool ChannelInfo::CheckKick(User *user)
if (!user || !this->c)
return false;
- if (user->isSuperAdmin)
+ if (user->SuperAdmin)
return false;
/* We don't enforce services restrictions on clients on ulined services
diff --git a/src/users.cpp b/src/users.cpp
index 214f3c91b..50e84dce3 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -40,7 +40,7 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope:
this->ident = sident;
this->host = shost;
this->uid = suid;
- this->isSuperAdmin = 0;
+ this->SuperAdmin = false;
UserListByNick[snick] = this;
if (!suid.empty())
@@ -815,7 +815,7 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop
Log() << "user: NICK from nonexistent nick " << source;
return NULL;
}
- user->isSuperAdmin = 0; /* Dont let people nick change and stay SuperAdmins */
+ user->SuperAdmin = false;
Log(user, "nick") << "(" << user->realname << ") changed nick to " << nick;