mirror of
https://github.com/anope/anope.git
synced 2026-06-26 04:26:38 +02:00
Cleanup ok if modules with pending identify requests are unloaded
This commit is contained in:
+2
-1
@@ -308,6 +308,7 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END
|
||||
|
||||
class IdentifyRequest
|
||||
{
|
||||
Module *owner;
|
||||
Anope::string account;
|
||||
Anope::string password;
|
||||
|
||||
@@ -318,7 +319,7 @@ class IdentifyRequest
|
||||
static std::set<IdentifyRequest *> requests;
|
||||
|
||||
protected:
|
||||
IdentifyRequest(const Anope::string &acc, const Anope::string &pass);
|
||||
IdentifyRequest(Module *o, const Anope::string &acc, const Anope::string &pass);
|
||||
virtual ~IdentifyRequest();
|
||||
|
||||
public:
|
||||
|
||||
@@ -19,7 +19,7 @@ class NSGhostRequest : public IdentifyRequest
|
||||
Command *cmd;
|
||||
|
||||
public:
|
||||
NSGhostRequest(CommandSource &src, Command *c, const Anope::string &user, const Anope::string &pass) : IdentifyRequest(user, pass), source(src), cmd(c) { }
|
||||
NSGhostRequest(Module *o, CommandSource &src, Command *c, const Anope::string &user, const Anope::string &pass) : IdentifyRequest(o, user, pass), source(src), cmd(c) { }
|
||||
|
||||
void OnSuccess() anope_override
|
||||
{
|
||||
@@ -90,13 +90,13 @@ class CommandNSGhost : public Command
|
||||
|
||||
if (ok == false && !pass.empty())
|
||||
{
|
||||
NSGhostRequest *req = new NSGhostRequest(source, this, na->nc->display, pass);
|
||||
NSGhostRequest *req = new NSGhostRequest(owner, source, this, na->nc->display, pass);
|
||||
FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(source.GetUser(), req));
|
||||
req->Dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
NSGhostRequest req(source, this, na->nc->display, pass);
|
||||
NSGhostRequest req(owner, source, this, na->nc->display, pass);
|
||||
|
||||
if (ok)
|
||||
req.OnSuccess();
|
||||
|
||||
@@ -21,7 +21,7 @@ class NSGroupRequest : public IdentifyRequest
|
||||
dynamic_reference<NickAlias> target;
|
||||
|
||||
public:
|
||||
NSGroupRequest(CommandSource &src, Command *c, const Anope::string &n, NickAlias *targ, const Anope::string &pass) : IdentifyRequest(targ->nc->display, pass), source(src), cmd(c), nick(n), target(targ) { }
|
||||
NSGroupRequest(Module *o, CommandSource &src, Command *c, const Anope::string &n, NickAlias *targ, const Anope::string &pass) : IdentifyRequest(o, targ->nc->display, pass), source(src), cmd(c), nick(n), target(targ) { }
|
||||
|
||||
void OnSuccess() anope_override
|
||||
{
|
||||
@@ -146,13 +146,13 @@ class CommandNSGroup : public Command
|
||||
|
||||
if (ok == false && !pass.empty())
|
||||
{
|
||||
NSGroupRequest *req = new NSGroupRequest(source, this, u->nick, target, pass);
|
||||
NSGroupRequest *req = new NSGroupRequest(owner, source, this, u->nick, target, pass);
|
||||
FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(source.GetUser(), req));
|
||||
req->Dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
NSGroupRequest req(source, this, u->nick, target, pass);
|
||||
NSGroupRequest req(owner, source, this, u->nick, target, pass);
|
||||
|
||||
if (ok)
|
||||
req.OnSuccess();
|
||||
|
||||
@@ -19,7 +19,7 @@ class NSIdentifyRequest : public IdentifyRequest
|
||||
Command *cmd;
|
||||
|
||||
public:
|
||||
NSIdentifyRequest(CommandSource &s, Command *c, const Anope::string &acc, const Anope::string &pass) : IdentifyRequest(acc, pass), source(s), cmd(c) { }
|
||||
NSIdentifyRequest(Module *o, CommandSource &s, Command *c, const Anope::string &acc, const Anope::string &pass) : IdentifyRequest(o, acc, pass), source(s), cmd(c) { }
|
||||
|
||||
void OnSuccess() anope_override
|
||||
{
|
||||
@@ -81,7 +81,7 @@ class CommandNSIdentify : public Command
|
||||
source.Reply(_("You are already identified."));
|
||||
else
|
||||
{
|
||||
NSIdentifyRequest *req = new NSIdentifyRequest(source, this, na ? na->nc->display : nick, pass);
|
||||
NSIdentifyRequest *req = new NSIdentifyRequest(owner, source, this, na ? na->nc->display : nick, pass);
|
||||
FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(source.GetUser(), req));
|
||||
req->Dispatch();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class NSRecoverRequest : public IdentifyRequest
|
||||
dynamic_reference<NickAlias> na;
|
||||
|
||||
public:
|
||||
NSRecoverRequest(CommandSource &src, Command *c, NickAlias *n, const Anope::string &pass) : IdentifyRequest(n->nc->display, pass), source(src), cmd(c), na(n) { }
|
||||
NSRecoverRequest(Module *m, CommandSource &src, Command *c, NickAlias *n, const Anope::string &pass) : IdentifyRequest(m, n->nc->display, pass), source(src), cmd(c), na(n) { }
|
||||
|
||||
void OnSuccess() anope_override
|
||||
{
|
||||
@@ -101,13 +101,13 @@ class CommandNSRecover : public Command
|
||||
|
||||
if (ok == false && !pass.empty())
|
||||
{
|
||||
NSRecoverRequest *req = new NSRecoverRequest(source, this, na, pass);
|
||||
NSRecoverRequest *req = new NSRecoverRequest(owner, source, this, na, pass);
|
||||
FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(source.GetUser(), req));
|
||||
req->Dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
NSRecoverRequest req(source, this, na, pass);
|
||||
NSRecoverRequest req(owner, source, this, na, pass);
|
||||
|
||||
if (ok)
|
||||
req.OnSuccess();
|
||||
|
||||
@@ -20,7 +20,7 @@ class NSReleaseRequest : public IdentifyRequest
|
||||
dynamic_reference<NickAlias> na;
|
||||
|
||||
public:
|
||||
NSReleaseRequest(CommandSource &src, Command *c, NickAlias *n, const Anope::string &pass) : IdentifyRequest(n->nc->display, pass), source(src), cmd(c), na(n) { }
|
||||
NSReleaseRequest(Module *m, CommandSource &src, Command *c, NickAlias *n, const Anope::string &pass) : IdentifyRequest(m, n->nc->display, pass), source(src), cmd(c), na(n) { }
|
||||
|
||||
void OnSuccess() anope_override
|
||||
{
|
||||
@@ -81,13 +81,13 @@ class CommandNSRelease : public Command
|
||||
|
||||
if (ok == false && !pass.empty())
|
||||
{
|
||||
NSReleaseRequest *req = new NSReleaseRequest(source, this, na, pass);
|
||||
NSReleaseRequest *req = new NSReleaseRequest(owner, source, this, na, pass);
|
||||
FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(source.GetUser(), req));
|
||||
req->Dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
NSReleaseRequest req(source, this, na, pass);
|
||||
NSReleaseRequest req(owner, source, this, na, pass);
|
||||
|
||||
if (ok)
|
||||
req.OnSuccess();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "module.h"
|
||||
#include "xmlrpc.h"
|
||||
|
||||
static Module *me;
|
||||
|
||||
class XMLRPCIdentifyRequest : public IdentifyRequest
|
||||
{
|
||||
XMLRPCRequest request;
|
||||
@@ -8,7 +10,7 @@ class XMLRPCIdentifyRequest : public IdentifyRequest
|
||||
dynamic_reference<XMLRPCClientSocket> source;
|
||||
|
||||
public:
|
||||
XMLRPCIdentifyRequest(XMLRPCRequest& req, XMLRPCServiceInterface* iface, XMLRPCClientSocket* s, const Anope::string &acc, const Anope::string &pass) : IdentifyRequest(acc, pass), request(req), xinterface(iface), source(s) { }
|
||||
XMLRPCIdentifyRequest(Module *m, XMLRPCRequest& req, XMLRPCServiceInterface* iface, XMLRPCClientSocket* s, const Anope::string &acc, const Anope::string &pass) : IdentifyRequest(m, acc, pass), request(req), xinterface(iface), source(s) { }
|
||||
|
||||
void OnSuccess() anope_override
|
||||
{
|
||||
@@ -104,7 +106,7 @@ class MyXMLRPCEvent : public XMLRPCEvent
|
||||
request->reply("error", "Invalid parameters");
|
||||
else
|
||||
{
|
||||
XMLRPCIdentifyRequest *req = new XMLRPCIdentifyRequest(*request, iface, source, username, password);
|
||||
XMLRPCIdentifyRequest *req = new XMLRPCIdentifyRequest(me, *request, iface, source, username, password);
|
||||
FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(NULL, req));
|
||||
req->Dispatch();
|
||||
}
|
||||
@@ -248,6 +250,8 @@ class ModuleXMLRPCMain : public Module
|
||||
if (!xmlrpc)
|
||||
throw ModuleException("Unable to find xmlrpc reference, is m_xmlrpc loaded?");
|
||||
|
||||
me = this;
|
||||
|
||||
xmlrpc->Register(&stats);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class WebpanelRequest : public IdentifyRequest
|
||||
TemplateFileServer::Replacements replacements;
|
||||
|
||||
public:
|
||||
WebpanelRequest(HTTPReply &r, HTTPMessage &m, HTTPProvider *s, const Anope::string &p_n, HTTPClient *c, TemplateFileServer::Replacements &re, const Anope::string &user, const Anope::string &pass) : IdentifyRequest(user, pass), reply(r), message(m), server(s), page_name(p_n), client(c), replacements(re) { }
|
||||
WebpanelRequest(Module *o, HTTPReply &r, HTTPMessage &m, HTTPProvider *s, const Anope::string &p_n, HTTPClient *c, TemplateFileServer::Replacements &re, const Anope::string &user, const Anope::string &pass) : IdentifyRequest(o, user, pass), reply(r), message(m), server(s), page_name(p_n), client(c), replacements(re) { }
|
||||
|
||||
void OnSuccess() anope_override
|
||||
{
|
||||
@@ -86,7 +86,7 @@ bool WebCPanel::Index::OnRequest(HTTPProvider *server, const Anope::string &page
|
||||
{
|
||||
// Rate limit check.
|
||||
|
||||
WebpanelRequest *req = new WebpanelRequest(reply, message, server, page_name, client, replacements, user, pass);
|
||||
WebpanelRequest *req = new WebpanelRequest(me, reply, message, server, page_name, client, replacements, user, pass);
|
||||
FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(NULL, req));
|
||||
req->Dispatch();
|
||||
return false;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "webcpanel.h"
|
||||
|
||||
Module *me;
|
||||
Anope::string provider_name, template_name, template_base, page_title;
|
||||
|
||||
class ModuleWebCPanel : public Module
|
||||
@@ -45,6 +46,8 @@ class ModuleWebCPanel : public Module
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
|
||||
me = this;
|
||||
|
||||
ConfigReader reader;
|
||||
provider_name = reader.ReadValue("webcpanel", "server", "httpd/main", 0);
|
||||
template_name = reader.ReadValue("webcpanel", "template", "template", 0);
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "static_fileserver.h"
|
||||
#include "template_fileserver.h"
|
||||
|
||||
extern Module *me;
|
||||
|
||||
extern Anope::string provider_name, template_name, template_base, page_title;
|
||||
|
||||
struct SubSection
|
||||
|
||||
+3
-1
@@ -95,7 +95,7 @@ void change_core_display(NickCore *nc)
|
||||
|
||||
std::set<IdentifyRequest *> IdentifyRequest::requests;
|
||||
|
||||
IdentifyRequest::IdentifyRequest(const Anope::string &acc, const Anope::string &pass) : account(acc), password(pass), dispatched(false), success(false)
|
||||
IdentifyRequest::IdentifyRequest(Module *o, const Anope::string &acc, const Anope::string &pass) : owner(o), account(acc), password(pass), dispatched(false), success(false)
|
||||
{
|
||||
requests.insert(this);
|
||||
}
|
||||
@@ -150,5 +150,7 @@ void IdentifyRequest::ModuleUnload(Module *m)
|
||||
++it;
|
||||
|
||||
ir->Release(m);
|
||||
if (ir->owner == m)
|
||||
delete ir;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user