1 package FS::part_export::shellcommands;
3 use vars qw(@ISA @saltset);
6 @ISA = qw(FS::part_export);
8 @saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' );
10 sub rebless { shift; }
14 $self->_export_command('useradd', @_);
19 $self->_export_command('userdel', @_);
23 my ( $self, $action, $svc_acct) = (shift, shift, shift);
24 my $command = $self->option($action);
25 my $stdin = $self->option($action."_stdin");
28 ${$_} = $svc_acct->getfield($_) foreach $svc_acct->fields;
30 $crypt_password = ''; #surpress "used only once" warnings
31 $crypt_password = crypt( $svc_acct->_password,
32 $saltset[int(rand(64))].$saltset[int(rand(64))] );
33 $self->shellcommands_queue( $svc_acct->svcnum,
34 user => $self->option('user')||'root',
35 host => $self->machine,
36 command => eval(qq("$command")),
37 stdin_string => eval(qq("$stdin")),
42 my($self, $new, $old ) = (shift, shift, shift);
43 my $command = $self->option('usermod');
44 my $stdin = $self->option('usermod_stdin');
47 ${"old_$_"} = $old->getfield($_) foreach $old->fields;
48 ${"new_$_"} = $new->getfield($_) foreach $new->fields;
50 $new_crypt_password = ''; #surpress "used only once" warnings
51 $new_crypt_password = crypt( $new->_password,
52 $saltset[int(rand(64))].$saltset[int(rand(64))]);
53 $self->shellcommands_queue( $new->svcnum,
54 user => $self->option('user')||'root',
55 host => $self->machine,
56 command => eval(qq("$command")),
57 stdin_string => eval(qq("$stdin")),
61 #a good idea to queue anything that could fail or take any time
62 sub shellcommands_queue {
63 my( $self, $svcnum ) = (shift, shift);
64 my $queue = new FS::queue {
66 'job' => "FS::part_export::shellcommands::ssh_cmd",
71 sub ssh_cmd { #subroutine, not method
73 &Net::SSH::ssh_cmd( { @_ } );
76 #sub shellcommands_insert { #subroutine, not method
78 #sub shellcommands_replace { #subroutine, not method
80 #sub shellcommands_delete { #subroutine, not method