summaryrefslogtreecommitdiff
path: root/src/modules/m_cap.cpp
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2015-12-05 15:35:05 +0100
committerAttila Molnar <attilamolnar@hush.com>2015-12-05 15:35:05 +0100
commitbc388aa97c1e8ab4ebea729d116e868cff11e137 (patch)
tree171016fc53e182831beb166d1ee16f0d76451cc7 /src/modules/m_cap.cpp
parent259b1113944a01aeb450265f03fb97a283e8ef15 (diff)
m_cap Add Capability::OnRequest() hook
Diffstat (limited to 'src/modules/m_cap.cpp')
-rw-r--r--src/modules/m_cap.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/modules/m_cap.cpp b/src/modules/m_cap.cpp
index 9e857ad28..bb5a506c9 100644
--- a/src/modules/m_cap.cpp
+++ b/src/modules/m_cap.cpp
@@ -32,6 +32,14 @@ class Cap::ManagerImpl : public Cap::Manager
ExtItem capext;
CapMap caps;
+ static bool CanRequest(LocalUser* user, Ext usercaps, Capability* cap, bool adding)
+ {
+ if ((usercaps & cap->GetMask()) == adding)
+ return true;
+
+ return cap->OnRequest(user, adding);
+ }
+
Capability::Bit AllocateBit() const
{
Capability::Bit used = 0;
@@ -118,7 +126,7 @@ class Cap::ManagerImpl : public Cap::Manager
capname.erase(capname.begin());
Capability* cap = ManagerImpl::Find(capname);
- if (!cap)
+ if ((!cap) || (!CanRequest(user, usercaps, cap, !remove)))
return false;
if (remove)