X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fsvc_acct.pm;h=42eb7d9eef7b6d5d2063b976333bf81f5e8eabea;hp=d2e3918dab5cd8634946206f328a91371688eb84;hb=8a8c9386cbd3383b0134aae8e32b5995f8886fb2;hpb=48b905cd57f4b9e0f33e84bcee15b28d812c3d9f diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index d2e3918da..42eb7d9ee 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -2,14 +2,14 @@ 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; 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; @@ -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' , '.' , '/' ); @@ -80,6 +82,10 @@ FS::svc_acct - Object methods for svc_acct records %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 @@ -111,6 +117,8 @@ FS::svc_Common. The following fields are currently supported: =item radius_I - I +=item domsvc - service number of svc_domain with which to associate + =back =head1 METHODS @@ -167,10 +175,12 @@ sub insert { 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 } ) @@ -377,15 +387,22 @@ sub check { return $x unless ref($x); my $part_svc = $x; + my $error = $self->ut_number('domsvc'); + return $error if $error; + my $ulen = $usernamemax || $self->dbdef_table->column('username')->length; $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} } ); @@ -402,8 +419,8 @@ sub check { 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"; @@ -473,6 +490,8 @@ sub check { $recref->{_password} = $1.$3; } elsif ( $recref->{_password} eq '*' ) { $recref->{_password} = '*'; + } elsif ( $recref->{_password} eq '!!' ) { + $recref->{_password} = '!!'; } else { return "Illegal password"; } @@ -532,11 +551,30 @@ sub radius_check { } grep { /^rc_/ && $self->getfield($_) } fields( $self->table ); } +=item email + +Returns an email address associated with the account. + =cut +sub email { + my $self = shift; + my $domain; + my $svc_domain = qsearchs( 'svc_domain', { 'svcnum' => $self->domsvc } ); + if ($svc_domain) { + $domain=$svc_domain->domain; + }else{ + warn "couldn't find svc_acct.domsvc " . $self->domsvc . "!"; + $domain="unknown"; + } + return $self->username . "@" . $domain; +} + +=back + =head1 VERSION -$Id: svc_acct.pm,v 1.13 2000-07-17 13:51:07 ivan Exp $ +$Id: svc_acct.pm,v 1.24 2001-08-19 15:53:34 jeff Exp $ =head1 BUGS @@ -552,7 +590,7 @@ counterintuitive. =head1 SEE ALSO L, L, L, L, -L, L, L, L, L, +L, L, L, L, L, schema.html from the base documentation. =cut