summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/Conf.pm14
-rw-r--r--FS/FS/svc_acct.pm11
2 files changed, 24 insertions, 1 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 3565be965..6e45ec052 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -779,6 +779,20 @@ httemplate/docs/config.html
},
{
+ 'key' => 'username-nounderscore',
+ 'section' => 'username',
+ 'description' => 'Disallow underscores in usernames',
+ 'type' => 'checkbox',
+ },
+
+ {
+ 'key' => 'username-nodash',
+ 'section' => 'username',
+ 'description' => 'Disallow dashes in usernames',
+ 'type' => 'checkbox',
+ },
+
+ {
'key' => 'username-uppercase',
'section' => 'username',
'description' => 'Allow uppercase characters in usernames',
diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
index d3c415ce3..bb8c5e21e 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -5,7 +5,8 @@ use vars qw( @ISA $noexport_hack $conf
$dir_prefix @shells $usernamemin
$usernamemax $passwordmin $passwordmax
$username_ampersand $username_letter $username_letterfirst
- $username_noperiod $username_uppercase
+ $username_noperiod $username_nounderscore $username_nodash
+ $username_uppercase
$mydomain
$dirhash
@saltset @pw_set );
@@ -40,6 +41,8 @@ $FS::UID::callback{'FS::svc_acct'} = sub {
$username_letter = $conf->exists('username-letter');
$username_letterfirst = $conf->exists('username-letterfirst');
$username_noperiod = $conf->exists('username-noperiod');
+ $username_nounderscore = $conf->exists('username-nounderscore');
+ $username_nodash = $conf->exists('username-nodash');
$username_uppercase = $conf->exists('username-uppercase');
$username_ampersand = $conf->exists('username-ampersand');
$mydomain = $conf->config('domain');
@@ -547,6 +550,12 @@ sub check {
if ( $username_noperiod ) {
$recref->{username} =~ /\./ and return gettext('illegal_username');
}
+ if ( $username_nounderscore ) {
+ $recref->{username} =~ /_/ and return gettext('illegal_username');
+ }
+ if ( $username_nodash ) {
+ $recref->{username} =~ /\-/ and return gettext('illegal_username');
+ }
unless ( $username_ampersand ) {
$recref->{username} =~ /\&/ and return gettext('illegal_username');
}