> Two questions, first off, I have a 'default' user that has neither idle
> timeout or session timeout set, now when a user of that class logs in,
> they get logged out after between 2-5 minutes with a cause of "Idle-Timeout"
>
> Now ive since put in an idle timeout of 4 hours (max) and a session
> timeout of 1 year, and it has stopped happening, however I do not want to
> limit my users to 4 hours login. Does anyone have a fix/suggestion?
You should be able to set the timeouts to zero for indefinite login
periods on the portmaster and leave the Radius fields blank.
>
> Secondly, does anyone have a script to see who is online at the time?
> Basically an quiv to "who" for a PM2/Radius combo?
> Thanks in advance.
The following script is written in expect, an extension to the TCL
language:
-----------------------------------------------------
#!/usr/local/bin/expect -f
proc timedout {} \
{
send_user "Timed out.\n"
exit 1
}
set timeout 15
match_max 10000
set timeout 45
while { 1 } \
{
spawn -noecho /bin/telnet pm1
expect \
{
timeout timedout
eof {}
"login: " { break }
}
}
set current_prompt "pm1>"
send -- "!root\r"
expect timeout timedout "Password: "
send -- "Your-password-goes-here\r"
expect $current_prompt
send -- "show sessions\r"
expect \
{
" Press Return for More " { send -- "\r" }
$current_prompt {}
}
send -- "quit\r"
set current_prompt $env(USER)
expect $current_prompt
----------------------------------------------------------
That script will dump the same output as a "show sessions". I then put it
through a Perl script to make it pretty:
----------------------------------------------------------
#!/usr/bin/perl
sub usage
{
die "usage: parse-expect-pm1 [-help]\n";
}
sub swap_em
{
local( $first ) = $_[ 0 ];
local( $second ) = $_[ 1 ];
$temp = $port_num[ $first ];
$port_num[ $first ] = $port_num[ $second ];
$port_num[ $second ] = $temp;
$temp = $login_name[ $first ];
$login_name[ $first ] = $login_name[ $second ];
$login_name[ $second ] = $temp;
$temp = $line_status[ $first ];
$line_status[ $first ] = $line_status[ $second ];
$line_status[ $second ] = $temp;
$temp = $online_time[ $first ];
$online_time[ $first ] = $online_time[ $second ];
$online_time[ $second ] = $temp;
$temp = $complete_line[ $first ];
$complete_line[ $first ] = $complete_line[ $second ];
$complete_line[ $second ] = $temp;
}
sub compare_em
{
local( $first ) = $_[ 0 ];
local( $second ) = $_[ 1 ];
local( $first_exp ) = $online_time[ $first ];
local( $second_exp ) = $online_time[ $second ];
if(( $line_status[ $first ] ne "ESTABLISHED" )&&
( $line_status[ $second ] ne "ESTABLISHED" ))
{
return 0;
}
elsif( $line_status[ $first ] ne "ESTABLISHED" )
{
return -1;
}
elsif( $line_status[ $second ] ne "ESTABLISHED" )
{
return 1;
}
elsif( length( $first_exp ) < length( $second_exp ))
{
return -1;
}
elsif( length( $first_exp ) > length( $second_exp ))
{
return 1;
}
elsif( $first_exp lt $second_exp )
{
return -1;
}
elsif( $first_exp gt $second_exp )
{
return 1;
}
else
{
return 0;
}
}
sub sort_em
{
local( $index1 );
local( $index2 );
for( $index1 = 0; $index1 < $total_lines - 1; $index1++ )
{
for( $index2 = $index1 + 1; $index2 < $total_lines; $index2++ )
{
if( compare_em( $index1, $index2 ) < 0 )
{
swap_em( $index1, $index2 );
}
}
}
}
sub main
{
$total_lines = 24;
$used_lines = 0;
$available_lines = 0;
$position = 0;
open( ln_cnt, "/MCW/scripts/num-lines" ) || die "Couldn't find
num-lines: $!\
$total_lines = <ln_cnt>;
close( ln_cnt );
foreach $argc ( @ARGV )
{
if( $argc eq "-help" )
{
usage();
}
else
{
usage();
}
}
open( pm1, "/MCW/scripts/pm1.exp |" ) || die "Couldn't find pm1.exp:
$!\n";
while( <pm1> )
{
$complete_line[ $position2 ] = $_;
if(
/(^S(\d+)\s+([0-9a-zA-Z\-_=]+)\s+[0-9a-zA-Z\-_.]+\s+[a-zA-Z0-9\/]+\s+\w
{
$port_num[ $position ] = $2;
$login_name[ $position ] = $3;
$line_status[ $position ] = $4;
$online_time[ $position ] = $5;
if( $port_num[ $position ] < $total_lines )
{
if( $line_status[ $position ] eq "IDLE" )
{
$available_lines++;
}
else
{
$used_lines++;
}
$position++;
}
}
}
close( pm1 );
sort_em();
if( $used_lines != 0 )
{
for( $position = 0; $position < $total_lines; $position++ )
{
if( $line_status[ $position ] ne "IDLE" ) # USERNAME PASSWORD
CONNECTING
{
if( $line_status[ $position ] eq "ESTABLISHED" )
{
printf( "%-13s has been on port %2s for %5s minutes.\n",
$login_name[ $position ], $port_num[ $position ],
$online_time[ $position ] );
}
else
{
printf( "A new user is logging in to port %3s.\n",
$port_num[ $position ] );
}
}
}
printf( "\n" );
printf( "Lines Total/Used/Available: %2d / %2d / %2d.\n",
$total
}
else
{
printf( "There is currently nobody logged onto the portmaster.\n" );
}
}
&main;
-------------------------------------------------------------
You need to ensure that the two open commands in the Perl script can find
the files that you need. The first open is looking for a file that
contains the number of dial-up lines that you have and can be removed
(along with the following two lines) and hardwire the value in. The
second open refers to the first script and should point to whatever you
named it and wherever you put it.
The first script is written in an awesome language: expect. Available at:
http://elib.cme.nist.gov/pub/expect/index.html
It is worth getting this language even if you are not a programmer - just
for the examples (automatic FTP, etc.). It is also EXTREMLY EASY to
install.
Hope this is what you were looking for.
>
> = Alan Sawyer frooky@sx.com.au =
> = System Administrator/Webmaster/Photoshop 'guy'/aka Man of many hats. =
> = Secretary - Cranbourne Cricket Club. Member - VAPA, CISC. =
Tres
tres@chaffee.net
--If you think it to be idiot proof,
then you haven't met the "Latest 'n Greatest" idiot!