add username-nounderscore and username-nodash config files
authorivan <ivan>
Fri, 26 Apr 2002 11:14:37 +0000 (11:14 +0000)
committerivan <ivan>
Fri, 26 Apr 2002 11:14:37 +0000 (11:14 +0000)
FS/FS/Conf.pm
FS/FS/svc_acct.pm

index 3565be9..6e45ec0 100644 (file)
@@ -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',
index d3c415c..bb8c5e2 100644 (file)
@@ -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');
   }