summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViper <Viper@Anope.org>2011-04-28 22:16:18 +0200
committerViper <Viper@Anope.org>2011-04-28 22:16:18 +0200
commit096de4fb25bdb390753bc49b4914273e2929853c (patch)
treeb1e765643c020cd66145e86d207dbe3fc37e2a6b
parent01946cb46701aed6161e96ec8455bfacd8c3b164 (diff)
Bug #1263 - Fixed /ns REGISTER not getting an "unknown cmd" reply when ns_register is not loaded & ns_maxemail is loaded.
This Bug cannot be structurally fixed, needs to be addressed by 3rd party module authors for similar situations. This implementation can serve as a template.
-rw-r--r--Changes1
-rw-r--r--src/modules/ns_maxemail.c82
-rw-r--r--version.log3
3 files changed, 71 insertions, 15 deletions
diff --git a/Changes b/Changes
index 2927d7e6f..8bb338990 100644
--- a/Changes
+++ b/Changes
@@ -24,6 +24,7 @@ Anope Version 1.8 - GIT
03/03 F Fixed opping our clients on ratbox when not using TS6 [ #00]
03/04 F Fixed setting a users host in InspIRCd when vhost is turned off [ #00]
03/24 F Fixed groups display nick showing in HS req memos for aliases. [#1252]
+04/28 F Fixed missing NS REGISTER reply when ns_register is not loaded. [#1263]
Anope Version 1.8.5
-------------------
diff --git a/src/modules/ns_maxemail.c b/src/modules/ns_maxemail.c
index 557a214f7..fb540872e 100644
--- a/src/modules/ns_maxemail.c
+++ b/src/modules/ns_maxemail.c
@@ -23,8 +23,11 @@ void my_add_languages(void);
int my_ns_register(User * u);
int my_ns_set(User * u);
int my_event_reload(int argc, char **argv);
+int my_event_addcommand(int argc, char **argv);
+int my_event_delcommand(int argc, char **argv);
int NSEmailMax = 0;
+int added_register = 0;
#define LNG_NUM_STRINGS 2
#define LNG_NSEMAILMAX_REACHED 0
@@ -40,12 +43,18 @@ int AnopeInit(int argc, char **argv)
moduleAddVersion(VERSION);
moduleSetType(SUPPORTED);
- c = createCommand("REGISTER", my_ns_register, NULL, -1, -1, -1, -1,
- -1);
- if ((status = moduleAddCommand(NICKSERV, c, MOD_HEAD))) {
- alog("[ns_maxemail] Unable to create REGISTER command: %d",
- status);
- return MOD_STOP;
+ /* Only add the command if REGISTER is actually available.
+ * If it s not available, hooking to it will suppress anopes
+ * "Unknown Command" response.. ~ Viper */
+ if (findCommand(NICKSERV, "REGISTER")) {
+ c = createCommand("REGISTER", my_ns_register, NULL, -1, -1, -1, -1,
+ -1);
+ if ((status = moduleAddCommand(NICKSERV, c, MOD_HEAD))) {
+ alog("[ns_maxemail] Unable to create REGISTER command: %d",
+ status);
+ return MOD_STOP;
+ }
+ added_register = 1;
}
c = createCommand("SET", my_ns_set, NULL, -1, -1, -1, -1, -1);
@@ -60,6 +69,20 @@ int AnopeInit(int argc, char **argv)
return MOD_STOP;
}
+ /* If the REGISTER command is added after initial load, provide hooks.. */
+ evt = createEventHook(EVENT_ADDCOMMAND, my_event_addcommand);
+ if ((status = moduleAddEventHook(evt))) {
+ alog("[ns_maxemail] Unable to hook to EVENT_ADDCOMMAND: %d", status);
+ return MOD_STOP;
+ }
+
+ /* If the REGISTER command is deleted after initial load, remove hooks.. */
+ evt = createEventHook(EVENT_DELCOMMAND, my_event_delcommand);
+ if ((status = moduleAddEventHook(evt))) {
+ alog("[ns_maxemail] Unable to hook to EVENT_DELCOMMAND: %d", status);
+ return MOD_STOP;
+ }
+
my_load_config();
my_add_languages();
@@ -115,8 +138,8 @@ int my_ns_register(User * u)
cur_buffer = moduleGetLastBuffer();
email = myStrGetToken(cur_buffer, ' ', 1);
- if (!email)
- return MOD_CONT;
+ if (!email)
+ return MOD_CONT;
ret = check_email_limit_reached(email, u);
free(email);
@@ -133,10 +156,10 @@ int my_ns_set(User * u)
cur_buffer = moduleGetLastBuffer();
set = myStrGetToken(cur_buffer, ' ', 0);
-
- if (!set)
- return MOD_CONT;
-
+
+ if (!set)
+ return MOD_CONT;
+
if (stricmp(set, "email") != 0) {
free(set);
return MOD_CONT;
@@ -144,8 +167,8 @@ int my_ns_set(User * u)
free(set);
email = myStrGetToken(cur_buffer, ' ', 1);
- if (!email)
- return MOD_CONT;
+ if (!email)
+ return MOD_CONT;
ret = check_email_limit_reached(email, u);
free(email);
@@ -161,6 +184,37 @@ int my_event_reload(int argc, char **argv)
return MOD_CONT;
}
+int my_event_addcommand(int argc, char **argv)
+{
+ Command *c;
+ int status;
+
+ if (argc == 2 && stricmp(argv[0], "ns_maxemail")
+ && !stricmp(argv[1], "REGISTER") && !added_register) {
+ c = createCommand("REGISTER", my_ns_register, NULL, -1, -1, -1, -1,
+ -1);
+ if ((status = moduleAddCommand(NICKSERV, c, MOD_HEAD))) {
+ alog("[ns_maxemail] Unable to create REGISTER command: %d",
+ status);
+ return MOD_CONT;
+ }
+ added_register = 1;
+ }
+
+ return MOD_CONT;
+}
+
+int my_event_delcommand(int argc, char **argv)
+{
+ if (argc == 2 && stricmp(argv[0], "ns_maxemail")
+ && !stricmp(argv[1], "REGISTER") && added_register) {
+ moduleDelCommand(NICKSERV, "REGISTER");
+ added_register = 0;
+ }
+
+ return MOD_CONT;
+}
+
void my_load_config(void)
{
Directive confvalues[] = {
diff --git a/version.log b/version.log
index b754df270..7a8068a1f 100644
--- a/version.log
+++ b/version.log
@@ -8,9 +8,10 @@ VERSION_MAJOR="1"
VERSION_MINOR="8"
VERSION_PATCH="5"
VERSION_EXTRA="-git"
-VERSION_BUILD="3068"
+VERSION_BUILD="3069"
# $Log$ # Changes since 1.8.5 Release
+#Revision 3069 - Bug #1263 - Fixed /ns REGISTER not getting an "unknown cmd" reply when ns_register is not loaded & ns_maxemail is loaded. (Bug cannot be structurally fixed, needs to be addressed by 3rd party module authors for similar situations.)
#Revision 3068 - Added events for module loading/unloading and command creation/deletion. Enables modules expanding on other modules to adjust hooks if needed. - Related to bug #1263.
#Revision 3067 - Fixed bug #1252 - The group display nick showing in HS req memos instead of the requesting alias. Also cleaned up the mess in Changes...
#Revision 3066 - Added support m_services.c and m_change.c from Hybrid's contrib folder