summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-02-03 16:28:08 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-02-03 16:28:08 +0000
commit04cfaea87edd1b4b742cb607ea69ece760c460aa (patch)
tree5b7e5671290d808353f2c0c6064f74cee1182b6a /src
parentb7caf477e6ac3a6ba5790c0915783be02b8b6d41 (diff)
Add access checking for m_autoop
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12361 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_autoop.cpp31
-rw-r--r--src/modules/u_listmode.h9
2 files changed, 30 insertions, 10 deletions
diff --git a/src/modules/m_autoop.cpp b/src/modules/m_autoop.cpp
index a66e2bd4d..5dc54fba6 100644
--- a/src/modules/m_autoop.cpp
+++ b/src/modules/m_autoop.cpp
@@ -25,8 +25,30 @@ class AutoOpList : public ListModeBase
{
levelrequired = OP_VALUE;
}
- // TODO need own numerics
- // TODO add some serious access control for setting this mode (you can currently gain +qa with it)
+
+ ModResult AccessCheck(User* source, Channel* channel, std::string &parameter, bool adding)
+ {
+ std::string::size_type pos = parameter.find(':');
+ if (pos == 0 || pos == std::string::npos)
+ return adding ? MOD_RES_DENY : MOD_RES_PASSTHRU;
+ unsigned int mylevel = channel->GetPrefixValue(source);
+ while (pos > 0)
+ {
+ pos--;
+ ModeHandler* mh = ServerInstance->Modes->FindMode(parameter[pos], MODETYPE_CHANNEL);
+ if (adding && !mh)
+ return MOD_RES_DENY;
+ else if (!mh)
+ continue;
+
+ std::string dummy;
+ if (mh->AccessCheck(source, channel, dummy, true) == MOD_RES_DENY)
+ return MOD_RES_DENY;
+ if (mh->GetLevelRequired() > mylevel)
+ return MOD_RES_DENY;
+ }
+ return MOD_RES_PASSTHRU;
+ }
};
@@ -58,10 +80,7 @@ public:
if (colon == std::string::npos)
continue;
if (chan->CheckBan(user, it->mask.substr(colon+1)))
- {
- privs = it->mask.substr(0, colon);
- break;
- }
+ privs += it->mask.substr(0, colon);
}
}
diff --git a/src/modules/u_listmode.h b/src/modules/u_listmode.h
index f7ab783cc..7e018e558 100644
--- a/src/modules/u_listmode.h
+++ b/src/modules/u_listmode.h
@@ -182,16 +182,17 @@ class ListModeBase : public ModeHandler
*/
virtual void DoRehash()
{
- ConfigReader Conf;
+ ConfigTagList tags = ServerInstance->Config->ConfTags(configtag);
chanlimits.clear();
- for (int i = 0; i < Conf.Enumerate(configtag); i++)
+ for (ConfigIter i = tags.first; i != tags.second; i++)
{
// For each <banlist> tag
+ ConfigTag* c = i->second;
ListLimit limit;
- limit.mask = Conf.ReadValue(configtag, "chan", i);
- limit.limit = Conf.ReadInteger(configtag, "limit", i, true);
+ limit.mask = c->getString("chan");
+ limit.limit = c->getInt("limit");
if (limit.mask.size() && limit.limit > 0)
chanlimits.push_back(limit);