8 use FS::SSH qw(sshopen2);
9 use FS::UID qw(adminsuidsetup);
10 use FS::Record qw(qsearchs);
11 use FS::cust_main_county;
16 my $user = shift or die &usage;
19 my $machine = shift or die &usage;
21 my $agentnum = shift or die &usage;
22 my $agent = qsearchs( 'agent', { 'agentnum' => $agentnum } ) or die &usage;
23 #my %part_pkg = %{ $agent->pkgpart_hashref };
25 my $refnum = shift or die &usage;
27 $SIG{CHLD} = sub { wait() };
29 my($fs_signupd)="/usr/local/sbin/fs_signupd";
32 my($reader,$writer)=(new IO::Handle, new IO::Handle);
33 $writer->autoflush(1);
34 sshopen2($shellmachine,$reader,$writer,$fs_signupd);
36 #send fs_signupd state/county/country
37 @cust_main_county = qsearch('cust_main_county', {} );
38 print $writer join("\n",
39 scalar(@cust_main_county),
48 #send fs_signupd package definitions
55 my( $first, $last, $ss, $company, $address1, $address2, $city, $county,
56 $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo,
57 $paydate, $payname, $username, $password, $popnum,
62 my($username,$old_password,$new_password,$new_gecos,$new_shell);
63 defined($username=<$reader>) or last;
64 defined($old_password=<$reader>) or last;
65 defined($new_password=<$reader>) or last;
66 defined($new_gecos=<$reader>) or last;
67 defined($new_shell=<$reader>) or last;
75 #need to try both $old_password and encrypted $old_password
76 #maybe the crypt function in svc_acct.export needs to be a library?
77 my $salt = substr($old_password,0,2);
78 my $cold_password = crypt($old_password,$salt);
79 $svc_acct=qsearchs('svc_acct',{'username'=>$username,
80 '_password'=>$old_password,
82 || qsearchs('svc_acct',{'username'=>$username,
83 '_password'=>$cold_password,
85 unless ( $svc_acct ) { print $writer "Incorrect password.\n"; next; }
87 my(%hash)=$svc_acct->hash;
88 my($new_svc_acct) = new FS::svc_acct ( \%hash );
89 $new_svc_acct->setfield('_password',$new_password)
90 if $new_password && $new_password ne $old_password;
91 $new_svc_acct->setfield('finger',$new_gecos) if $new_gecos;
92 $new_svc_acct->setfield('shell',$new_shell) if $new_shell;
93 my($error)=$new_svc_acct->replace($svc_acct);
94 print $writer $error,"\n";
99 warn "Connection to $shellmachine lost! Reconnecting...\n";
103 die "Usage:\n\n fs_signup_server user machine agentnum refnum\n";