4 use vars qw( @ISA $nossh_hack $conf $dir_prefix @shells $usernamemin
5 $usernamemax $passwordmin $passwordmax
6 $username_ampersand $username_letter $username_letterfirst
7 $username_noperiod $username_uppercase
8 $shellmachine $useradd $usermod $userdel $mydomain
9 $cyrus_server $cyrus_admin_user $cyrus_admin_pass
15 use FS::Record qw( qsearch qsearchs fields dbh );
21 use FS::cust_main_invoice;
26 @ISA = qw( FS::svc_Common );
28 #ask FS::UID to run this stuff for us later
29 $FS::UID::callback{'FS::svc_acct'} = sub {
31 $dir_prefix = $conf->config('home');
32 @shells = $conf->config('shells');
33 $shellmachine = $conf->config('shellmachine');
34 $usernamemin = $conf->config('usernamemin') || 2;
35 $usernamemax = $conf->config('usernamemax');
36 $passwordmin = $conf->config('passwordmin') || 6;
37 $passwordmax = $conf->config('passwordmax') || 8;
38 if ( $shellmachine ) {
39 if ( $conf->exists('shellmachine-useradd') ) {
40 $useradd = join("\n", $conf->config('shellmachine-useradd') )
41 || 'cp -pr /etc/skel $dir; chown -R $uid.$gid $dir';
43 $useradd = 'useradd -d $dir -m -s $shell -u $uid $username';
45 if ( $conf->exists('shellmachine-userdel') ) {
46 $userdel = join("\n", $conf->config('shellmachine-userdel') )
49 $userdel = 'userdel $username';
51 $usermod = join("\n", $conf->config('shellmachine-usermod') )
52 || '[ -d $old_dir ] && mv $old_dir $new_dir || ( '.
53 'chmod u+t $old_dir; mkdir $new_dir; cd $old_dir; '.
54 'find . -depth -print | cpio -pdm $new_dir; '.
55 'chmod u-t $new_dir; chown -R $uid.$gid $new_dir; '.
59 $username_letter = $conf->exists('username-letter');
60 $username_letterfirst = $conf->exists('username-letterfirst');
61 $username_noperiod = $conf->exists('username-noperiod');
62 $username_uppercase = $conf->exists('username-uppercase');
63 $username_ampersand = $conf->exists('username-ampersand');
64 $mydomain = $conf->config('domain');
65 if ( $conf->exists('cyrus') ) {
66 ($cyrus_server, $cyrus_admin_user, $cyrus_admin_pass) =
67 $conf->config('cyrus');
68 eval "use Cyrus::IMAP::Admin;"
71 $cyrus_admin_user = '';
72 $cyrus_admin_pass = '';
74 if ( $conf->exists('icradius_secrets') ) {
75 $icradius_dbh = DBI->connect($conf->config('icradius_secrets'))
80 $dirhash = $conf->config('dirhash') || 0;
83 @saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' );
84 @pw_set = ( 'a'..'z', 'A'..'Z', '0'..'9', '(', ')', '#', '!', '.', ',' );
86 #not needed in 5.004 #srand($$|time);
90 my ( $hashref, $cache ) = @_;
91 if ( $hashref->{'svc_acct_svcnum'} ) {
92 $self->{'_domsvc'} = FS::svc_domain->new( {
93 'svcnum' => $hashref->{'domsvc'},
94 'domain' => $hashref->{'svc_acct_domain'},
95 'catchall' => $hashref->{'svc_acct_catchall'},
102 FS::svc_acct - Object methods for svc_acct records
108 $record = new FS::svc_acct \%hash;
109 $record = new FS::svc_acct { 'column' => 'value' };
111 $error = $record->insert;
113 $error = $new_record->replace($old_record);
115 $error = $record->delete;
117 $error = $record->check;
119 $error = $record->suspend;
121 $error = $record->unsuspend;
123 $error = $record->cancel;
125 %hash = $record->radius;
127 %hash = $record->radius_reply;
129 %hash = $record->radius_check;
133 An FS::svc_acct object represents an account. FS::svc_acct inherits from
134 FS::svc_Common. The following fields are currently supported:
138 =item svcnum - primary key (assigned automatcially for new accounts)
142 =item _password - generated if blank
144 =item popnum - Point of presence (see L<FS::svc_acct_pop>)
152 =item dir - set automatically if blank (and uid is not)
156 =item quota - (unimplementd)
158 =item slipip - IP address
162 =item domsvc - svcnum from svc_domain
164 =item radius_I<Radius_Attribute> - I<Radius-Attribute>
166 =item domsvc - service number of svc_domain with which to associate
176 Creates a new account. To add the account to the database, see L<"insert">.
180 sub table { 'svc_acct'; }
184 Adds this account to the database. If there is an error, returns the error,
185 otherwise returns false.
187 The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be
188 defined. An FS::cust_svc record will be created and inserted.
190 If the configuration value (see L<FS::Conf>) shellmachine exists, and the
191 username, uid, and dir fields are defined, the command(s) specified in
192 the shellmachine-useradd configuration are added to the job queue (see
193 L<FS::queue> and L<freeside-queued>) to be exectued on shellmachine via ssh.
194 This behaviour can be surpressed by setting $FS::svc_acct::nossh_hack true.
195 If the shellmachine-useradd configuration file does not exist,
197 useradd -d $dir -m -s $shell -u $uid $username
199 is the default. If the shellmachine-useradd configuration file exists but
202 cp -pr /etc/skel $dir; chown -R $uid.$gid $dir
204 is the default instead. Otherwise the contents of the file are treated as
205 a double-quoted perl string, with the following variables available:
206 $username, $uid, $gid, $dir, and $shell.
208 (TODOC: cyrus config file, L<FS::queue> and L<freeside-queued>)
216 local $SIG{HUP} = 'IGNORE';
217 local $SIG{INT} = 'IGNORE';
218 local $SIG{QUIT} = 'IGNORE';
219 local $SIG{TERM} = 'IGNORE';
220 local $SIG{TSTP} = 'IGNORE';
221 local $SIG{PIPE} = 'IGNORE';
223 my $oldAutoCommit = $FS::UID::AutoCommit;
224 local $FS::UID::AutoCommit = 0;
229 $error = $self->check;
230 return $error if $error;
232 return "Username ". $self->username. " in use"
233 if qsearchs( 'svc_acct', { 'username' => $self->username,
234 'domsvc' => $self->domsvc,
237 my $part_svc = qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
238 return "Unknown svcpart" unless $part_svc;
240 if $part_svc->part_svc_column('uid')->columnflag ne 'F'
241 && qsearchs( 'svc_acct', { 'uid' => $self->uid } )
242 && $self->username !~ /^(hyla)?fax$/
245 $error = $self->SUPER::insert;
247 $dbh->rollback if $oldAutoCommit;
251 my( $username, $uid, $gid, $dir, $shell ) = (
258 if ( $username && $uid && $dir && $shellmachine && ! $nossh_hack ) {
259 my $queue = new FS::queue { 'job' => 'FS::svc_acct::ssh' };
260 $error = $queue->insert("root\@$shellmachine", eval qq("$useradd") );
262 $dbh->rollback if $oldAutoCommit;
263 return "queueing job (transaction rolled back): $error";
267 if ( $cyrus_server ) {
268 my $queue = new FS::queue { 'job' => 'FS::svc_acct::cyrus_insert' };
269 $error = $queue->insert($self->username, $self->quota);
271 $dbh->rollback if $oldAutoCommit;
272 return "queueing job (transaction rolled back): $error";
275 if ( $icradius_dbh ) {
276 my $queue = new FS::queue { 'job' => 'FS::svc_acct::icradius_rc_insert' };
277 $error = $queue->insert( $self->username,
282 $dbh->rollback if $oldAutoCommit;
283 return "queueing job (transaction rolled back): $error";
287 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
292 my( $username, $quota ) = @_;
294 warn "cyrus_insert: starting for user $username, quota $quota\n";
296 warn "cyrus_insert: connecting to $cyrus_server\n";
297 my $client = Cyrus::IMAP::Admin->new($cyrus_server);
299 warn "cyrus_insert: authentication as $cyrus_admin_user\n";
300 $client->authenticate(
301 -user => $cyrus_admin_user,
302 -mechanism => "login",
303 -password => $cyrus_admin_pass
306 warn "cyrus_insert: creating user.$username\n";
307 my $rc = $client->create("user.$username");
308 my $error = $client->error;
309 die "cyrus_insert: error creating user.$username: $error" if $error;
311 warn "cyrus_insert: setacl user.$username, $username => all\n";
312 $rc = $client->setacl("user.$username", $username => 'all' );
313 $error = $client->error;
314 die "cyrus_insert: error setacl user.$username: $error" if $error;
317 warn "cyrus_insert: setquota user.$username, STORAGE => $quota\n";
318 $rc = $client->setquota("user.$username", 'STORAGE' => $quota );
319 $error = $client->error;
320 die "cyrus_insert: error setquota user.$username: $error" if $error;
326 sub icradius_rc_insert {
327 my( $username, $password, %radcheck ) = @_;
329 my $sth = $icradius_dbh->prepare(
330 "INSERT INTO radcheck ( id, UserName, Attribute, Value ) VALUES ( ".
331 join(", ", map { $icradius_dbh->quote($_) } (
338 $sth->execute or die "can't insert into radcheck table: ". $sth->errstr;
340 foreach my $attribute ( keys %radcheck ) {
341 my $sth = $icradius_dbh->prepare(
342 "INSERT INTO radcheck ( id, UserName, Attribute, Value ) VALUES ( ".
343 join(", ", map { $icradius_dbh->quote($_) } (
347 $radcheck{$attribute},
350 $sth->execute or die "can't insert into radcheck table: ". $sth->errstr;
358 Deletes this account from the database. If there is an error, returns the
359 error, otherwise returns false.
361 The corresponding FS::cust_svc record will be deleted as well.
363 If the configuration value (see L<FS::Conf>) shellmachine exists, the
364 command(s) specified in the shellmachine-userdel configuration file are
365 added to the job queue (see L<FS::queue> and L<freeside-queued>) to be executed
366 on shellmachine via ssh. This behavior can be surpressed by setting
367 $FS::svc_acct::nossh_hack true. If the shellmachine-userdel configuration
372 is the default. If the shellmachine-userdel configuration file exists but
377 is the default instead. Otherwise the contents of the file are treated as a
378 double-quoted perl string, with the following variables available:
381 (TODOC: cyrus config file)
388 if ( defined( $FS::Record::dbdef->table('svc_acct_sm') ) ) {
389 return "Can't delete an account which has (svc_acct_sm) mail aliases!"
390 if $self->uid && qsearch( 'svc_acct_sm', { 'domuid' => $self->uid } );
393 return "Can't delete an account which is a (svc_forward) source!"
394 if qsearch( 'svc_forward', { 'srcsvc' => $self->svcnum } );
396 return "Can't delete an account which is a (svc_forward) destination!"
397 if qsearch( 'svc_forward', { 'dstsvc' => $self->svcnum } );
399 return "Can't delete an account with (svc_www) web service!"
400 if qsearch( 'svc_www', { 'usersvc' => $self->usersvc } );
402 # what about records in session ?
404 local $SIG{HUP} = 'IGNORE';
405 local $SIG{INT} = 'IGNORE';
406 local $SIG{QUIT} = 'IGNORE';
407 local $SIG{TERM} = 'IGNORE';
408 local $SIG{TSTP} = 'IGNORE';
409 local $SIG{PIPE} = 'IGNORE';
411 my $oldAutoCommit = $FS::UID::AutoCommit;
412 local $FS::UID::AutoCommit = 0;
415 foreach my $cust_main_invoice (
416 qsearch( 'cust_main_invoice', { 'dest' => $self->svcnum } )
418 #next unless defined; #wtf is up with qsearch?
419 warn $cust_main_invoice;
420 next unless defined $cust_main_invoice;
421 my %hash = $cust_main_invoice->hash;
422 $hash{'dest'} = $self->email;
423 my $new = new FS::cust_main_invoice \%hash;
424 my $error = $new->replace($cust_main_invoice);
426 $dbh->rollback if $oldAutoCommit;
431 foreach my $svc_domain (
432 qsearch( 'svc_domain', { 'catchall' => $self->svcnum } )
434 my %hash = new FS::svc_domain->hash;
435 $hash{'catchall'} = '';
436 my $new = new FS::svc_domain \%hash;
437 my $error = $new->replace($svc_domain);
439 $dbh->rollback if $oldAutoCommit;
444 my $error = $self->SUPER::delete;
446 $dbh->rollback if $oldAutoCommit;
450 my( $username, $dir ) = (
454 if ( $username && $shellmachine && ! $nossh_hack ) {
455 my $queue = new FS::queue { 'job' => 'FS::svc_acct::ssh' };
456 $error = $queue->insert("root\@$shellmachine", eval qq("$userdel") );
458 $dbh->rollback if $oldAutoCommit;
459 return "queueing job (transaction rolled back): $error";
464 if ( $cyrus_server ) {
465 my $queue = new FS::queue { 'job' => 'FS::svc_acct::cyrus_delete' };
466 $error = $queue->insert($self->username);
468 $dbh->rollback if $oldAutoCommit;
469 return "queueing job (transaction rolled back): $error";
472 if ( $icradius_dbh ) {
473 my $queue = new FS::queue { 'job' => 'FS::svc_acct::icradius_rc_delete' };
474 $error = $queue->insert( $self->username );
476 $dbh->rollback if $oldAutoCommit;
477 return "queueing job (transaction rolled back): $error";
481 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
486 my $username = shift;
488 my $client = Cyrus::IMAP::Admin->new($cyrus_server);
489 $client->authenticate(
490 -user => $cyrus_admin_user,
491 -mechanism => "login",
492 -password => $cyrus_admin_pass
495 my $rc = $client->setacl("user.$username", $cyrus_admin_user => 'all' );
496 my $error = $client->error;
497 die $error if $error;
499 $rc = $client->delete("user.$username");
500 $error = $client->error;
501 die $error if $error;
506 sub icradius_rc_delete {
507 my $username = shift;
509 my $sth = $icradius_dbh->prepare(
510 'DELETE FROM radcheck WHERE UserName = ?'
512 $sth->execute($username)
513 or die "can't delete from radcheck table: ". $sth->errstr;
518 =item replace OLD_RECORD
520 Replaces OLD_RECORD with this one in the database. If there is an error,
521 returns the error, otherwise returns false.
523 If the configuration value (see L<FS::Conf>) shellmachine exists, and the
524 dir field has changed, the command(s) specified in the shellmachine-usermod
525 configuraiton file are added to the job queue (see L<FS::queue> and
526 L<freeside-queued>) to be executed on shellmachine via ssh. This behavior can
527 be surpressed by setting $FS::svc-acct::nossh_hack true. If the
528 shellmachine-userdel configuration file does not exist or is empty,
530 [ -d $old_dir ] && mv $old_dir $new_dir || (
534 find . -depth -print | cpio -pdm $new_dir;
536 chown -R $uid.$gid $new_dir;
540 is the default. This behaviour can be surpressed by setting
541 $FS::svc_acct::nossh_hack true.
546 my ( $new, $old ) = ( shift, shift );
549 return "Username in use"
550 if $old->username ne $new->username &&
551 qsearchs( 'svc_acct', { 'username' => $new->username,
552 'domsvc' => $new->domsvc,
555 return "Can't change uid!" if $old->uid != $new->uid;
557 return "can't change username using Cyrus"
558 if $cyrus_server && $old->username ne $new->username;
560 #change homdir when we change username
561 $new->setfield('dir', '') if $old->username ne $new->username;
563 local $SIG{HUP} = 'IGNORE';
564 local $SIG{INT} = 'IGNORE';
565 local $SIG{QUIT} = 'IGNORE';
566 local $SIG{TERM} = 'IGNORE';
567 local $SIG{TSTP} = 'IGNORE';
568 local $SIG{PIPE} = 'IGNORE';
570 my $oldAutoCommit = $FS::UID::AutoCommit;
571 local $FS::UID::AutoCommit = 0;
574 $error = $new->SUPER::replace($old);
576 $dbh->rollback if $oldAutoCommit;
577 return $error if $error;
580 my ( $old_dir, $new_dir, $uid, $gid ) = (
581 $old->getfield('dir'),
582 $new->getfield('dir'),
583 $new->getfield('uid'),
584 $new->getfield('gid'),
586 if ( $old_dir && $new_dir && $old_dir ne $new_dir && ! $nossh_hack ) {
587 my $queue = new FS::queue { 'job' => 'FS::svc_acct::ssh' };
588 $error = $queue->insert("root\@$shellmachine", eval qq("$usermod") );
590 $dbh->rollback if $oldAutoCommit;
591 return "queueing job (transaction rolled back): $error";
595 if ( $icradius_dbh ) {
596 my $queue = new FS::queue { 'job' => 'FS::svc_acct::icradius_rc_replace' };
597 $error = $queue->insert( $new->username,
601 $dbh->rollback if $oldAutoCommit;
602 return "queueing job (transaction rolled back): $error";
606 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
610 sub icradius_rc_replace {
611 my( $username, $new_password ) = @_;
613 my $sth = $icradius_dbh->prepare(
614 "UPDATE radcheck SET Value = ? WHERE UserName = ? and Attribute = ?"
616 $sth->execute($new_password, $username, 'Password' )
617 or die "can't update radcheck table: ". $sth->errstr;
624 Suspends this account by prefixing *SUSPENDED* to the password. If there is an
625 error, returns the error, otherwise returns false.
627 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
633 my %hash = $self->hash;
634 unless ( $hash{_password} =~ /^\*SUSPENDED\* / ) {
635 $hash{_password} = '*SUSPENDED* '.$hash{_password};
636 my $new = new FS::svc_acct ( \%hash );
637 $new->replace($self);
639 ''; #no error (already suspended)
645 Unsuspends this account by removing *SUSPENDED* from the password. If there is
646 an error, returns the error, otherwise returns false.
648 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
654 my %hash = $self->hash;
655 if ( $hash{_password} =~ /^\*SUSPENDED\* (.*)$/ ) {
656 $hash{_password} = $1;
657 my $new = new FS::svc_acct ( \%hash );
658 $new->replace($self);
660 ''; #no error (already unsuspended)
666 Just returns false (no error) for now.
668 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
672 Checks all fields to make sure this is a valid service. If there is an error,
673 returns the error, otherwise returns false. Called by the insert and replace
676 Sets any fixed values; see L<FS::part_svc>.
683 my($recref) = $self->hashref;
685 my $x = $self->setfixed;
686 return $x unless ref($x);
689 my $error = $self->ut_numbern('svcnum')
690 || $self->ut_number('domsvc')
692 return $error if $error;
694 my $ulen = $usernamemax || $self->dbdef_table->column('username')->length;
695 if ( $username_uppercase ) {
696 $recref->{username} =~ /^([a-z0-9_\-\.\&]{$usernamemin,$ulen})$/i
697 or return "Illegal username: ". $recref->{username};
698 $recref->{username} = $1;
700 $recref->{username} =~ /^([a-z0-9_\-\.\&]{$usernamemin,$ulen})$/
701 or return "Illegal username: ". $recref->{username};
702 $recref->{username} = $1;
705 if ( $username_letterfirst ) {
706 $recref->{username} =~ /^[a-z]/ or return "Illegal username";
707 } elsif ( $username_letter ) {
708 $recref->{username} =~ /[a-z]/ or return "Illegal username";
710 if ( $username_noperiod ) {
711 $recref->{username} =~ /\./ and return "Illegal username";
713 unless ( $username_ampersand ) {
714 $recref->{username} =~ /\&/ and return "Illegal username";
717 $recref->{popnum} =~ /^(\d*)$/ or return "Illegal popnum: ".$recref->{popnum};
718 $recref->{popnum} = $1;
719 return "Unknown popnum" unless
720 ! $recref->{popnum} ||
721 qsearchs('svc_acct_pop',{'popnum'=> $recref->{popnum} } );
723 unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
725 $recref->{uid} =~ /^(\d*)$/ or return "Illegal uid";
726 $recref->{uid} = $1 eq '' ? $self->unique('uid') : $1;
728 $recref->{gid} =~ /^(\d*)$/ or return "Illegal gid";
729 $recref->{gid} = $1 eq '' ? $recref->{uid} : $1;
730 #not all systems use gid=uid
731 #you can set a fixed gid in part_svc
733 return "Only root can have uid 0"
734 if $recref->{uid} == 0 && $recref->{username} ne 'root';
736 # $error = $self->ut_textn('finger');
737 # return $error if $error;
738 $self->getfield('finger') =~
739 /^([\w \t\!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\*\<\>]*)$/
740 or return "Illegal finger: ". $self->getfield('finger');
741 $self->setfield('finger', $1);
743 $recref->{dir} =~ /^([\/\w\-\.\&]*)$/
744 or return "Illegal directory";
746 return "Illegal directory"
747 if $recref->{dir} =~ /(^|\/)\.+(\/|$)/; #no .. component
748 return "Illegal directory"
749 if $recref->{dir} =~ /\&/ && ! $username_ampersand;
750 unless ( $recref->{dir} ) {
751 $recref->{dir} = $dir_prefix . '/';
752 if ( $dirhash > 0 ) {
753 for my $h ( 1 .. $dirhash ) {
754 $recref->{dir} .= substr($recref->{username}, $h-1, 1). '/';
756 } elsif ( $dirhash < 0 ) {
757 for my $h ( reverse $dirhash .. -1 ) {
758 $recref->{dir} .= substr($recref->{username}, $h, 1). '/';
761 $recref->{dir} .= $recref->{username};
765 unless ( $recref->{username} eq 'sync' ) {
766 if ( grep $_ eq $recref->{shell}, @shells ) {
767 $recref->{shell} = (grep $_ eq $recref->{shell}, @shells)[0];
769 return "Illegal shell \`". $self->shell. "\'; ".
770 $conf->dir. "/shells contains: @shells";
773 $recref->{shell} = '/bin/sync';
776 $recref->{quota} =~ /^(\d*)$/ or return "Illegal quota (unimplemented)";
777 $recref->{quota} = $1;
780 $recref->{gid} ne '' ?
781 return "Can't have gid without uid" : ( $recref->{gid}='' );
782 $recref->{finger} ne '' ?
783 return "Can't have finger-name without uid" : ( $recref->{finger}='' );
784 $recref->{dir} ne '' ?
785 return "Can't have directory without uid" : ( $recref->{dir}='' );
786 $recref->{shell} ne '' ?
787 return "Can't have shell without uid" : ( $recref->{shell}='' );
788 $recref->{quota} ne '' ?
789 return "Can't have quota without uid" : ( $recref->{quota}='' );
792 unless ( $part_svc->part_svc_column('slipip')->columnflag eq 'F' ) {
793 unless ( $recref->{slipip} eq '0e0' ) {
794 $recref->{slipip} =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/
795 or return "Illegal slipip". $self->slipip;
796 $recref->{slipip} = $1;
798 $recref->{slipip} = '0e0';
803 #arbitrary RADIUS stuff; allow ut_textn for now
804 foreach ( grep /^radius_/, fields('svc_acct') ) {
808 #generate a password if it is blank
809 $recref->{_password} = join('',map($pw_set[ int(rand $#pw_set) ], (0..7) ) )
810 unless ( $recref->{_password} );
812 #if ( $recref->{_password} =~ /^((\*SUSPENDED\* )?)([^\t\n]{4,16})$/ ) {
813 if ( $recref->{_password} =~ /^((\*SUSPENDED\* )?)([^\t\n]{$passwordmin,$passwordmax})$/ ) {
814 $recref->{_password} = $1.$3;
815 #uncomment this to encrypt password immediately upon entry, or run
816 #bin/crypt_pw in cron to give new users a window during which their
817 #password is available to techs, for faxing, etc. (also be aware of
819 #$recref->{password} = $1.
820 # crypt($3,$saltset[int(rand(64))].$saltset[int(rand(64))]
822 } elsif ( $recref->{_password} =~ /^((\*SUSPENDED\* )?)([\w\.\/\$]{13,34})$/ ) {
823 $recref->{_password} = $1.$3;
824 } elsif ( $recref->{_password} eq '*' ) {
825 $recref->{_password} = '*';
826 } elsif ( $recref->{_password} eq '!!' ) {
827 $recref->{_password} = '!!';
829 #return "Illegal password";
830 return "Illegal password: ". $recref->{_password};
838 Depriciated, use radius_reply instead.
843 carp "FS::svc_acct::radius depriciated, use radius_reply";
849 Returns key/value pairs, suitable for assigning to a hash, for any RADIUS
850 reply attributes of this record.
852 Note that this is now the preferred method for reading RADIUS attributes -
853 accessing the columns directly is discouraged, as the column names are
854 expected to change in the future.
862 my($column, $attrib) = ($1, $2);
863 #$attrib =~ s/_/\-/g;
864 ( $FS::raddb::attrib{lc($attrib)}, $self->getfield($column) );
865 } grep { /^radius_/ && $self->getfield($_) } fields( $self->table );
870 Returns key/value pairs, suitable for assigning to a hash, for any RADIUS
871 check attributes of this record.
873 Accessing RADIUS attributes directly is not supported and will break in the
882 my($column, $attrib) = ($1, $2);
883 #$attrib =~ s/_/\-/g;
884 ( $FS::raddb::attrib{lc($attrib)}, $self->getfield($column) );
885 } grep { /^rc_/ && $self->getfield($_) } fields( $self->table );
890 Returns the domain associated with this account.
896 if ( $self->domsvc ) {
897 #$self->svc_domain->domain;
898 my $svc_domain = $self->svc_domain
899 or die "no svc_domain.svcnum for svc_acct.domsvc ". $self->domsvc;
902 $mydomain or die "svc_acct.domsvc is null and no legacy domain config file";
908 Returns the FS::svc_domain record for this account's domain (see
917 : qsearchs( 'svc_domain', { 'svcnum' => $self->domsvc } );
922 Returns an email address associated with the account.
928 $self->username. '@'. $self->domain;
936 my ( $host, @cmd_and_args ) = @_;
939 my $reader = IO::File->new();
940 my $writer = IO::File->new();
941 my $error = IO::File->new();
943 &Net::SSH::sshopen3( $host, $reader, $writer, $error, @cmd_and_args) or die $!;
946 my $output_stream = <$writer>;
947 my $error_stream = <$error>;
948 if ( length $error_stream ) {
949 #warn "[FS::svc_acct::ssh] STDERR $error_stream";
950 die "[FS::svc_acct::ssh] STDERR $error_stream";
952 if ( length $output_stream ) {
953 warn "[FS::svc_acct::ssh] STDOUT $output_stream";
956 # &Net::SSH::ssh(@args,">>/usr/local/etc/freeside/sshoutput 2>&1");
963 $Id: svc_acct.pm,v 1.55 2001-11-05 17:00:41 jeff Exp $
967 The bits which ssh should fork before doing so (or maybe queue jobs for a
970 The $recref stuff in sub check should be cleaned up.
972 The suspend, unsuspend and cancel methods update the database, but not the
973 current object. This is probably a bug as it's unexpected and
978 L<FS::svc_Common>, L<FS::Record>, L<FS::Conf>, L<FS::cust_svc>,
979 L<FS::part_svc>, L<FS::cust_pkg>, L<FS::queue>, L<freeside-queued>),
980 L<Net::SSH>, L<ssh>, L<FS::svc_acct_pop>,
981 schema.html from the base documentation.