From 21ec8a6b7223054c6137fdbffa0e059c5c6c9473 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 8 Dec 2000 22:22:31 +0000 Subject: [PATCH] session callbacks --- FS/FS/session.pm | 26 ++++++++++++++++++++++---- htdocs/docs/config.html | 2 ++ htdocs/docs/session.html | 12 ++++++------ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/FS/FS/session.pm b/FS/FS/session.pm index 027708d98..61dc8991a 100644 --- a/FS/FS/session.pm +++ b/FS/FS/session.pm @@ -1,7 +1,7 @@ package FS::session; use strict; -use vars qw( @ISA ); +use vars qw( @ISA $conf $start $stop ); use FS::Record qw( qsearchs ); use FS::svc_acct; use FS::port; @@ -9,6 +9,12 @@ use FS::nas; @ISA = qw(FS::Record); +$FS::UID::callback{'FS::session'} = sub { + $conf = new FS::Conf; + $start = $conf->exists('session-start') ? $conf->config('session-start') : ''; + $stop = $conf->exists('session-stop') ? $conf->config('session-stop') : ''; +}; + =head1 NAME FS::session - Object methods for session records @@ -104,7 +110,13 @@ sub insert { $self->nas_heartbeat($self->getfield('login')); - #session-starting callback! + #session-starting callback + #redundant with heartbeat, yuck + my $port = qsearchs('port',{'portnum'=>$self->portnum}); + my $nas = qsearchs('nas',{'nasnum'=>$port->nasnum}); + #kcuy + my( $ip, $nasip, $nasfqdn ) = ( $port->ip, $nas->nasip, $nas->nasfqdn ); + system( eval qq("$start") ) if $start; ''; @@ -147,7 +159,13 @@ sub replace { $self->nas_heartbeat($self->getfield('logout')); - #session-ending callback! + #session-ending callback + #redundant with heartbeat, yuck + my $port = qsearchs('port',{'portnum'=>$self->portnum}); + my $nas = qsearchs('nas',{'nasnum'=>$port->nasnum}); + #kcuy + my( $ip, $nasip, $nasfqdn ) = ( $port->ip, $nas->nasip, $nas->nasfqdn ); + session( eval qq("$stop") ) if $stop; ''; } @@ -206,7 +224,7 @@ sub svc_acct { =head1 VERSION -$Id: session.pm,v 1.3 2000-12-03 20:25:20 ivan Exp $ +$Id: session.pm,v 1.4 2000-12-08 22:22:31 ivan Exp $ =head1 BUGS diff --git a/htdocs/docs/config.html b/htdocs/docs/config.html index db218d642..fb744bff7 100644 --- a/htdocs/docs/config.html +++ b/htdocs/docs/config.html @@ -66,6 +66,8 @@ All further configuration files and directories are located in
  • sendmailconfigpath - Sendmail configuration file path - defaults to `/etc'. Many newer distributions use `/etc/mail'.
  • sendmailmachines - Your sendmail machines, one per line. This enables export of `/etc/virtusertable' and `/etc/sendmail.cw'.
  • sendmailrestart - If defined, the command which is run on sendmail machines after files are copied. +
  • session-start - If defined, the command which is executed on the Freeside machine when a session begins. The contents of the file are treated as a double-quoted perl string, with the following variables available: $ip, $nasip and $nasfqdn, which are the IP address of the starting session, and the IP address and fully-qualified domain name of the NAS this session is on. +
  • session-stop - If defined, the command which is executed on the Freeside machine when a session ends. The contents of the file are treated as a double-quoted perl string, with the following variables available: $ip, $nasip and $nasfqdn, which are the IP address of the starting session, and the IP address and fully-qualified domain name of the NAS this session is on.
  • shellmachine - A single machine with user home directories mounted. This enables home directory creation, renaming and archiving/deletion. In conjunction with `qmailmachines', it also enables `.qmail-extension' file maintenance.
  • shellmachine-useradd - The command(s) to run on shellmachine when an account is created. If this file does not exist, useradd -d $dir -m -s $shell -u $uid $username is the default. If the file exists but is empty, cp -pr /etc/skel $dir; chown -R $uid.$gid $dir is the default instead. Otherwise the contents of the file are treated as a double-quoted perl string, with the following variables available: $username, $uid, $gid, $dir, and $shell.
  • shellmachine-userdel - The command(s) to run on shellmachine when an account is deleted. If this file does not exist, userdel $username is the default. If the file exists but is empty, rm -rf $dir is the default instead. Otherwise the contents of the file are treated as a double-quoted perl string, with the following variables available: $username and $dir. diff --git a/htdocs/docs/session.html b/htdocs/docs/session.html index b7939acef..3e88d568b 100644 --- a/htdocs/docs/session.html +++ b/htdocs/docs/session.html @@ -39,10 +39,10 @@ Then:
  • portnum, ip or nasport and nasnum uniquely identify a port in the port database table. +

    Callbacks

    + - - - - - - + -- 2.11.0