summaryrefslogtreecommitdiff
path: root/fs_sesmon
diff options
context:
space:
mode:
authorivan <ivan>2000-12-03 20:25:20 +0000
committerivan <ivan>2000-12-03 20:25:20 +0000
commitb90f8cdac9371c219a72dda16f8deecc7c44fc28 (patch)
tree566f55939a488f29e5a79821aef6102669afe721 /fs_sesmon
parent3a95cc316da367ffd248ba29ac594f3efbc9db61 (diff)
session monitor updates
Diffstat (limited to 'fs_sesmon')
-rw-r--r--fs_sesmon/FS-SessionClient/MANIFEST4
-rw-r--r--fs_sesmon/FS-SessionClient/Makefile.PL2
-rw-r--r--fs_sesmon/FS-SessionClient/SessionClient.pm22
-rw-r--r--fs_sesmon/FS-SessionClient/bin/freeside-login2
-rw-r--r--fs_sesmon/FS-SessionClient/bin/freeside-logout (renamed from fs_sesmon/FS-SessionClient/bin/freeside-logoff)7
-rw-r--r--fs_sesmon/FS-SessionClient/fs_sessiond10
-rw-r--r--fs_sesmon/FS-SessionClient/test.pl3
-rw-r--r--fs_sesmon/fs_session_server42
8 files changed, 49 insertions, 43 deletions
diff --git a/fs_sesmon/FS-SessionClient/MANIFEST b/fs_sesmon/FS-SessionClient/MANIFEST
index 6da7b22e9..9da279a87 100644
--- a/fs_sesmon/FS-SessionClient/MANIFEST
+++ b/fs_sesmon/FS-SessionClient/MANIFEST
@@ -6,6 +6,6 @@ SessionClient.pm
test.pl
fs_sessiond
cgi/logon.cgi
-cgi/logoff.cgi
+cgi/logout.cgi
bin/freeside-login
-bin/freeside-logoff
+bin/freeside-logout
diff --git a/fs_sesmon/FS-SessionClient/Makefile.PL b/fs_sesmon/FS-SessionClient/Makefile.PL
index 1f598474a..137b6b8bd 100644
--- a/fs_sesmon/FS-SessionClient/Makefile.PL
+++ b/fs_sesmon/FS-SessionClient/Makefile.PL
@@ -4,7 +4,7 @@ use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'FS::SessionClient',
'VERSION_FROM' => 'SessionClient.pm', # finds $VERSION
- 'EXE_FILES' => [ qw(fs_sessiond freeside-login freeside-logoff) ],
+ 'EXE_FILES' => [ qw(fs_sessiond bin/freeside-login bin/freeside-logout) ],
'INSTALLSCRIPT' => '/usr/local/sbin',
'PERM_RWX' => '750',
);
diff --git a/fs_sesmon/FS-SessionClient/SessionClient.pm b/fs_sesmon/FS-SessionClient/SessionClient.pm
index 97332cb26..8a0ff705f 100644
--- a/fs_sesmon/FS-SessionClient/SessionClient.pm
+++ b/fs_sesmon/FS-SessionClient/SessionClient.pm
@@ -10,7 +10,7 @@ use IO::Handle;
$VERSION = '0.01';
@ISA = qw( Exporter );
-@EXPORT_OK = qw( login logoff portnum );
+@EXPORT_OK = qw( login logout portnum );
$fs_sessiond_socket = "/usr/local/freeside/fs_sessiond_socket";
@@ -30,7 +30,7 @@ FS::SessionClient - Freeside session client API
=head1 SYNOPSIS
- use FS::SessionClient qw( login portnum logoff );
+ use FS::SessionClient qw( login portnum logout );
$error = login ( {
'username' => $username,
@@ -43,10 +43,10 @@ FS::SessionClient - Freeside session client API
$portnum = portnum( { 'nasnum' => $nasnum, 'nasport' => $nasport } )
or die "unknown nasnum/nasport";
- $error = logoff ( {
+ $error = logout ( {
'username' => $username,
'password' => $password,
- 'logoff' => $timestamp,
+ 'logout' => $timestamp,
'portnum' => $portnum,
} );
@@ -73,13 +73,13 @@ Returns a scalar error message, or the empty string for success.
=item portnum
HASHREF should contain a single key: ip, or the two keys: nasnum and nasport.
-Returns a portnum suitable for the login and logoff subroutines, or false
+Returns a portnum suitable for the login and logout subroutines, or false
on error.
-=item logoff HASHREF
+=item logout HASHREF
-HASHREF should have the following keys: usrename, password, logoff and portnum.
-logoff is a UNIX timestamp; if not specified, will default to the current time.
+HASHREF should have the following keys: usrename, password, logout and portnum.
+logout is a UNIX timestamp; if not specified, will default to the current time.
Starts a new session for the specified user and portnum. The password is
optional, but must be correct if specified.
@@ -89,9 +89,11 @@ Returns a scalar error message, or the empty string for success.
sub AUTOLOAD {
my $hashref = shift;
+ my $method = $AUTOLOAD;
+ $method =~ s/^.*:://;
socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
connect(SOCK, sockaddr_un($fs_sessiond_socket)) or die "connect: $!";
- print SOCK "$AUTOLOAD\n";
+ print SOCK "$method\n";
print SOCK join("\n", %{$hashref}, 'END' ), "\n";
SOCK->flush;
@@ -104,7 +106,7 @@ sub AUTOLOAD {
=head1 VERSION
-$Id: SessionClient.pm,v 1.2 2000-11-07 15:00:37 ivan Exp $
+$Id: SessionClient.pm,v 1.3 2000-12-03 20:25:20 ivan Exp $
=head1 BUGS
diff --git a/fs_sesmon/FS-SessionClient/bin/freeside-login b/fs_sesmon/FS-SessionClient/bin/freeside-login
index 6ca4455f8..a6d475169 100644
--- a/fs_sesmon/FS-SessionClient/bin/freeside-login
+++ b/fs_sesmon/FS-SessionClient/bin/freeside-login
@@ -1,6 +1,6 @@
#!/usr/bin/perl -Tw
-#false-laziness hack w freeside-logoff
+#false-laziness hack w freeside-logout
use strict;
use FS::SessionClient qw( login portnum );
diff --git a/fs_sesmon/FS-SessionClient/bin/freeside-logoff b/fs_sesmon/FS-SessionClient/bin/freeside-logout
index f7b876b33..9b4ecfe23 100644
--- a/fs_sesmon/FS-SessionClient/bin/freeside-logoff
+++ b/fs_sesmon/FS-SessionClient/bin/freeside-logout
@@ -3,7 +3,7 @@
#false-laziness hack w freeside-login
use strict;
-use FS::SessionClient qw( logoff portnum );
+use FS::SessionClient qw( logout portnum );
my $username = shift;
@@ -24,7 +24,7 @@ if ( scalar(@ARGV) == 1 ) {
&usage;
}
-my $error = login ( {
+my $error = logout ( {
'username' => $username,
'portnum' => $portnum,
} );
@@ -32,6 +32,5 @@ my $error = login ( {
warn $error if $error;
sub usage {
- die "Usage:\n\n freeside-logoff username ( portnum | ip | nasnum nasport )";
+ die "Usage:\n\n freeside-logout username ( portnum | ip | nasnum nasport )";
}
-
diff --git a/fs_sesmon/FS-SessionClient/fs_sessiond b/fs_sesmon/FS-SessionClient/fs_sessiond
index 74d3aab31..d7284b252 100644
--- a/fs_sesmon/FS-SessionClient/fs_sessiond
+++ b/fs_sesmon/FS-SessionClient/fs_sessiond
@@ -12,7 +12,7 @@ use vars qw( $Debug );
$Debug = 1;
-my $fs_session_socket = "/usr/local/freeside/fs_sessiond_socket";
+my $fs_sessiond_socket = "/usr/local/freeside/fs_sessiond_socket";
$ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin';
$ENV{'SHELL'} = '/bin/sh';
@@ -29,10 +29,10 @@ warn "$me starting\n" if $Debug;
#nothing to read from server
warn "$me creating $fs_sessiond_socket\n" if $Debug;
-my $uaddr = sockaddr_un($fs_signupd_socket);
+my $uaddr = sockaddr_un($fs_sessiond_socket);
my $proto = getprotobyname('tcp');
socket(Server,PF_UNIX,SOCK_STREAM,0) or die "socket: $!";
-unlink($fs_signup_socket);
+unlink($fs_sessiond_socket);
bind(Server, $uaddr) or die "bind: $!";
listen(Server,SOMAXCONN) or die "listen: $!";
@@ -44,8 +44,8 @@ for ( ; $paddr = accept(Client,Server); close Client) {
if ( $command eq 'login' || $command eq 'logout' || $command eq 'portnum' ) {
warn "$me reading data from local client\n" if $Debug;
- my @data, $dos;
- push @data, scalar(<Client>) until $dos++ == 99 || $data[$#data] != "END\n";
+ my( @data, $dos );
+ push @data, scalar(<Client>) until $dos++ == 99 || $data[$#data] eq "END\n";
if ( $dos == 99 ) {
warn "$me WARNING: DoS attempt!"
} else {
diff --git a/fs_sesmon/FS-SessionClient/test.pl b/fs_sesmon/FS-SessionClient/test.pl
index d05201b66..4b9ae17e0 100644
--- a/fs_sesmon/FS-SessionClient/test.pl
+++ b/fs_sesmon/FS-SessionClient/test.pl
@@ -8,7 +8,8 @@
BEGIN { $| = 1; print "1..1\n"; }
END {print "not ok 1\n" unless $loaded;}
-use FS::SessionClient;
+#use FS::SessionClient;
+#sigh, "not running as the freeside user"
$loaded = 1;
print "ok 1\n";
diff --git a/fs_sesmon/fs_session_server b/fs_sesmon/fs_session_server
index 46e53d118..0930a3c00 100644
--- a/fs_sesmon/fs_session_server
+++ b/fs_sesmon/fs_session_server
@@ -6,9 +6,9 @@
use strict;
use vars qw( $opt $Debug );
use IO::Handle;
-use Net::SSH qw(sshopen3)
+use Net::SSH qw(sshopen2);
use FS::UID qw(adminsuidsetup);
-use FS::Record qw( qsearch qsearchs );
+use FS::Record qw( qsearchs ); #qsearch );
#use FS::cust_main_county;
#use FS::cust_main;
use FS::session;
@@ -31,25 +31,28 @@ while (1) {
my($reader, $writer) = (new IO::Handle, new IO::Handle);
$writer->autoflush(1);
warn "$me Connecting to $machine\n" if $Debug;
- sshopen2($machine,$reader,$writer,$fs_signupd);
+ sshopen2($machine,$reader,$writer,$fs_sessiond);
warn "$me Entering main loop\n" if $Debug;
while (1) {
warn "$me Reading (waiting for) data\n" if $Debug;
- my $command = scalar(<$reader));
+ my $command = scalar(<$reader>);
+ chomp $command;
#DoS protection here too, to protect against a compromised client? *sigh*
- while ( ( my $key = scalar(<$reader>) ) != "END\n" ) {
+ my %hash;
+ while ( ( my $key = scalar(<$reader>) ) ne "END\n" ) {
chomp $key;
chomp( $hash{$key} = scalar(<$reader>) );
}
if ( $command eq 'login' ) {
- $error = &login(\%hash);
+ my $error = &login(\%hash);
print $writer "$error\n";
- } elsif ( $command eq 'logoff' ) {
- $error = &logoff(\%hash);
+ } elsif ( $command eq 'logout' ) {
+ my $error = &logout(\%hash);
print $writer "$error\n";
} elsif ( $command eq 'portnum' ) {
+ my $port;
if ( exists $hash{'ip'} ) {
$hash{'ip'} =~ /^([\d\.]+)$/ or $1='nomatch';
$port = qsearchs('port', { 'ip' => $1 } );
@@ -60,13 +63,13 @@ while (1) {
}
print $writer ( $port ? $port->portnum : '' ), "\n";
} else {
- warn "$me WARNING: unrecognized command";
+ warn "$me WARNING: unrecognized command: $command";
}
}
#won't ever reach without code above to throw out of loop, but...
close $writer;
close $reader;
- warn "connection to $machine lost!\n"
+ warn "connection to $machine lost!\n";
sleep 5;
warn "reconnecting...\n";
}
@@ -75,10 +78,10 @@ sub login {
my $href = shift;
$href->{'username'} =~ /^([a-z0-9_\-\.]+)$/ or return "Illegal username";
my $username = $1;
- $svc_acct = qsearchs('svc_acct', { 'username' => $username } )
+ my $svc_acct = qsearchs('svc_acct', { 'username' => $username } )
or return "Unknown user";
return "Incorrect password"
- if defined($href->{'password'})
+ if exists($href->{'password'})
&& $href->{'password'} ne $svc_acct->_password;
my $session = new FS::session {
'portnum' => $href->{'portnum'},
@@ -92,18 +95,19 @@ sub logout {
my $href = shift;
$href->{'username'} =~ /^([a-z0-9_\-\.]+)$/ or return "Illegal username";
my $username = $1;
- $svc_acct = qsearchs('svc_acct', { 'username' => $username } )
+ my $svc_acct = qsearchs('svc_acct', { 'username' => $username } )
or return "Unknown user";
return "Incorrect password"
- if defined($href->{'password'})
+ if exists($href->{'password'})
&& $href->{'password'} ne $svc_acct->_password;
- my $session = qsearchs FS::session {
+ my $session = qsearchs( 'session', {
'portnum' => $href->{'portnum'},
'svcnum' => $svc_acct->svcnum,
- 'logoff' => '',
- };
- return "No currently open sessios found for that user/port!" unless $session;
- my $nsession = new FS::session ( { $old->hash } );
+ 'logout' => '',
+ } );
+ return "No currently open sessions found for that user/port!" unless $session;
+ my $nsession = new FS::session ( { $session->hash } );
+ warn "$nsession replacing $session";
$nsession->replace($session);
}