summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-04-01 18:53:32 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-04-01 18:53:32 +0000
commitfb1308514e384b1ae5fd95972e3b1ec7dfdd3af2 (patch)
tree8d15cb9396e634654d0c01f5eb0ab003b9b4d54d /src/modules
parentf505e1821bf0b6e3c36df4bab8e3a4f3d1710dfd (diff)
Add feature to this module which allows you to specify that an oper requires ssl to oper up, but doesnt require a fingerprint
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6727 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/extra/m_ssl_oper_cert.cpp52
1 files changed, 34 insertions, 18 deletions
diff --git a/src/modules/extra/m_ssl_oper_cert.cpp b/src/modules/extra/m_ssl_oper_cert.cpp
index 0c13d5e6d..1f9a8b911 100644
--- a/src/modules/extra/m_ssl_oper_cert.cpp
+++ b/src/modules/extra/m_ssl_oper_cert.cpp
@@ -74,25 +74,32 @@ class ModuleOperSSLCert : public Module
ssl_cert* cert;
bool HasCert;
cmd_fingerprint* mycommand;
+ ConfigReader* cf;
public:
ModuleOperSSLCert(InspIRCd* Me)
: Module::Module(Me)
{
-
mycommand = new cmd_fingerprint(ServerInstance);
ServerInstance->AddCommand(mycommand);
+ cf = new ConfigReader(ServerInstance);
}
-
+
virtual ~ModuleOperSSLCert()
{
+ delete cf;
}
void Implements(char* List)
{
- List[I_OnPreCommand] = 1;
+ List[I_OnPreCommand] = List[I_OnRehash] = 1;
}
+ virtual void OnRehash(userrec* user, const std::string &parameter)
+ {
+ delete cf;
+ cf = new ConfigReader(ServerInstance);
+ }
bool OneOfMatches(const char* host, const char* ip, const char* hostlist)
{
@@ -115,31 +122,40 @@ class ModuleOperSSLCert : public Module
if ((cmd == "OPER") && (validated))
{
- char LoginName[MAXBUF];
- char Password[MAXBUF];
- char OperType[MAXBUF];
- char HostName[MAXBUF];
char TheHost[MAXBUF];
char TheIP[MAXBUF];
- char FingerPrint[MAXBUF];
+ std::string LoginName;
+ std::string Password;
+ std::string OperType;
+ std::string HostName;
+ std::string FingerPrint;
+ bool SSLOnly;
+ char* dummy;
snprintf(TheHost,MAXBUF,"%s@%s",user->ident,user->host);
snprintf(TheIP, MAXBUF,"%s@%s",user->ident,user->GetIPString());
HasCert = user->GetExt("ssl_cert",cert);
- ServerInstance->Log(DEBUG,"HasCert=%d",HasCert);
- for (int i = 0; i < ServerInstance->Config->ConfValueEnum(ServerInstance->Config->config_data, "oper"); i++)
+
+ for (int i = 0; i < cf->Enumerate("oper"); i++)
{
- ServerInstance->Config->ConfValue(ServerInstance->Config->config_data, "oper", "name", i, LoginName, MAXBUF);
- ServerInstance->Config->ConfValue(ServerInstance->Config->config_data, "oper", "password", i, Password, MAXBUF);
- ServerInstance->Config->ConfValue(ServerInstance->Config->config_data, "oper", "type", i, OperType, MAXBUF);
- ServerInstance->Config->ConfValue(ServerInstance->Config->config_data, "oper", "host", i, HostName, MAXBUF);
- ServerInstance->Config->ConfValue(ServerInstance->Config->config_data, "oper", "fingerprint", i, FingerPrint, MAXBUF);
-
- if (*FingerPrint)
+ LoginName = cf->ReadValue("oper", "name", i);
+ Password = cf->ReadValue("oper", "password", i);
+ OperType = cf->ReadValue("oper", "type", i);
+ HostName = cf->ReadValue("oper", "host", i);
+ FingerPrint = cf->ReadValue("oper", "fingerprint", i);
+ SSLOnly = cf->ReadFlag("oper", "sslonly", i);
+
+ if (SSLOnly || !FingerPrint.empty())
{
- if ((!strcmp(LoginName,parameters[0])) && (!ServerInstance->OperPassCompare(Password,parameters[1], i)) && (OneOfMatches(TheHost,TheIP,HostName)))
+ if ((!strcmp(LoginName.c_str(),parameters[0])) && (!ServerInstance->OperPassCompare(Password.c_str(),parameters[1],i)) && (OneOfMatches(TheHost,TheIP,HostName.c_str())))
{
+ if (SSLOnly && !user->GetExt("ssl", dummy))
+ {
+ user->WriteServ("491 %s :This oper login name requires an SSL connection.", user->nick);
+ return 1;
+ }
+
/* This oper would match */
if ((!cert) || (cert->GetFingerprint() != FingerPrint))
{