md5 passwords can are 34 characters long and have $ in them.
[freeside.git] / FS / FS / svc_acct.pm
index fcd8030..26c634b 100644 (file)
@@ -54,6 +54,8 @@ FS::svc_acct - Object methods for svc_acct records
 
   $error = $record->cancel;
 
+  %hash = $record->radius;
+
 =head1 DESCRIPTION
 
 An FS::svc_acct object represents an account.  FS::svc_acct inherits from
@@ -378,9 +380,8 @@ sub check {
     ;
 
     unless ( $recref->{username} eq 'sync' ) {
-      my($shell);
-      if ( $shell = (grep $_ eq $recref->{shell}, @shells)[0] ) {
-        $recref->{shell} = $shell;
+      if ( grep $_ eq $recref->{shell}, @shells ) {
+        $recref->{shell} = (grep $_ eq $recref->{shell}, @shells)[0];
       } else {
         return "Illegal shell \`". $self->shell. "\'; ".
                $conf->dir. "/shells contains: @shells";
@@ -435,7 +436,7 @@ sub check {
     #$recref->{password} = $1.
     #  crypt($3,$saltset[int(rand(64))].$saltset[int(rand(64))]
     #;
-  } elsif ( $recref->{_password} =~ /^((\*SUSPENDED\* )?)([\w\.\/]{13,24})$/ ) {
+  } elsif ( $recref->{_password} =~ /^((\*SUSPENDED\* )?)([\w\.\/\$]{13,34})$/ ) {
     $recref->{_password} = $1.$3;
   } elsif ( $recref->{_password} eq '*' ) {
     $recref->{_password} = '*';
@@ -446,11 +447,32 @@ sub check {
   ''; #no error
 }
 
+=item radius
+
+Returns key/value pairs, suitable for assigning to a hash, for any RADIUS
+attributes of this record.
+
+Note that this is now the preferred method for reading RADIUS attributes - 
+accessing the columns directly is discouraged, as the column names are
+expected to change in the future.
+
+=cut
+
+sub radius { 
+  my $self = shift;
+  map {
+    /^(radius_(.*))$/;
+    my($column, $attrib) = ($1, $2);
+    $attrib =~ s/_/\-/g;
+    ( $attrib, $self->getfield($column) );
+  } grep { /^radius_/ && $self->getfield($_) } fields( $self->table );
+}
+
 =back
 
 =head1 VERSION
 
-$Id: svc_acct.pm,v 1.3 2000-03-06 16:38:42 ivan Exp $
+$Id: svc_acct.pm,v 1.7 2000-06-29 11:56:52 ivan Exp $
 
 =head1 BUGS