summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-13 22:40:30 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-13 22:40:30 +0000
commit5adff9af1b71adb9ebaaa09159821b1947f7f625 (patch)
tree8dc8922fac56c2771940e35a1fd11824f2338f11
parentf9c08a2906e03008055cf513b19eae9ccf5089bf (diff)
Change this to use our md5 provider rather than MD5() in the query
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6303 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/extra/m_sqloper.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/modules/extra/m_sqloper.cpp b/src/modules/extra/m_sqloper.cpp
index bc506f917..5d56b0fad 100644
--- a/src/modules/extra/m_sqloper.cpp
+++ b/src/modules/extra/m_sqloper.cpp
@@ -20,6 +20,7 @@
#include "m_sqlv2.h"
#include "m_sqlutils.h"
+#include "m_hash.h"
#include "commands/cmd_oper.h"
/* $ModDesc: Allows storage of oper credentials in an SQL table */
@@ -29,6 +30,7 @@ class ModuleSQLOper : public Module
{
InspIRCd* Srv;
Module* SQLutils;
+ Module* HashModule;
std::string databaseid;
public:
@@ -37,6 +39,12 @@ public:
{
ServerInstance->UseInterface("SQLutils");
ServerInstance->UseInterface("SQL");
+ ServerInstance->UseInterface("HashRequest");
+
+ /* Attempt to locate the md5 service provider, bail if we can't find it */
+ HashModule = ServerInstance->FindModule("m_md5.so");
+ if (!HashModule)
+ throw ModuleException("Can't find m_md5.so. Please load m_md5.so before m_sqloper.so.");
SQLutils = ServerInstance->FindModule("m_sqlutils.so");
if (!SQLutils)
@@ -49,6 +57,7 @@ public:
{
ServerInstance->DoneWithInterface("SQL");
ServerInstance->DoneWithInterface("SQLutils");
+ ServerInstance->DoneWithInterface("HashRequest");
}
void Implements(char* List)
@@ -88,7 +97,12 @@ public:
if (target)
{
- SQLrequest req = SQLreq(this, target, databaseid, "SELECT username, password, hostname, type FROM ircd_opers WHERE username = '?' AND password=md5('?')", username, password);
+ /* Reset hash module first back to MD5 standard state */
+ HashResetRequest(this, HashModule).Send();
+ /* Make an MD5 hash of the password for using in the query */
+ std::string md5_pass_hash = HashSumRequest(this, HashModule, password.c_str()).Send();
+
+ SQLrequest req = SQLreq(this, target, databaseid, "SELECT username, password, hostname, type FROM ircd_opers WHERE username = '?' AND password='?'", username, md5_pass_hash);
if (req.Send())
{