5 # This is run REMOTELY over ssh by fs_session_server
11 use vars qw( $Debug );
15 my $fs_sessiond_socket = "/usr/local/freeside/fs_sessiond_socket";
17 $ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin';
18 $ENV{'SHELL'} = '/bin/sh';
19 $ENV{'IFS'} = " \t\n";
22 $ENV{'BASH_ENV'} = '';
26 my $me = "[fs_sessiond]";
28 warn "$me starting\n" if $Debug;
29 #nothing to read from server
31 warn "$me creating $fs_sessiond_socket\n" if $Debug;
32 my $uaddr = sockaddr_un($fs_sessiond_socket);
33 my $proto = getprotobyname('tcp');
34 socket(Server,PF_UNIX,SOCK_STREAM,0) or die "socket: $!";
35 unlink($fs_sessiond_socket);
36 bind(Server, $uaddr) or die "bind: $!";
37 listen(Server,SOMAXCONN) or die "listen: $!";
39 warn "$me entering main loop\n" if $Debug;
41 for ( ; $paddr = accept(Client,Server); close Client) {
43 chomp( my $command = <Client> );
45 if ( $command eq 'login' || $command eq 'logout' || $command eq 'portnum' ) {
46 warn "$me reading data from local client\n" if $Debug;
49 push @data, scalar(<Client>) until $dos++ == 99 || $data[$#data] eq "END\n";
51 warn "$me WARNING: DoS attempt!"
53 warn "$me sending data to remote server\n" if $Debug;
54 print "$command\n", @data;
55 warn "$me reading result from remote server\n" if $Debug;
57 warn "$me sending error to local client\n" if $Debug;
61 warn "$me WARNING: unexpected command from client: $command";