summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/nickserv.example.conf7
-rw-r--r--docs/Changes.conf1
-rw-r--r--include/language.h3
-rw-r--r--modules/commands/ns_register.cpp3
-rw-r--r--modules/commands/ns_set.cpp14
5 files changed, 27 insertions, 1 deletions
diff --git a/data/nickserv.example.conf b/data/nickserv.example.conf
index 53307f33f..667e427b1 100644
--- a/data/nickserv.example.conf
+++ b/data/nickserv.example.conf
@@ -209,6 +209,13 @@ module
nonicknameownership = no
/*
+ * The minimum length of passwords
+ *
+ * This directive is optional. If not set it defaults to 8.
+ */
+ minpasslen = 8
+
+ /*
* The maximum length of passwords
*
* This directive is optional. If not set it defaults to 32.
diff --git a/docs/Changes.conf b/docs/Changes.conf
index 6a530436b..9f9802834 100644
--- a/docs/Changes.conf
+++ b/docs/Changes.conf
@@ -1,5 +1,6 @@
Anope Version 2.1.0-git
--------------------
+Added nickserv:minpasslen for configuring the minimum password length.
Renamed nickserv:passlen to nickserv:maxpasslen.
Anope Version 2.0.10-git
diff --git a/include/language.h b/include/language.h
index bdf5b3042..3087da802 100644
--- a/include/language.h
+++ b/include/language.h
@@ -73,7 +73,8 @@ namespace Language
#define MORE_OBSCURE_PASSWORD _("Please try again with a more obscure password. Passwords should be at least\n" \
"five characters long, should not be something easily guessed\n" \
"(e.g. your real name or your nick), and cannot contain the space or tab characters.")
-#define PASSWORD_TOO_LONG _("Your password is too long. It must not exceed %u characters.")
+#define PASSWORD_TOO_SHORT _("Your password is too short. It must must be longer than %u characters.")
+#define PASSWORD_TOO_LONG _("Your password is too long. It must be shorter than %u characters.")
#define NICK_NOT_REGISTERED _("Your nick isn't registered.")
#define NICK_X_NOT_REGISTERED _("Nick \002%s\002 isn't registered.")
#define NICK_X_NOT_IN_USE _("Nick \002%s\002 isn't currently in use.")
diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp
index bf59ad1d0..bdbff9386 100644
--- a/modules/commands/ns_register.cpp
+++ b/modules/commands/ns_register.cpp
@@ -192,6 +192,7 @@ class CommandNSRegister : public Command
}
}
+ unsigned int minpasslen = Config->GetModule("nickserv")->Get<unsigned>("minpasslen", "8");
unsigned int maxpasslen = Config->GetModule("nickserv")->Get<unsigned>("maxpasslen", "32");
if (Config->GetModule("nickserv")->Get<bool>("forceemail", "yes") && email.empty())
@@ -202,6 +203,8 @@ class CommandNSRegister : public Command
source.Reply(NICK_ALREADY_REGISTERED, u_nick.c_str());
else if (pass.equals_ci(u_nick) || (Config->GetBlock("options")->Get<bool>("strictpasswords") && pass.length() < 5))
source.Reply(MORE_OBSCURE_PASSWORD);
+ else if (pass.length() < minpasslen)
+ source.Reply(PASSWORD_TOO_SHORT, minpasslen);
else if (pass.length() > maxpasslen)
source.Reply(PASSWORD_TOO_LONG, maxpasslen);
else if (!email.empty() && !Mail::Validate(email))
diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp
index 22f74703c..8008bd5d4 100644
--- a/modules/commands/ns_set.cpp
+++ b/modules/commands/ns_set.cpp
@@ -137,6 +137,13 @@ class CommandNSSetPassword : public Command
return;
}
+ unsigned int minpasslen = Config->GetModule("nickserv")->Get<unsigned>("minpasslen", "8");
+ if (len < minpasslen)
+ {
+ source.Reply(PASSWORD_TOO_SHORT, minpasslen);
+ return;
+ }
+
unsigned int maxpasslen = Config->GetModule("nickserv")->Get<unsigned>("maxpasslen", "32");
if (len > maxpasslen)
{
@@ -199,6 +206,13 @@ class CommandNSSASetPassword : public Command
return;
}
+ unsigned int minpasslen = Config->GetModule("nickserv")->Get<unsigned>("minpasslen", "8");
+ if (len < minpasslen)
+ {
+ source.Reply(PASSWORD_TOO_SHORT, minpasslen);
+ return;
+ }
+
unsigned int maxpasslen = Config->GetModule("nickserv")->Get<unsigned>("maxpasslen", "32");
if (len > maxpasslen)
{