From 52b07e8abd3946578a6c2701ec9e5195ec6b17e6 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 27 Oct 2000 20:15:50 +0000 Subject: session monitor --- fs_sesmon/FS-SessionClient/Changes | 5 ++ fs_sesmon/FS-SessionClient/MANIFEST | 9 +++ fs_sesmon/FS-SessionClient/MANIFEST.SKIP | 1 + fs_sesmon/FS-SessionClient/Makefile.PL | 10 +++ fs_sesmon/FS-SessionClient/SessionClient.pm | 120 ++++++++++++++++++++++++++++ fs_sesmon/FS-SessionClient/fs_sessiond | 64 +++++++++++++++ fs_sesmon/FS-SessionClient/test.pl | 20 +++++ 7 files changed, 229 insertions(+) create mode 100644 fs_sesmon/FS-SessionClient/Changes create mode 100644 fs_sesmon/FS-SessionClient/MANIFEST create mode 100644 fs_sesmon/FS-SessionClient/MANIFEST.SKIP create mode 100644 fs_sesmon/FS-SessionClient/Makefile.PL create mode 100644 fs_sesmon/FS-SessionClient/SessionClient.pm create mode 100644 fs_sesmon/FS-SessionClient/fs_sessiond create mode 100644 fs_sesmon/FS-SessionClient/test.pl (limited to 'fs_sesmon/FS-SessionClient') diff --git a/fs_sesmon/FS-SessionClient/Changes b/fs_sesmon/FS-SessionClient/Changes new file mode 100644 index 000000000..390a7b946 --- /dev/null +++ b/fs_sesmon/FS-SessionClient/Changes @@ -0,0 +1,5 @@ +Revision history for Perl extension FS::SessionClient + +0.01 Wed Oct 18 16:34:36 1999 + - original version; created by ivan 1.0 + diff --git a/fs_sesmon/FS-SessionClient/MANIFEST b/fs_sesmon/FS-SessionClient/MANIFEST new file mode 100644 index 000000000..3ced1df17 --- /dev/null +++ b/fs_sesmon/FS-SessionClient/MANIFEST @@ -0,0 +1,9 @@ +Changes +MANIFEST +MANIFEST.SKIP +Makefile.PL +SessionClient.pm +test.pl +fs_sessiond +cgi/logon.cgi +cgi/logoff.cgi diff --git a/fs_sesmon/FS-SessionClient/MANIFEST.SKIP b/fs_sesmon/FS-SessionClient/MANIFEST.SKIP new file mode 100644 index 000000000..ae335e78a --- /dev/null +++ b/fs_sesmon/FS-SessionClient/MANIFEST.SKIP @@ -0,0 +1 @@ +CVS/ diff --git a/fs_sesmon/FS-SessionClient/Makefile.PL b/fs_sesmon/FS-SessionClient/Makefile.PL new file mode 100644 index 000000000..8dff176a7 --- /dev/null +++ b/fs_sesmon/FS-SessionClient/Makefile.PL @@ -0,0 +1,10 @@ +use ExtUtils::MakeMaker; +# See lib/ExtUtils/MakeMaker.pm for details of how to influence +# the contents of the Makefile that is written. +WriteMakefile( + 'NAME' => 'FS::SessionClient', + 'VERSION_FROM' => 'SessionClient.pm', # finds $VERSION + 'EXE_FILES' => [ 'fs_sessiond' ], + 'INSTALLSCRIPT' => '/usr/local/sbin', + 'PERM_RWX' => '750', +); diff --git a/fs_sesmon/FS-SessionClient/SessionClient.pm b/fs_sesmon/FS-SessionClient/SessionClient.pm new file mode 100644 index 000000000..fd50e8908 --- /dev/null +++ b/fs_sesmon/FS-SessionClient/SessionClient.pm @@ -0,0 +1,120 @@ +package FS::SessionClient; + +use strict; +use vars qw($VERSION @ISA @EXPORT_OK $fs_sessiond_socket); +use Exporter; +use Socket; +use FileHandle; +use IO::Handle; + +$VERSION = '0.01'; + +@ISA = qw( Exporter ); +@EXPORT_OK = qw( login logoff ); + +$fs_sessiond_socket = "/usr/local/freeside/fs_sessiond_socket"; + +$ENV{'PATH'} ='/usr/bin:/bin'; +$ENV{'SHELL'} = '/bin/sh'; +$ENV{'IFS'} = " \t\n"; +$ENV{'CDPATH'} = ''; +$ENV{'ENV'} = ''; +$ENV{'BASH_ENV'} = ''; + +my $freeside_uid = scalar(getpwnam('freeside')); +die "not running as the freeside user\n" if $> != $freeside_uid; + +=head1 NAME + +FS::SessionClient - Freeside session client API + +=head1 SYNOPSIS + + use FS::SessionClient qw( login portnum logoff ); + + $error = login ( { + 'username' => $username, + 'password' => $password, + 'login' => $timestamp, + 'portnum' => $portnum, + } ); + + $portnum = portnum( { 'ip' => $ip } ) or die "unknown ip!" + $portnum = portnum( { 'nasnum' => $nasnum, 'nasport' => $nasport } ) + or die "unknown nasnum/nasport"; + + $error = logoff ( { + 'username' => $username, + 'password' => $password, + 'logoff' => $timestamp, + 'portnum' => $portnum, + } ); + +=head1 DESCRIPTION + +This modules provides an API for a remote session application. + +It needs to be run as the freeside user. Because of this, the program which +calls these subroutines should be written very carefully. + +=head1 SUBROUTINES + +=over 4 + +=item login HASHREF + +HASHREF should have the following keys: username, password, login and portnum. +login 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. + +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 +on error. + +=item logoff 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. +Starts a new session for the specified user and portnum. The password is +optional, but must be correct if specified. + +Returns a scalar error message, or the empty string for success. + +=cut + +sub AUTOLOAD { + my $hashref = shift; + 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 join("\n", %{$hashref}, 'END' ), "\n"; + SOCK->flush; + + chomp( my $r = ); + $r; +} + +=back + +=head1 VERSION + +$Id: SessionClient.pm,v 1.1 2000-10-27 20:15:50 ivan Exp $ + +=head1 BUGS + +=head1 SEE ALSO + +L + +=cut + +1; + + + diff --git a/fs_sesmon/FS-SessionClient/fs_sessiond b/fs_sesmon/FS-SessionClient/fs_sessiond new file mode 100644 index 000000000..74d3aab31 --- /dev/null +++ b/fs_sesmon/FS-SessionClient/fs_sessiond @@ -0,0 +1,64 @@ +#!/usr/bin/perl -Tw +# +# fs_sessiond +# +# This is run REMOTELY over ssh by fs_session_server +# + +use strict; +use Socket; + +use vars qw( $Debug ); + +$Debug = 1; + +my $fs_session_socket = "/usr/local/freeside/fs_sessiond_socket"; + +$ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin'; +$ENV{'SHELL'} = '/bin/sh'; +$ENV{'IFS'} = " \t\n"; +$ENV{'CDPATH'} = ''; +$ENV{'ENV'} = ''; +$ENV{'BASH_ENV'} = ''; + +$|=1; + +my $me = "[fs_sessiond]"; + +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 $proto = getprotobyname('tcp'); +socket(Server,PF_UNIX,SOCK_STREAM,0) or die "socket: $!"; +unlink($fs_signup_socket); +bind(Server, $uaddr) or die "bind: $!"; +listen(Server,SOMAXCONN) or die "listen: $!"; + +warn "$me entering main loop\n" if $Debug; +my $paddr; +for ( ; $paddr = accept(Client,Server); close Client) { + + chomp( my $command = ); + + 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() until $dos++ == 99 || $data[$#data] != "END\n"; + if ( $dos == 99 ) { + warn "$me WARNING: DoS attempt!" + } else { + warn "$me sending data to remote server\n" if $Debug; + print "$command\n", @data; + warn "$me reading result from remote server\n" if $Debug; + my $error = ; + warn "$me sending error to local client\n" if $Debug; + print Client $error; + } + } else { + warn "$me WARNING: unexpected command from client: $command"; + } + +} + diff --git a/fs_sesmon/FS-SessionClient/test.pl b/fs_sesmon/FS-SessionClient/test.pl new file mode 100644 index 000000000..d05201b66 --- /dev/null +++ b/fs_sesmon/FS-SessionClient/test.pl @@ -0,0 +1,20 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. + +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..1\n"; } +END {print "not ok 1\n" unless $loaded;} +use FS::SessionClient; +$loaded = 1; +print "ok 1\n"; + +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + -- cgit v1.2.1 From 7f07089722bfcabe3bf42619bb2bdb81fd8d44e1 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 7 Nov 2000 15:00:37 +0000 Subject: session monitor --- fs_sesmon/FS-SessionClient/MANIFEST | 2 ++ fs_sesmon/FS-SessionClient/Makefile.PL | 2 +- fs_sesmon/FS-SessionClient/SessionClient.pm | 6 ++--- fs_sesmon/FS-SessionClient/bin/freeside-login | 36 +++++++++++++++++++++++++ fs_sesmon/FS-SessionClient/bin/freeside-logoff | 37 ++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 fs_sesmon/FS-SessionClient/bin/freeside-login create mode 100644 fs_sesmon/FS-SessionClient/bin/freeside-logoff (limited to 'fs_sesmon/FS-SessionClient') diff --git a/fs_sesmon/FS-SessionClient/MANIFEST b/fs_sesmon/FS-SessionClient/MANIFEST index 3ced1df17..6da7b22e9 100644 --- a/fs_sesmon/FS-SessionClient/MANIFEST +++ b/fs_sesmon/FS-SessionClient/MANIFEST @@ -7,3 +7,5 @@ test.pl fs_sessiond cgi/logon.cgi cgi/logoff.cgi +bin/freeside-login +bin/freeside-logoff diff --git a/fs_sesmon/FS-SessionClient/Makefile.PL b/fs_sesmon/FS-SessionClient/Makefile.PL index 8dff176a7..1f598474a 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' => [ 'fs_sessiond' ], + 'EXE_FILES' => [ qw(fs_sessiond freeside-login freeside-logoff) ], 'INSTALLSCRIPT' => '/usr/local/sbin', 'PERM_RWX' => '750', ); diff --git a/fs_sesmon/FS-SessionClient/SessionClient.pm b/fs_sesmon/FS-SessionClient/SessionClient.pm index fd50e8908..97332cb26 100644 --- a/fs_sesmon/FS-SessionClient/SessionClient.pm +++ b/fs_sesmon/FS-SessionClient/SessionClient.pm @@ -1,7 +1,7 @@ package FS::SessionClient; use strict; -use vars qw($VERSION @ISA @EXPORT_OK $fs_sessiond_socket); +use vars qw($AUTOLOAD $VERSION @ISA @EXPORT_OK $fs_sessiond_socket); use Exporter; use Socket; use FileHandle; @@ -10,7 +10,7 @@ use IO::Handle; $VERSION = '0.01'; @ISA = qw( Exporter ); -@EXPORT_OK = qw( login logoff ); +@EXPORT_OK = qw( login logoff portnum ); $fs_sessiond_socket = "/usr/local/freeside/fs_sessiond_socket"; @@ -104,7 +104,7 @@ sub AUTOLOAD { =head1 VERSION -$Id: SessionClient.pm,v 1.1 2000-10-27 20:15:50 ivan Exp $ +$Id: SessionClient.pm,v 1.2 2000-11-07 15:00:37 ivan Exp $ =head1 BUGS diff --git a/fs_sesmon/FS-SessionClient/bin/freeside-login b/fs_sesmon/FS-SessionClient/bin/freeside-login new file mode 100644 index 000000000..6ca4455f8 --- /dev/null +++ b/fs_sesmon/FS-SessionClient/bin/freeside-login @@ -0,0 +1,36 @@ +#!/usr/bin/perl -Tw + +#false-laziness hack w freeside-logoff + +use strict; +use FS::SessionClient qw( login portnum ); + +my $username = shift; + +my $portnum; +if ( scalar(@ARGV) == 1 ) { + my $arg = shift; + if ( $arg =~ /^(\d+)$/ ) { + $portnum = $1; + } elsif ( $arg =~ /^([\d\.]+)$/ ) { + $portnum = portnum( { 'ip' => $1 } ) or die "unknown ip!" + } else { + &usage; + } +} elsif ( scalar(@ARGV) == 2 ) { + $portnum = portnum( { 'nasnum' => shift, 'nasport' => shift } ) + or die "unknown nasnum/nasport"; +} else { + &usage; +} + +my $error = login ( { + 'username' => $username, + 'portnum' => $portnum, +} ); + +warn $error if $error; + +sub usage { + die "Usage:\n\n freeside-login username ( portnum | ip | nasnum nasport )"; +} diff --git a/fs_sesmon/FS-SessionClient/bin/freeside-logoff b/fs_sesmon/FS-SessionClient/bin/freeside-logoff new file mode 100644 index 000000000..f7b876b33 --- /dev/null +++ b/fs_sesmon/FS-SessionClient/bin/freeside-logoff @@ -0,0 +1,37 @@ +#!/usr/bin/perl -Tw + +#false-laziness hack w freeside-login + +use strict; +use FS::SessionClient qw( logoff portnum ); + +my $username = shift; + +my $portnum; +if ( scalar(@ARGV) == 1 ) { + my $arg = shift; + if ( $arg =~ /^(\d+)$/ ) { + $portnum = $1; + } elsif ( $arg =~ /^([\d\.]+)$/ ) { + $portnum = portnum( { 'ip' => $1 } ) or die "unknown ip!" + } else { + &usage; + } +} elsif ( scalar(@ARGV) == 2 ) { + $portnum = portnum( { 'nasnum' => shift, 'nasport' => shift } ) + or die "unknown nasnum/nasport"; +} else { + &usage; +} + +my $error = login ( { + 'username' => $username, + 'portnum' => $portnum, +} ); + +warn $error if $error; + +sub usage { + die "Usage:\n\n freeside-logoff username ( portnum | ip | nasnum nasport )"; +} + -- cgit v1.2.1 From b90f8cdac9371c219a72dda16f8deecc7c44fc28 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 3 Dec 2000 20:25:20 +0000 Subject: session monitor updates --- fs_sesmon/FS-SessionClient/MANIFEST | 4 +-- fs_sesmon/FS-SessionClient/Makefile.PL | 2 +- fs_sesmon/FS-SessionClient/SessionClient.pm | 22 ++++++++------- fs_sesmon/FS-SessionClient/bin/freeside-login | 2 +- fs_sesmon/FS-SessionClient/bin/freeside-logoff | 37 -------------------------- fs_sesmon/FS-SessionClient/bin/freeside-logout | 36 +++++++++++++++++++++++++ fs_sesmon/FS-SessionClient/fs_sessiond | 10 +++---- fs_sesmon/FS-SessionClient/test.pl | 3 ++- 8 files changed, 59 insertions(+), 57 deletions(-) delete mode 100644 fs_sesmon/FS-SessionClient/bin/freeside-logoff create mode 100644 fs_sesmon/FS-SessionClient/bin/freeside-logout (limited to 'fs_sesmon/FS-SessionClient') 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-logoff deleted file mode 100644 index f7b876b33..000000000 --- a/fs_sesmon/FS-SessionClient/bin/freeside-logoff +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/perl -Tw - -#false-laziness hack w freeside-login - -use strict; -use FS::SessionClient qw( logoff portnum ); - -my $username = shift; - -my $portnum; -if ( scalar(@ARGV) == 1 ) { - my $arg = shift; - if ( $arg =~ /^(\d+)$/ ) { - $portnum = $1; - } elsif ( $arg =~ /^([\d\.]+)$/ ) { - $portnum = portnum( { 'ip' => $1 } ) or die "unknown ip!" - } else { - &usage; - } -} elsif ( scalar(@ARGV) == 2 ) { - $portnum = portnum( { 'nasnum' => shift, 'nasport' => shift } ) - or die "unknown nasnum/nasport"; -} else { - &usage; -} - -my $error = login ( { - 'username' => $username, - 'portnum' => $portnum, -} ); - -warn $error if $error; - -sub usage { - die "Usage:\n\n freeside-logoff username ( portnum | ip | nasnum nasport )"; -} - diff --git a/fs_sesmon/FS-SessionClient/bin/freeside-logout b/fs_sesmon/FS-SessionClient/bin/freeside-logout new file mode 100644 index 000000000..9b4ecfe23 --- /dev/null +++ b/fs_sesmon/FS-SessionClient/bin/freeside-logout @@ -0,0 +1,36 @@ +#!/usr/bin/perl -Tw + +#false-laziness hack w freeside-login + +use strict; +use FS::SessionClient qw( logout portnum ); + +my $username = shift; + +my $portnum; +if ( scalar(@ARGV) == 1 ) { + my $arg = shift; + if ( $arg =~ /^(\d+)$/ ) { + $portnum = $1; + } elsif ( $arg =~ /^([\d\.]+)$/ ) { + $portnum = portnum( { 'ip' => $1 } ) or die "unknown ip!" + } else { + &usage; + } +} elsif ( scalar(@ARGV) == 2 ) { + $portnum = portnum( { 'nasnum' => shift, 'nasport' => shift } ) + or die "unknown nasnum/nasport"; +} else { + &usage; +} + +my $error = logout ( { + 'username' => $username, + 'portnum' => $portnum, +} ); + +warn $error if $error; + +sub usage { + 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() until $dos++ == 99 || $data[$#data] != "END\n"; + my( @data, $dos ); + push @data, scalar() 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"; -- cgit v1.2.1 From f83184464cc34d1c2a0a999cbf215414827b39a2 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 3 Dec 2000 21:13:31 +0000 Subject: oops, forgot the web apps --- fs_sesmon/FS-SessionClient/cgi/login.cgi | 90 +++++++++++++++++++++++++++++++ fs_sesmon/FS-SessionClient/cgi/logout.cgi | 90 +++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 fs_sesmon/FS-SessionClient/cgi/login.cgi create mode 100644 fs_sesmon/FS-SessionClient/cgi/logout.cgi (limited to 'fs_sesmon/FS-SessionClient') diff --git a/fs_sesmon/FS-SessionClient/cgi/login.cgi b/fs_sesmon/FS-SessionClient/cgi/login.cgi new file mode 100644 index 000000000..ad964df75 --- /dev/null +++ b/fs_sesmon/FS-SessionClient/cgi/login.cgi @@ -0,0 +1,90 @@ +#!/usr/bin/perl -Tw + +#false-laziness hack w logout.cgi + +use strict; +use vars qw( $cgi $username $password $error $ip $portnum ); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use FS::SessionClient qw( login portnum ); + +$cgi = new CGI; + +if ( defined $cgi->param('magic') ) { + $cgi->param('username') =~ /^\s*(\w{1,255})\s*$/ or do { + $error = "Illegal username"; + &print_form; + exit; + }; + $username = $1; + $cgi->param('password') =~ /^([^\n]{0,255})$/ or die "guru meditation #420"; + $password = $1; + #$ip = $cgi->remote_host; + $ip = $ENV{REMOTE_ADDR}; + $ip =~ /^([\d\.]+)$/ or die "illegal ip: $ip"; + $ip = $1; + $portnum = portnum( { 'ip' => $1 } ) or do { + $error = "You appear to be coming from an unknown IP address. Verify ". + "that your computer is set to obtain an IP address automatically ". + "via DHCP."; + &print_form; + exit; + }; + + ( $error = login ( { + 'username' => $username, + 'portnum' => $portnum, + 'password' => $password, + } ) ) + ? &print_form() + : &print_okay(); + +} else { + $username = ''; + $password = ''; + $error = ''; + &print_form; +} + +sub print_form { + my $self_url = $cgi->self_url; + + print $cgi->header( '-expires' => 'now' ), <login + +END + +print qq!Error: $error! if $error; + +print < + +Username
+Password
+ + + + +END + +} + +sub print_okay { + print $cgi->header( '-expires' => 'now' ), <login sucessful +login successful, etc. + + +END +} + +my $error = login ( { + 'username' => $username, + 'portnum' => $portnum, +} ); + +warn $error if $error; + +sub usage { + die "Usage:\n\n freeside-login username ( portnum | ip | nasnum nasport )"; +} diff --git a/fs_sesmon/FS-SessionClient/cgi/logout.cgi b/fs_sesmon/FS-SessionClient/cgi/logout.cgi new file mode 100644 index 000000000..f5a57b2e8 --- /dev/null +++ b/fs_sesmon/FS-SessionClient/cgi/logout.cgi @@ -0,0 +1,90 @@ +#!/usr/bin/perl -Tw + +#false-laziness hack w login.cgi + +use strict; +use vars qw( $cgi $username $password $error $ip $portnum ); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use FS::SessionClient qw( logout portnum ); + +$cgi = new CGI; + +if ( defined $cgi->param('magic') ) { + $cgi->param('username') =~ /^\s*(\w{1,255})\s*$/ or do { + $error = "Illegal username"; + &print_form; + exit; + }; + $username = $1; + $cgi->param('password') =~ /^([^\n]{0,255})$/ or die "guru meditation #420"; + $password = $1; + #$ip = $cgi->remote_host; + $ip = $ENV{REMOTE_ADDR}; + $ip =~ /^([\d\.]+)$/ or die "illegal ip: $ip"; + $ip = $1; + $portnum = portnum( { 'ip' => $1 } ) or do { + $error = "You appear to be coming from an unknown IP address. Verify ". + "that your computer is set to obtain an IP address automatically ". + "via DHCP."; + &print_form; + exit; + }; + + ( $error = logout ( { + 'username' => $username, + 'portnum' => $portnum, + 'password' => $password, + } ) ) + ? &print_form() + : &print_okay(); + +} else { + $username = ''; + $password = ''; + $error = ''; + &print_form; +} + +sub print_form { + my $self_url = $cgi->self_url; + + print $cgi->header( '-expires' => 'now' ), <logout + +END + +print qq!Error: $error! if $error; + +print < + +Username
+Password
+ + + + +END + +} + +sub print_okay { + print $cgi->header( '-expires' => 'now' ), <logout sucessful +logout successful, etc. + + +END +} + +my $error = logout ( { + 'username' => $username, + 'portnum' => $portnum, +} ); + +warn $error if $error; + +sub usage { + die "Usage:\n\n freeside-logout username ( portnum | ip | nasnum nasport )"; +} -- cgit v1.2.1 From 7ca036115f70fd3d9b9bef6bca366d7a2f6064db Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 3 Dec 2000 21:45:36 +0000 Subject: tyop --- fs_sesmon/FS-SessionClient/MANIFEST | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs_sesmon/FS-SessionClient') diff --git a/fs_sesmon/FS-SessionClient/MANIFEST b/fs_sesmon/FS-SessionClient/MANIFEST index 9da279a87..162d4e453 100644 --- a/fs_sesmon/FS-SessionClient/MANIFEST +++ b/fs_sesmon/FS-SessionClient/MANIFEST @@ -5,7 +5,7 @@ Makefile.PL SessionClient.pm test.pl fs_sessiond -cgi/logon.cgi +cgi/login.cgi cgi/logout.cgi bin/freeside-login bin/freeside-logout -- cgit v1.2.1 From eefc403e7269f191637fa0b4a38b33dc8d206051 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 9 Dec 2000 02:53:31 +0000 Subject: layout nicely thanks to matt peterson --- fs_sesmon/FS-SessionClient/cgi/login.cgi | 35 +++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'fs_sesmon/FS-SessionClient') diff --git a/fs_sesmon/FS-SessionClient/cgi/login.cgi b/fs_sesmon/FS-SessionClient/cgi/login.cgi index ad964df75..54ac541c5 100644 --- a/fs_sesmon/FS-SessionClient/cgi/login.cgi +++ b/fs_sesmon/FS-SessionClient/cgi/login.cgi @@ -51,17 +51,42 @@ sub print_form { print $cgi->header( '-expires' => 'now' ), <login - + END print qq!Error: $error! if $error; print < +
-Username
-Password
- + + + + + + + + + + + + + + + +
+ Welcome +
+ Username + + +
+ Password + + +
+ +
-- cgit v1.2.1 From c328bbcdf207c83be69c9b925e597d4f92288806 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 10 Dec 2000 21:16:26 +0000 Subject: fix uninitialized value errors --- fs_sesmon/FS-SessionClient/fs_sessiond | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'fs_sesmon/FS-SessionClient') diff --git a/fs_sesmon/FS-SessionClient/fs_sessiond b/fs_sesmon/FS-SessionClient/fs_sessiond index d7284b252..bfdb20a1d 100644 --- a/fs_sesmon/FS-SessionClient/fs_sessiond +++ b/fs_sesmon/FS-SessionClient/fs_sessiond @@ -44,7 +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 ); + my @data; + my $dos = 0; push @data, scalar() until $dos++ == 99 || $data[$#data] eq "END\n"; if ( $dos == 99 ) { warn "$me WARNING: DoS attempt!" -- cgit v1.2.1 From 139cc78c8a30f0e73742a8af65f262b783ea606e Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 Apr 2001 07:25:51 +0000 Subject: oops, extraneous code causing problems, thanks to Mack for bugreport --- fs_sesmon/FS-SessionClient/cgi/login.cgi | 7 ------- fs_sesmon/FS-SessionClient/cgi/logout.cgi | 7 ------- 2 files changed, 14 deletions(-) (limited to 'fs_sesmon/FS-SessionClient') diff --git a/fs_sesmon/FS-SessionClient/cgi/login.cgi b/fs_sesmon/FS-SessionClient/cgi/login.cgi index 54ac541c5..0307c5a3d 100644 --- a/fs_sesmon/FS-SessionClient/cgi/login.cgi +++ b/fs_sesmon/FS-SessionClient/cgi/login.cgi @@ -103,13 +103,6 @@ sub print_okay { END } -my $error = login ( { - 'username' => $username, - 'portnum' => $portnum, -} ); - -warn $error if $error; - sub usage { die "Usage:\n\n freeside-login username ( portnum | ip | nasnum nasport )"; } diff --git a/fs_sesmon/FS-SessionClient/cgi/logout.cgi b/fs_sesmon/FS-SessionClient/cgi/logout.cgi index f5a57b2e8..95cef98d1 100644 --- a/fs_sesmon/FS-SessionClient/cgi/logout.cgi +++ b/fs_sesmon/FS-SessionClient/cgi/logout.cgi @@ -78,13 +78,6 @@ sub print_okay { END } -my $error = logout ( { - 'username' => $username, - 'portnum' => $portnum, -} ); - -warn $error if $error; - sub usage { die "Usage:\n\n freeside-logout username ( portnum | ip | nasnum nasport )"; } -- cgit v1.2.1