also untaint pid
[freeside.git] / fs_signup / fs_signup_server
index ebf424c..5dfa0e8 100755 (executable)
@@ -4,6 +4,7 @@
 #
 
 use strict;
+use vars qw($pid);
 use IO::Handle;
 use Storable qw(nstore_fd fd_retrieve);
 use Tie::RefHash;
@@ -13,7 +14,7 @@ use FS::Conf;
 use FS::Record qw( qsearch qsearchs );
 use FS::cust_main_county;
 use FS::cust_main;
-use FS::msgcat qw(gettext);
+use FS::Msgcat qw(gettext);
 
 use vars qw( $opt $Debug );
 
@@ -39,13 +40,20 @@ my $refnum = shift or die &usage;
 #causing trouble for some folks
 #$SIG{CHLD} = sub { wait() };
 
+$SIG{HUP} = \&killssh;
+$SIG{INT} = \&killssh;
+$SIG{QUIT} = \&killssh;
+$SIG{TERM} = \&killssh;
+$SIG{PIPE} = \&killssh;
+sub killssh { kill 'TERM', $pid if $pid; exit; };
+
 my($fs_signupd)="/usr/local/sbin/fs_signupd";
 
 while (1) {
   my($reader,$writer)=(new IO::Handle, new IO::Handle);
   #seems to be broken - calling ->flush explicitly# $writer->autoflush(1);
   warn "[fs_signup_server] Connecting to $machine...\n" if $Debug;
-  sshopen2($machine,$reader,$writer,$fs_signupd);
+  $pid = sshopen2($machine,$reader,$writer,$fs_signupd);
 
   my @pops = qsearch('svc_acct_pop',{} );
   my $init_data = {
@@ -105,7 +113,7 @@ while (1) {
     # common that are still here and library them.
     my $cust_main = new FS::cust_main ( {
       #'custnum'          => '',
-      'agentnum'         => $agentnum,
+      'agentnum'         => $signup-data->{agentnum} || $agentnum,
       'refnum'           => $refnum,
 
       map { $_ => $signup_data->{$_} } qw(