diff options
author | Adam <Adam@anope.org> | 2013-11-01 04:58:38 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-11-01 04:58:38 -0400 |
commit | 4ee9021adbb10140c30d6027a97e4748cb2f5903 (patch) | |
tree | f587e7492f142f8d4e7a908190c83a22087559b0 /modules/commands/cs_access.cpp | |
parent | c8db362bca238aaedf9113383a731d18ba88594f (diff) |
Compare access entries created with the levels access system by access level and not by privilege set, as two entries can have the same privset but different levels, but still represent two different levels of access. This prevented users from adding other users at a lower access level when that level had the same privset as them. Spotted by TSG.
Diffstat (limited to 'modules/commands/cs_access.cpp')
-rw-r--r-- | modules/commands/cs_access.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index 0ecf95106..7a2d1a35b 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -43,13 +43,32 @@ class AccessChanAccess : public ChanAccess { this->level = convertTo<int>(data); } + + bool operator>(const ChanAccess &other) const anope_override + { + if (this->provider != other.provider) + return ChanAccess::operator>(other); + else + return this->level > anope_dynamic_static_cast<const AccessChanAccess &>(other).level; + } + + bool operator<(const ChanAccess &other) const anope_override + { + if (this->provider != other.provider) + return ChanAccess::operator<(other); + else + return this->level < anope_dynamic_static_cast<const AccessChanAccess &>(other).level; + } }; class AccessAccessProvider : public AccessProvider { public: + static AccessAccessProvider *me; + AccessAccessProvider(Module *o) : AccessProvider(o, "access/access") { + me = this; } ChanAccess *Create() anope_override @@ -57,6 +76,7 @@ class AccessAccessProvider : public AccessProvider return new AccessChanAccess(this); } }; +AccessAccessProvider* AccessAccessProvider::me; class CommandCSAccess : public Command { @@ -91,7 +111,7 @@ class CommandCSAccess : public Command AccessGroup u_access = source.AccessFor(ci); const ChanAccess *highest = u_access.Highest(); - AccessChanAccess tmp_access(NULL); + AccessChanAccess tmp_access(AccessAccessProvider::me); tmp_access.ci = ci; tmp_access.level = level; |