add username-letter and username-letterfirst config files
authorivan <ivan>
Sun, 3 Jun 2001 12:36:10 +0000 (12:36 +0000)
committerivan <ivan>
Sun, 3 Jun 2001 12:36:10 +0000 (12:36 +0000)
FS/FS/svc_acct.pm
htdocs/docs/config.html

index 774b8d0..0e0c885 100644 (file)
@@ -2,7 +2,7 @@ package FS::svc_acct;
 
 use strict;
 use vars qw( @ISA $nossh_hack $conf $dir_prefix @shells $usernamemin
-             $usernamemax $passwordmin
+             $usernamemax $passwordmin $username_letter $username_letterfirst
              $shellmachine $useradd $usermod $userdel 
              @saltset @pw_set);
 use Carp;
@@ -46,6 +46,8 @@ $FS::UID::callback{'FS::svc_acct'} = sub {
                     'rm -rf $old_dir'.
                   ')';
   }
+  $username_letter = $conf->exists('username-letter');
+  $username_letterfirst = $conf->exists('username-letterfirst');
 };
 
 @saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' );
@@ -381,7 +383,11 @@ sub check {
   $recref->{username} =~ /^([a-z0-9_\-\.]{$usernamemin,$ulen})$/
     or return "Illegal username";
   $recref->{username} = $1;
-  $recref->{username} =~ /[a-z]/ or return "Illegal username";
+  if ( $username_letterfirst ) {
+    $recref->{username} =~ /^[a-z]/ or return "Illegal username";
+  } elsif ( $username_letter ) {
+    $recref->{username} =~ /[a-z]/ or return "Illegal username";
+  }
 
   $recref->{popnum} =~ /^(\d*)$/ or return "Illegal popnum: ".$recref->{popnum};
   $recref->{popnum} = $1;
@@ -536,7 +542,7 @@ sub radius_check {
 
 =head1 VERSION
 
-$Id: svc_acct.pm,v 1.16 2001-06-03 11:37:08 ivan Exp $
+$Id: svc_acct.pm,v 1.17 2001-06-03 12:36:10 ivan Exp $
 
 =head1 BUGS
 
index b255ce3..49be720 100644 (file)
@@ -99,6 +99,8 @@ All further configuration files and directories are located in
   <li><a name="textradiusprepend">textradiusprepend</a> - The contents of this file will be prepended to the first line of a user's RADIUS entry in text exports.  If necessary, usually `Auth-Type = Local, '.
   <li><a name="usernamemin">usernamemin</a> - Minimum username length (default 2);
   <li><a name="usernamemax">usernamemax</a> - Maximum username length (default is the size of the SQL column, probably specified when fs-setup was run)
+  <li><a name="usernamemax">username-letter</a> - The existance of this file will turn on the requirement that usernames contain at least one letter.
+  <li><a name="usernamemax">username-letterfirst</a> - The existance of this file will turn on the requirement that usernames start with a letter.
 </ul>
 </body>