summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modules.h8
-rw-r--r--src/commands.cpp13
-rw-r--r--src/modules.cpp2
3 files changed, 20 insertions, 3 deletions
diff --git a/include/modules.h b/include/modules.h
index 1e0fcf936..57a7a1e04 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -619,6 +619,14 @@ class Module : public classbase
* may be able to use for pre-determined purposes (e.g. the results of an SQL query, etc).
*/
virtual char* OnRequest(Request* request);
+
+ /** Called whenever an oper password is to be compared to what a user has input.
+ * The password field (from the config file) is in 'password' and is to be compared against
+ * 'input'. This method allows for encryption of oper passwords and much more besides.
+ * You should return a nonzero value if you want to allow the comparison or zero if you wish
+ * to do nothing.
+ */
+ virtual int OnOperCompare(std::string password, std::string input);
};
diff --git a/src/commands.cpp b/src/commands.cpp
index 7093386aa..db2cd3624 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -1605,7 +1605,16 @@ bool is_uline(const char* server)
}
return false;
}
-
+int operstrcmp(char* data,char* input)
+{
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(OnOperCompare(data,input))
+ if (MOD_RESULT == 1)
+ return 0;
+ if (MOD_RESULT == -1)
+ return 1;
+ return strcmp(data,input);
+}
void handle_oper(char **parameters, int pcnt, userrec *user)
{
@@ -1628,7 +1637,7 @@ void handle_oper(char **parameters, int pcnt, userrec *user)
ConfValue("oper","password",i,Password,&config_f);
ConfValue("oper","type",i,OperType,&config_f);
ConfValue("oper","host",i,HostName,&config_f);
- if ((!strcmp(LoginName,parameters[0])) && (!strcmp(Password,parameters[1])) && (match(TheHost,HostName)))
+ if ((!strcmp(LoginName,parameters[0])) && (!operstrcmp(Password,parameters[1])) && (match(TheHost,HostName)))
{
fail2 = true;
for (j =0; j < ConfValueEnum("type",&config_f); j++)
diff --git a/src/modules.cpp b/src/modules.cpp
index 50b9bdbc2..83abb6e57 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -405,7 +405,7 @@ int Module::OnLocalTopicChange(userrec* user, chanrec* chan, std::string topic)
int Module::OnMeshToken(char token,string_list params,serverrec* source,serverrec* reply, std::string tcp_host,std::string ipaddr,int port) { return 0; };
void Module::OnEvent(Event* event) { return; };
char* Module::OnRequest(Request* request) { return NULL; };
-
+int Module::OnOperCompare(std::string password, std::string input) { return 0; };
// server is a wrapper class that provides methods to all of the C-style
// exports in the core