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;
use FS::Conf;
-use FS::Record qw( qsearchs fields );
+use FS::Record qw( qsearch qsearchs fields );
use FS::svc_Common;
-use FS::SSH qw(ssh);
+use Net::SSH qw(ssh);
use FS::part_svc;
use FS::svc_acct_pop;
use FS::svc_acct_sm;
'rm -rf $old_dir'.
')';
}
+ $username_letter = $conf->exists('username-letter');
+ $username_letterfirst = $conf->exists('username-letterfirst');
};
@saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' );
%hash = $record->radius;
+ %hash = $record->radius_reply;
+
+ %hash = $record->radius_check;
+
=head1 DESCRIPTION
An FS::svc_acct object represents an account. FS::svc_acct inherits from
=item radius_I<Radius_Attribute> - I<Radius-Attribute>
+=item domsvc - service number of svc_domain with which to associate
+
=back
=head1 METHODS
return $error if $error;
return "Username ". $self->username. " in use"
- if qsearchs( 'svc_acct', { 'username' => $self->username } );
+ if qsearchs( 'svc_acct', { 'username' => $self->username,
+ 'domsvc' => $self->domsvc,
+ } );
my $part_svc = qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
- return "Unkonwn svcpart" unless $part_svc;
+ return "Unknown svcpart" unless $part_svc;
return "uid in use"
if $part_svc->svc_acct__uid_flag ne 'F'
&& qsearchs( 'svc_acct', { 'uid' => $self->uid } )
$self->shell,
);
if ( $username && $uid && $dir && $shellmachine && ! $nossh_hack ) {
- ssh("root\@$shellmachine", eval "$useradd");
+ ssh("root\@$shellmachine", eval qq("$useradd") );
}
''; #no error
$self->dir,
);
if ( $username && $shellmachine && ! $nossh_hack ) {
- ssh("root\@$shellmachine", eval "$userdel");
+ ssh("root\@$shellmachine", eval qq("$userdel") );
}
'';
$new->getfield('gid'),
);
if ( $old_dir && $new_dir && $old_dir ne $new_dir && ! $nossh_hack ) {
- ssh("root\@$shellmachine", eval "$usermod" );
+ ssh("root\@$shellmachine", eval qq("$usermod") );
}
''; #no error
sub check {
my $self = shift;
+ my $error =
+ $self->ut_numbern('svcnum')
+ || $self->ut_number('domsvc')
+ ;
+ return $error if $error;
+
my($recref) = $self->hashref;
my $x = $self->setfixed;
$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;
- return "Unkonwn popnum" unless
+ return "Unknown popnum" unless
! $recref->{popnum} ||
qsearchs('svc_acct_pop',{'popnum'=> $recref->{popnum} } );
return "Only root can have uid 0"
if $recref->{uid} == 0 && $recref->{username} ne 'root';
- my($error);
- return $error if $error=$self->ut_textn('finger');
+ $error = $self->ut_textn('finger');
+ return $error if $error;
$recref->{dir} =~ /^([\/\w\-]*)$/
or return "Illegal directory";
$recref->{_password} = $1.$3;
} elsif ( $recref->{_password} eq '*' ) {
$recref->{_password} = '*';
+ } elsif ( $recref->{_password} eq '!!' ) {
+ $recref->{_password} = '!!';
} else {
return "Illegal password";
}
} grep { /^rc_/ && $self->getfield($_) } fields( $self->table );
}
-=cut
+=back
=head1 VERSION
-$Id: svc_acct.pm,v 1.12 2000-07-17 10:53:42 ivan Exp $
+$Id: svc_acct.pm,v 1.21 2001-08-13 00:21:54 ivan Exp $
=head1 BUGS
=head1 SEE ALSO
L<FS::svc_Common>, L<FS::Record>, L<FS::Conf>, L<FS::cust_svc>,
-L<FS::part_svc>, L<FS::cust_pkg>, L<FS::SSH>, L<ssh>, L<FS::svc_acct_pop>,
+L<FS::part_svc>, L<FS::cust_pkg>, L<Net::SSH>, L<ssh>, L<FS::svc_acct_pop>,
schema.html from the base documentation.
=cut