summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-09-03 21:38:29 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-09-03 21:38:29 +0000
commit547ee1342e8b07bcdf46bc81343d1a1f7a2998e5 (patch)
treebff11b7c236893ebe4e7cc86f4beba0d7a27c49e /src
parent8cb9b91cf7789e14d332cd125d708d956db39c78 (diff)
YAY! A module which allows a user to oper via their ssl key fingerprint.
This is largely untested stuff here, be careful with it. Use /fingerprint to get the user's fingerprint (or ask them for it) and then put the fingerprint into the password field of their oper block. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5130 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/extra/m_ssl_oper_cert.cpp152
-rw-r--r--src/modules/m_opermd5.cpp2
2 files changed, 153 insertions, 1 deletions
diff --git a/src/modules/extra/m_ssl_oper_cert.cpp b/src/modules/extra/m_ssl_oper_cert.cpp
new file mode 100644
index 000000000..0d1ab045c
--- /dev/null
+++ b/src/modules/extra/m_ssl_oper_cert.cpp
@@ -0,0 +1,152 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
+ * E-mail:
+ * <brain@chatspike.net>
+ * <Craig@chatspike.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+/* $ModDesc: Allows for MD5 encrypted oper passwords */
+
+using namespace std;
+
+#include <stdio.h>
+#include "inspircd_config.h"
+#include "users.h"
+#include "channels.h"
+#include "modules.h"
+#include "inspircd.h"
+#include "ssl_cert.h"
+
+class cmd_fingerprint : public command_t
+{
+ public:
+ cmd_fingerprint (InspIRCd* Instance) : command_t(Instance,"FINGERPRINT", 0, 1)
+ {
+ this->source = "m_ssl_oper_cert.so";
+ syntax = "<nickname>";
+ }
+
+ void Handle (const char** parameters, int pcnt, userrec *user)
+ {
+ userrec* target = ServerInstance->FindNick(parameters[0]);
+ if (target)
+ {
+ ssl_cert* cert;
+ if (target->GetExt("ssl_cert",cert))
+ {
+ if (cert->GetFingerprint().length())
+ user->WriteServ("NOTICE %s :Certificate fingerprint for %s is %s",user->nick,target->nick,cert->GetFingerprint().c_str());
+ else
+ user->WriteServ("NOTICE %s :Certificate fingerprint for %s does not exist!", user->nick,target->nick);
+ }
+ else
+ {
+ user->WriteServ("NOTICE %s :Certificate fingerprint for %s does not exist!", user->nick, target->nick);
+ }
+ }
+ else
+ {
+ user->WriteServ("401 %s %s :No such nickname", user->nick, parameters[0]);
+ }
+ }
+};
+
+
+class ModuleOperSSLCert : public Module
+{
+ ssl_cert* cert;
+ bool HasCert;
+ cmd_fingerprint* mycommand;
+ public:
+
+ ModuleOperSSLCert(InspIRCd* Me)
+ : Module::Module(Me)
+ {
+
+ mycommand = new cmd_fingerprint(ServerInstance);
+ ServerInstance->AddCommand(mycommand);
+ }
+
+ virtual ~ModuleOperSSLCert()
+ {
+ }
+
+ void Implements(char* List)
+ {
+ List[I_OnOperCompare] = List[I_OnPreCommand] = 1;
+ }
+
+ virtual int OnOperCompare(const std::string &data, const std::string &input)
+ {
+ ServerInstance->Log(DEBUG,"HasCert=%d, data='%s' input='%s'",HasCert,data.c_str(), input.c_str());
+ if (((data.length()) && (data.length() == cert->GetFingerprint().length())))
+ {
+ ServerInstance->Log(DEBUG,"Lengths match, cert='%s'",cert->GetFingerprint().c_str());
+ if (data == cert->GetFingerprint())
+ {
+ ServerInstance->Log(DEBUG,"Return 1");
+ return 1;
+ }
+ else
+ {
+ ServerInstance->Log(DEBUG,"'%s' != '%s'",data.c_str(), cert->GetFingerprint().c_str());
+ return 0;
+ }
+ }
+ else
+ {
+ ServerInstance->Log(DEBUG,"Lengths dont match");
+ return 0;
+ }
+ }
+
+ virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated)
+ {
+ irc::string cmd = command.c_str();
+
+ if ((cmd == "OPER") && (validated == 1))
+ {
+ HasCert = user->GetExt("ssl_cert",cert);
+ ServerInstance->Log(DEBUG,"HasCert=%d",HasCert);
+ }
+ return 0;
+ }
+
+ virtual Version GetVersion()
+ {
+ return Version(1,1,0,0,VF_VENDOR);
+ }
+};
+
+class ModuleOperSSLCertFactory : public ModuleFactory
+{
+ public:
+ ModuleOperSSLCertFactory()
+ {
+ }
+
+ ~ModuleOperSSLCertFactory()
+ {
+ }
+
+ virtual Module * CreateModule(InspIRCd* Me)
+ {
+ return new ModuleOperSSLCert(Me);
+ }
+
+};
+
+
+extern "C" void * init_module( void )
+{
+ return new ModuleOperSSLCertFactory;
+}
diff --git a/src/modules/m_opermd5.cpp b/src/modules/m_opermd5.cpp
index 9ac896e81..e6fd8023b 100644
--- a/src/modules/m_opermd5.cpp
+++ b/src/modules/m_opermd5.cpp
@@ -319,7 +319,7 @@ class ModuleOperMD5 : public Module
{
return 1;
}
- else return -1;
+ else return 0;
}
return 0;
}