summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-12-31 01:33:32 -0500
committerAdam <Adam@anope.org>2011-12-31 01:33:32 -0500
commit20aa4e85ce11a5d286f027638c4af82251c2afb9 (patch)
tree398140734d25134002f633c4c6dac6510584580b
parentf1b05acf269817b9fd70bab24fe66fbfe936beba (diff)
Bug #1368 - check all members of a users gruop against the access list
-rw-r--r--include/access.h2
-rw-r--r--modules/commands/cs_access.cpp9
-rw-r--r--modules/commands/cs_flags.cpp9
-rw-r--r--modules/commands/cs_xop.cpp9
-rw-r--r--modules/commands/ns_alist.cpp3
-rw-r--r--src/access.cpp16
6 files changed, 19 insertions, 29 deletions
diff --git a/include/access.h b/include/access.h
index 64e0971c9..8f36b68d0 100644
--- a/include/access.h
+++ b/include/access.h
@@ -55,7 +55,7 @@ class CoreExport ChanAccess : public Serializable
serialized_data serialize();
static void unserialize(serialized_data &);
- virtual bool Matches(User *u, NickCore *nc) = 0;
+ virtual bool Matches(User *u, NickCore *nc);
virtual bool HasPriv(const Anope::string &name) const = 0;
virtual Anope::string Serialize() = 0;
virtual void Unserialize(const Anope::string &data) = 0;
diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp
index d1d3deb93..26359190a 100644
--- a/modules/commands/cs_access.cpp
+++ b/modules/commands/cs_access.cpp
@@ -31,15 +31,6 @@ class AccessChanAccess : public ChanAccess
{
}
- bool Matches(User *u, NickCore *nc)
- {
- if (u && this->mask.find_first_of("!@?*") != Anope::string::npos && (Anope::Match(u->nick, this->mask) || Anope::Match(u->GetMask(), this->mask)))
- return true;
- else if (nc && Anope::Match(nc->display, this->mask))
- return true;
- return false;
- }
-
bool HasPriv(const Anope::string &name) const
{
return this->ci->GetLevel(name) != ACCESS_INVALID && this->level >= this->ci->GetLevel(name);
diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp
index a720a2a79..604643704 100644
--- a/modules/commands/cs_flags.cpp
+++ b/modules/commands/cs_flags.cpp
@@ -24,15 +24,6 @@ class FlagsChanAccess : public ChanAccess
{
}
- bool Matches(User *u, NickCore *nc)
- {
- if (u && this->mask.find_first_of("!@?*") != Anope::string::npos && (Anope::Match(u->nick, this->mask) || Anope::Match(u->GetMask(), this->mask)))
- return true;
- else if (nc && Anope::Match(nc->display, this->mask))
- return true;
- return false;
- }
-
bool HasPriv(const Anope::string &priv) const
{
std::map<Anope::string, char>::iterator it = defaultFlags.find(priv);
diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp
index 3ba53e28f..1fd197967 100644
--- a/modules/commands/cs_xop.cpp
+++ b/modules/commands/cs_xop.cpp
@@ -99,15 +99,6 @@ class XOPChanAccess : public ChanAccess
{
}
- bool Matches(User *u, NickCore *nc)
- {
- if (u && this->mask.find_first_of("!@?*") != Anope::string::npos && (Anope::Match(u->nick, this->mask) || Anope::Match(u->GetMask(), this->mask)))
- return true;
- else if (nc && Anope::Match(nc->display, this->mask))
- return true;
- return false;
- }
-
bool HasPriv(const Anope::string &priv) const
{
for (int i = 0; xopAccess[i].type != XOP_UNKNOWN; ++i)
diff --git a/modules/commands/ns_alist.cpp b/modules/commands/ns_alist.cpp
index 8b8be9290..04cfb5b3f 100644
--- a/modules/commands/ns_alist.cpp
+++ b/modules/commands/ns_alist.cpp
@@ -70,7 +70,8 @@ class CommandNSAList : public Command
entry["Channel"] = (ci->HasFlag(CI_NO_EXPIRE) ? "!" : "") + ci->name;
for (unsigned i = 0; i < access.size(); ++i)
entry["Access"] = entry["Access"] + ", " + access[i]->Serialize();
- entry["Access"] = entry["Access"].substr(3);
+ entry["Access"] = entry["Access"].substr(2);
+ list.addEntry(entry);
}
std::vector<Anope::string> replies;
diff --git a/src/access.cpp b/src/access.cpp
index 26622e6d6..06f0d2ef6 100644
--- a/src/access.cpp
+++ b/src/access.cpp
@@ -120,6 +120,22 @@ void ChanAccess::unserialize(serialized_data &data)
ci->AddAccess(access);
}
+bool ChanAccess::Matches(User *u, NickCore *nc)
+{
+ if (u && Anope::Match(u->nick, this->mask))
+ return true;
+ else if (u && Anope::Match(u->GetDisplayedMask(), this->mask))
+ return true;
+ else if (nc)
+ for (std::list<NickAlias *>::iterator it = nc->aliases.begin(); it != nc->aliases.end(); ++it)
+ {
+ NickAlias *na = *it;
+ if (Anope::Match(na->nick, this->mask))
+ return true;
+ }
+ return false;
+}
+
bool ChanAccess::operator>(const ChanAccess &other) const
{
const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();