diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-12-05 15:39:52 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-12-05 15:39:52 +0100 |
commit | 53b9f55c18dd72e8495f84bacfe6683d8df81e66 (patch) | |
tree | 17e5969612e511c9a021cad10448bf43bb87ab3c /src/modules/m_sasl.cpp | |
parent | bc388aa97c1e8ab4ebea729d116e868cff11e137 (diff) |
m_sasl Create SASLCap which subclasses Cap::Capability and implements OnRequest()
Diffstat (limited to 'src/modules/m_sasl.cpp')
-rw-r--r-- | src/modules/m_sasl.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index 297abad85..4d1dbbc71 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -24,6 +24,25 @@ #include "modules/sasl.h" #include "modules/ssl.h" +class SASLCap : public Cap::Capability +{ + bool OnRequest(LocalUser* user, bool adding) CXX11_OVERRIDE + { + // Requesting this cap is allowed anytime + if (adding) + return true; + + // But removing it can only be done when unregistered + return (user->registered != REG_ALL); + } + + public: + SASLCap(Module* mod) + : Cap::Capability(mod, "sasl") + { + } +}; + enum SaslState { SASL_INIT, SASL_COMM, SASL_DONE }; enum SaslResult { SASL_OK, SASL_FAIL, SASL_ABORT }; @@ -247,7 +266,7 @@ class CommandSASL : public Command class ModuleSASL : public Module { SimpleExtItem<SaslAuthenticator> authExt; - Cap::Capability cap; + SASLCap cap; CommandAuthenticate auth; CommandSASL sasl; Events::ModuleEventProvider sasleventprov; @@ -255,7 +274,7 @@ class ModuleSASL : public Module public: ModuleSASL() : authExt("sasl_auth", ExtensionItem::EXT_USER, this) - , cap(this, "sasl") + , cap(this) , auth(this, authExt, cap) , sasl(this, authExt) , sasleventprov(this, "event/sasl") |