]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_ldapauth.cpp
Replace OnRehash() with ReadConfig() that is called on boot, on module load and on...
[user/henk/code/inspircd.git] / src / modules / extra / m_ldapauth.cpp
index 5b3f1e7cc00ec0f538b87a67abf78eb060af121b..827179f84ebb0c225d39ff262cc1c5baf82968c5 100644 (file)
@@ -35,7 +35,6 @@
 # pragma comment(lib, "lber.lib")
 #endif
 
-/* $ModDesc: Allow/Deny connections based upon answer from LDAP server */
 /* $LinkerFlags: -lldap */
 
 struct RAIILDAPString
@@ -119,13 +118,10 @@ public:
                conn = NULL;
        }
 
-       void init()
+       void init() CXX11_OVERRIDE
        {
                ServerInstance->Modules->AddService(ldapAuthed);
                ServerInstance->Modules->AddService(ldapVhost);
-               Implementation eventlist[] = { I_OnCheckReady, I_OnRehash,I_OnUserRegister, I_OnUserConnect };
-               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
-               OnRehash(NULL);
        }
 
        ~ModuleLDAPAuth()
@@ -134,7 +130,7 @@ public:
                        ldap_unbind_ext(conn, NULL, NULL);
        }
 
-       void OnRehash(User* user)
+       void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
        {
                ConfigTag* tag = ServerInstance->Config->ConfValue("ldapauth");
                whitelistedcidrs.clear();
@@ -212,7 +208,7 @@ public:
                        std::string> &replacements)
        {
                std::string result;
-               result.reserve(MAXBUF);
+               result.reserve(text.length());
 
                for (unsigned int i = 0; i < text.length(); ++i) {
                        char c = text[i];
@@ -234,7 +230,7 @@ public:
           return result;
        }
 
-       virtual void OnUserConnect(LocalUser *user)
+       void OnUserConnect(LocalUser *user) CXX11_OVERRIDE
        {
                std::string* cc = ldapVhost.get(user);
                if (cc)
@@ -244,7 +240,7 @@ public:
                }
        }
 
-       ModResult OnUserRegister(LocalUser* user)
+       ModResult OnUserRegister(LocalUser* user) CXX11_OVERRIDE
        {
                if ((!allowpattern.empty()) && (InspIRCd::Match(user->nick,allowpattern)))
                {
@@ -378,7 +374,7 @@ public:
                                attr_value.bv_val = const_cast<char*>(val.c_str());
                                attr_value.bv_len = val.length();
 
-                               ServerInstance->Logs->Log("m_ldapauth", DEBUG, "LDAP compare: %s=%s", attr.c_str(), val.c_str());
+                               ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "LDAP compare: %s=%s", attr.c_str(), val.c_str());
 
                                authed = (ldap_compare_ext_s(conn, DN, attr.c_str(), &attr_value, NULL, NULL) == LDAP_COMPARE_TRUE);
 
@@ -421,16 +417,15 @@ public:
                return true;
        }
 
-       ModResult OnCheckReady(LocalUser* user)
+       ModResult OnCheckReady(LocalUser* user) CXX11_OVERRIDE
        {
                return ldapAuthed.get(user) ? MOD_RES_PASSTHRU : MOD_RES_DENY;
        }
 
-       Version GetVersion()
+       Version GetVersion() CXX11_OVERRIDE
        {
                return Version("Allow/Deny connections based upon answer from LDAP server", VF_VENDOR);
        }
-
 };
 
 MODULE_INIT(ModuleLDAPAuth)