diff options
author | ivan <ivan> | 2002-04-06 20:37:38 +0000 |
---|---|---|
committer | ivan <ivan> | 2002-04-06 20:37:38 +0000 |
commit | 8fc4118f1f055195d280b3250b39a3b5fcdf13dc (patch) | |
tree | 09f1c079662ae602829cfce585d9396658689206 /fs_signup/FS-SignupClient | |
parent | 195652229909566ccb3a6ae249d8fa26f25da55a (diff) |
big signup server cleanups. uses Storable for network protocol now.
- makes Bugs 384 & 385 easier
- closes: Bug#382
Diffstat (limited to 'fs_signup/FS-SignupClient')
-rw-r--r-- | fs_signup/FS-SignupClient/Makefile.PL | 1 | ||||
-rw-r--r-- | fs_signup/FS-SignupClient/SignupClient.pm | 58 | ||||
-rwxr-xr-x | fs_signup/FS-SignupClient/cgi/signup.cgi | 77 | ||||
-rwxr-xr-x | fs_signup/FS-SignupClient/cgi/signup.html | 5 | ||||
-rwxr-xr-x | fs_signup/FS-SignupClient/fs_signupd | 99 | ||||
-rw-r--r-- | fs_signup/FS-SignupClient/test.pl | 2 |
6 files changed, 83 insertions, 159 deletions
diff --git a/fs_signup/FS-SignupClient/Makefile.PL b/fs_signup/FS-SignupClient/Makefile.PL index 859d757c3..208e8507a 100644 --- a/fs_signup/FS-SignupClient/Makefile.PL +++ b/fs_signup/FS-SignupClient/Makefile.PL @@ -6,5 +6,6 @@ WriteMakefile( 'VERSION_FROM' => 'SignupClient.pm', # finds $VERSION 'EXE_FILES' => [ 'fs_signupd' ], 'INSTALLSCRIPT' => '/usr/local/sbin', + 'INSTALLSITEBIN' => '/usr/local/sbin', 'PERM_RWX' => '750', ); diff --git a/fs_signup/FS-SignupClient/SignupClient.pm b/fs_signup/FS-SignupClient/SignupClient.pm index bd917dae7..3933703ae 100644 --- a/fs_signup/FS-SignupClient/SignupClient.pm +++ b/fs_signup/FS-SignupClient/SignupClient.pm @@ -6,6 +6,7 @@ use Exporter; use Socket; use FileHandle; use IO::Handle; +use Storable qw(nstore_fd fd_retrieve); $VERSION = '0.02'; @@ -58,6 +59,7 @@ FS::SignupClient - Freeside signup client API 'pkgpart' => $pkgpart, 'username' => $username, '_password' => $password, + 'sec_phrase' => $sec_phrase, 'popnum' => $popnum, } ); @@ -104,51 +106,12 @@ sub signup_info { print SOCK "signup_info\n"; SOCK->flush; - chop ( my $n_cust_main_county = <SOCK> ); - my @cust_main_county = map { - chop ( my $taxnum = <SOCK> ); - chop ( my $state = <SOCK> ); - chop ( my $county = <SOCK> ); - chop ( my $country = <SOCK> ); - { - 'taxnum' => $taxnum, - 'state' => $state, - 'county' => $county, - 'country' => $country, - }; - } 1 .. $n_cust_main_county; - - chop ( my $n_part_pkg = <SOCK> ); - my @part_pkg = map { - chop ( my $pkgpart = <SOCK> ); - chop ( my $pkg = <SOCK> ); - { - 'pkgpart' => $pkgpart, - 'pkg' => $pkg, - }; - } 1 .. $n_part_pkg; - - chop ( my $n_svc_acct_pop = <SOCK> ); - my @svc_acct_pop = map { - chop ( my $popnum = <SOCK> ); - chop ( my $city = <SOCK> ); - chop ( my $state = <SOCK> ); - chop ( my $ac = <SOCK> ); - chop ( my $exch = <SOCK> ); - chop ( my $loc = <SOCK> ); - { - 'popnum' => $popnum, - 'city' => $city, - 'state' => $state, - 'ac' => $ac, - 'exch' => $exch, - 'loc' => $loc, - }; - } 1 .. $n_svc_acct_pop; - + my $init_data = fd_retrieve(\*SOCK); close SOCK; - \@cust_main_county, \@part_pkg, \@svc_acct_pop; + (map { $init_data->{$_} } qw( cust_main_county part_pkg svc_acct_pop ) ), + $init_data; + } =item new_customer HASHREF @@ -188,6 +151,8 @@ sub new_customer { my $hashref = shift; #things that aren't necessary in base class, but are for signup server +# return "Passwords don't match" +# if $hashref->{'_password'} ne $hashref->{'_password2'} return "Empty password" unless $hashref->{'_password'}; return "No POP selected" unless $hashref->{'popnum'}; @@ -195,11 +160,14 @@ sub new_customer { connect(SOCK, sockaddr_un($fs_signupd_socket)) or die "connect: $!"; print SOCK "new_customer\n"; - print SOCK join("\n", map { $hashref->{$_} } qw( + my $signup_data = { map { $_ => $hashref->{$_} } qw( first last ss company address1 address2 city county state zip country daytime night fax payby payinfo paydate payname invoicing_list referral_custnum pkgpart username _password popnum - ) ), "\n"; + ) }; + + # + nstore_fd($signup_data, \*SOCK) or die "can't send customer signup: $!"; SOCK->flush; chop( my $error = <SOCK> ); diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index b236e6fb2..d44782f9c 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,13 +1,13 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.15 2001-09-27 21:37:57 ivan Exp $ +# $Id: signup.cgi,v 1.16 2002-04-06 20:37:38 ivan Exp $ use strict; use vars qw( @payby $cgi $locales $packages $pops $error $last $first $ss $company $address1 $address2 $city $state $county $country $zip $daytime $night $fax $invoicing_list $payby $payinfo $paydate $payname $referral_custnum - $pkgpart $username $password $popnum + $pkgpart $username $password $password2 $popnum $ieak_file $ieak_template $cck_file $cck_template $signup_html $signup_template $success_html $success_template $ac $exch $loc @@ -115,37 +115,50 @@ if ( defined $cgi->param('magic') ) { $invoicing_list = 'POST'; } - $error = new_customer ( { - 'last' => $last = $cgi->param('last'), - 'first' => $first = $cgi->param('first'), - 'ss' => $ss = $cgi->param('ss'), - 'company' => $company = $cgi->param('company'), - 'address1' => $address1 = $cgi->param('address1'), - 'address2' => $address2 = $cgi->param('address2'), - 'city' => $city = $cgi->param('city'), - 'county' => $county, - 'state' => $state, - 'zip' => $zip = $cgi->param('zip'), - 'country' => $country, - 'daytime' => $daytime = $cgi->param('daytime'), - 'night' => $night = $cgi->param('night'), - 'fax' => $fax = $cgi->param('fax'), - 'payby' => $payby, - 'payinfo' => $payinfo, - 'paydate' => $paydate, - 'payname' => $payname, - 'invoicing_list' => $invoicing_list, - 'referral_custnum' => $referral_custnum = $cgi->param('ref'), - 'pkgpart' => $pkgpart = $cgi->param('pkgpart'), - 'username' => $username = $cgi->param('username'), - '_password' => $password = $cgi->param('_password'), - 'popnum' => $popnum = $cgi->param('popnum'), - } ); + $error = ''; + + if ( $cgi->param('_password') ne $cgi->param('_password2') ) { + $error = "Passwords don't match"; + $password = ''; + $password2 = ''; + } else { + $password2 = $cgi->param('_password2'); + + $error = new_customer ( { + 'last' => $last = $cgi->param('last'), + 'first' => $first = $cgi->param('first'), + 'ss' => $ss = $cgi->param('ss'), + 'company' => $company = $cgi->param('company'), + 'address1' => $address1 = $cgi->param('address1'), + 'address2' => $address2 = $cgi->param('address2'), + 'city' => $city = $cgi->param('city'), + 'county' => $county, + 'state' => $state, + 'zip' => $zip = $cgi->param('zip'), + 'country' => $country, + 'daytime' => $daytime = $cgi->param('daytime'), + 'night' => $night = $cgi->param('night'), + 'fax' => $fax = $cgi->param('fax'), + 'payby' => $payby, + 'payinfo' => $payinfo, + 'paydate' => $paydate, + 'payname' => $payname, + 'invoicing_list' => $invoicing_list, + 'referral_custnum' => $referral_custnum = $cgi->param('ref'), + 'pkgpart' => $pkgpart = $cgi->param('pkgpart'), + 'username' => $username = $cgi->param('username'), + '_password' => $password = $cgi->param('_password'), + 'popnum' => $popnum = $cgi->param('popnum'), + } ); + + } + if ( $error ) { print_form(); } else { print_okay(); } + } else { die "unrecognized magic: ". $cgi->param('magic'); } @@ -173,6 +186,7 @@ if ( defined $cgi->param('magic') ) { $pkgpart = ''; $username = ''; $password = ''; + $password2 = ''; $popnum = ''; $referral_custnum = $cgi->param('ref') || ''; print_form; @@ -463,10 +477,15 @@ Contact Information </TR> <TR> <TD ALIGN="right">Password</TD> - <TD><INPUT TYPE="text" NAME="_password" VALUE="<%= $password %>"> + <TD><INPUT TYPE="password" NAME="_password" VALUE="<%= $password %>"> (blank to generate)</TD> </TR> <TR> + <TD ALIGN="right">Re-enter Password</TD> + <TD><INPUT TYPE="password" NAME="_password2" VALUE="<%= $password2 %>"> + </TD> +</TR> +<TR> <TD ALIGN="right">Access number</TD> <TD><%= popselector($popnum) %></TD> </TR> diff --git a/fs_signup/FS-SignupClient/cgi/signup.html b/fs_signup/FS-SignupClient/cgi/signup.html index 0f4742d20..909d1fe5b 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.html +++ b/fs_signup/FS-SignupClient/cgi/signup.html @@ -130,6 +130,11 @@ Contact Information (blank to generate)</TD> </TR> <TR> + <TD ALIGN="right">Re-enter Password</TD> + <TD><INPUT TYPE="password" NAME="_password2" VALUE="<%= $password2 %>"> + </TD> +</TR> +<TR> <TD ALIGN="right">Access number</TD> <TD><%= popselector($popnum) %></TD> </TR> diff --git a/fs_signup/FS-SignupClient/fs_signupd b/fs_signup/FS-SignupClient/fs_signupd index 8b3cdde53..e764f32b7 100755 --- a/fs_signup/FS-SignupClient/fs_signupd +++ b/fs_signup/FS-SignupClient/fs_signupd @@ -3,14 +3,15 @@ # fs_signupd # # This is run REMOTELY over ssh by fs_signup_server. -# use strict; use Socket; +use Storable qw(nstore_fd fd_retrieve); +use IO::Handle; use vars qw( $Debug ); -$Debug = 0; +$Debug = 1; my($fs_signupd_socket)="/usr/local/freeside/fs_signupd_socket"; @@ -23,50 +24,8 @@ $ENV{'BASH_ENV'} = ''; $|=1; -warn "[fs_signupd] Reading locales...\n" if $Debug; -chomp( my $n_cust_main_county = <STDIN> ); -my @cust_main_county = map { - chomp( my $taxnum = <STDIN> ); - chomp( my $state = <STDIN> ); - chomp( my $county = <STDIN> ); - chomp( my $country = <STDIN> ); - { - 'taxnum' => $taxnum, - 'state' => $state, - 'county' => $county, - 'country' => $country, - }; -} ( 1 .. $n_cust_main_county ); - -warn "[fs_signupd] Reading package definitions...\n" if $Debug; -chomp( my $n_part_pkg = <STDIN> ); -my @part_pkg = map { - chomp( my $pkgpart = <STDIN> ); - chomp( my $pkg = <STDIN> ); - { - 'pkgpart' => $pkgpart, - 'pkg' => $pkg, - }; -} ( 1 .. $n_part_pkg ); - -warn "[fs_signupd] Reading POPs...\n" if $Debug; -chomp( my $n_svc_acct_pop = <STDIN> ); -my @svc_acct_pop = map { - chomp( my $popnum = <STDIN> ); - chomp( my $city = <STDIN> ); - chomp( my $state = <STDIN> ); - chomp( my $ac = <STDIN> ); - chomp( my $exch = <STDIN> ); - chomp( my $loc = <STDIN> ); - { - 'popnum' => $popnum, - 'city' => $city, - 'state' => $state, - 'ac' => $ac, - 'exch' => $exch, - 'loc' => $loc, - }; -} ( 1 .. $n_svc_acct_pop ); +warn "[fs_signupd] Reading init data...\n" if $Debug; +my $init_data = fd_retrieve(\*STDIN); warn "[fs_signupd] Creating $fs_signupd_socket\n" if $Debug; my $uaddr = sockaddr_un($fs_signupd_socket); @@ -83,56 +42,28 @@ for ( ; $paddr = accept(Client,Server); close Client) { chop( my $command = <Client> ); if ( $command eq "signup_info" ) { + warn "[fs_signupd] sending signup info...\n" if $Debug; - print Client join("\n", $n_cust_main_county, - map { - $_->{taxnum}, - $_->{state}, - $_->{county}, - $_->{country}, - } @cust_main_county - ), "\n"; - - print Client join("\n", $n_part_pkg, - map { - $_->{pkgpart}, - $_->{pkg}, - } @part_pkg - ), "\n"; - - print Client join("\n", $n_svc_acct_pop, - map { - $_->{popnum}, - $_->{city}, - $_->{state}, - $_->{ac}, - $_->{exch}, - $_->{loc}, - } @svc_acct_pop - ), "\n"; + nstore_fd($init_data, \*Client) or die "can't send init data: $!"; + Client->flush; } elsif ( $command eq "new_customer" ) { + + #inefficient... + warn "[fs_signupd] reading customer signup...\n" if $Debug; - my( - $first, $last, $ss, $company, $address1, $address2, $city, $county, - $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, - $paydate, $payname, $invoicing_list, $referral_custnum, - $pkgpart, $username, $password, $popnum, - ) = map { scalar(<Client>) } ( 1 .. 24 ); + my $signup_data = fd_retrieve(\*Client); warn "[fs_signupd] sending customer data to remote server...\n" if $Debug; - print - $first, $last, $ss, $company, $address1, $address2, $city, $county, - $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, - $paydate, $payname, $invoicing_list, $referral_custnum, - $pkgpart, $username, $password, $popnum, - ; + nstore_fd($signup_data, \*STDOUT) or die "can't send signup data: $!"; + STDOUT->flush; warn "[fs_signupd] reading error from remote server...\n" if $Debug; my $error = <STDIN>; warn "[fs_signupd] sending error to local client...\n" if $Debug; print Client $error; + Client->flush; } else { die "unexpected command from client: $command"; diff --git a/fs_signup/FS-SignupClient/test.pl b/fs_signup/FS-SignupClient/test.pl index 690f5840e..b6136954d 100644 --- a/fs_signup/FS-SignupClient/test.pl +++ b/fs_signup/FS-SignupClient/test.pl @@ -8,7 +8,7 @@ BEGIN { $| = 1; print "1..1\n"; } END {print "not ok 1\n" unless $loaded;} -use FS::SignupClient; +#blah#use FS::SignupClient; $loaded = 1; print "ok 1\n"; |