summaryrefslogtreecommitdiff
path: root/modules/extra/m_ldap_oper.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-03-14 13:52:26 -0400
committerAdam <Adam@anope.org>2011-03-14 13:52:26 -0400
commited73d7675152ccc66f20daedca8586a8de254a84 (patch)
tree18f7a1a53a717f24d061550c6670ca6f0ed54f9f /modules/extra/m_ldap_oper.cpp
parent4fe49af8401b956249d924b89b3e69bce5fb6744 (diff)
Rewrote some of the opertype system, added os_login
Diffstat (limited to 'modules/extra/m_ldap_oper.cpp')
-rw-r--r--modules/extra/m_ldap_oper.cpp45
1 files changed, 35 insertions, 10 deletions
diff --git a/modules/extra/m_ldap_oper.cpp b/modules/extra/m_ldap_oper.cpp
index 8a5f57116..b8a1d5f51 100644
--- a/modules/extra/m_ldap_oper.cpp
+++ b/modules/extra/m_ldap_oper.cpp
@@ -1,6 +1,7 @@
#include "module.h"
#include "ldap.h"
+static std::set<Oper *> my_opers;
static Anope::string opertype_attribute;
class IdentifyInterface : public LDAPInterface
@@ -36,22 +37,32 @@ class IdentifyInterface : public LDAPInterface
const Anope::string &opertype = attr.get(opertype_attribute);
- for (std::list<OperType *>::iterator oit = Config->MyOperTypes.begin(), oit_end = Config->MyOperTypes.end(); oit != oit_end; ++oit)
+ OperType *ot = OperType::Find(opertype);
+ if (ot != NULL && (u->Account()->o == NULL || ot != u->Account()->o->ot))
{
- OperType *ot = *oit;
- if (ot->GetName() == opertype && ot != u->Account()->ot)
+ Oper *o = u->Account()->o;
+ if (o != NULL && my_opers.count(o) > 0)
{
- u->Account()->ot = ot;
- Log() << "m_ldap_oper: Tied " << u->nick << " (" << u->Account()->display << ") to opertype " << ot->GetName();
- break;
+ my_opers.erase(o);
+ delete o;
}
+ o = new Oper(u->nick, "", "", ot);
+ my_opers.insert(o);
+ u->Account()->o = o;
+ Log() << "m_ldap_oper: Tied " << u->nick << " (" << u->Account()->display << ") to opertype " << ot->GetName();
}
}
catch (const LDAPException &ex)
{
- if (u->Account()->ot != NULL)
+ if (u->Account()->o != NULL)
{
- u->Account()->ot = NULL;
+ if (my_opers.count(u->Account()->o) > 0)
+ {
+ my_opers.erase(u->Account()->o);
+ delete u->Account()->o;
+ }
+ u->Account()->o = NULL;
+
Log() << "m_ldap_oper: Removed services operator from " << u->nick << " (" << u->Account()->display << ")";
}
}
@@ -79,8 +90,8 @@ class LDAPOper : public Module
this->SetAuthor("Anope");
this->SetType(SUPPORTED);
- Implementation i[] = { I_OnReload, I_OnNickIdentify };
- ModuleManager::Attach(i, this, 2);
+ Implementation i[] = { I_OnReload, I_OnNickIdentify, I_OnDelCore };
+ ModuleManager::Attach(i, this, 3);
OnReload(false);
}
@@ -94,6 +105,10 @@ class LDAPOper : public Module
this->basedn = config.ReadValue("m_ldap_oper", "basedn", "", 0);
this->filter = config.ReadValue("m_ldap_oper", "filter", "", 0);
opertype_attribute = config.ReadValue("m_ldap_oper", "opertype_attribute", "", 0);
+
+ for (std::set<Oper *>::iterator it = my_opers.begin(), it_end = my_opers.end(); it != it_end; ++it)
+ delete *it;
+ my_opers.clear();
}
void OnNickIdentify(User *u)
@@ -115,6 +130,16 @@ class LDAPOper : public Module
Log() << "m_ldapoper: " << ex.GetReason();
}
}
+
+ void OnDelCore(NickCore *nc)
+ {
+ if (nc->o != NULL && my_opers.count(nc->o) > 0)
+ {
+ my_opers.erase(nc->o);
+ delete nc->o;
+ nc->o = NULL;
+ }
+ }
};
MODULE_INIT(LDAPOper)