summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2000-12-08 22:22:31 +0000
committerivan <ivan>2000-12-08 22:22:31 +0000
commit21ec8a6b7223054c6137fdbffa0e059c5c6c9473 (patch)
tree5ef44bb5c2237d1a7cad64cd1a927195ca4853f5
parentcac4fe686355b65673f01d63013d9164a0a3c576 (diff)
session callbacks
-rw-r--r--FS/FS/session.pm26
-rw-r--r--htdocs/docs/config.html2
-rw-r--r--htdocs/docs/session.html12
3 files changed, 30 insertions, 10 deletions
diff --git a/FS/FS/session.pm b/FS/FS/session.pm
index 027708d..61dc899 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 db218d6..fb744bf 100644
--- a/htdocs/docs/config.html
+++ b/htdocs/docs/config.html
@@ -66,6 +66,8 @@ All further configuration files and directories are located in
<li><a name="sendmailconfigpath">sendmailconfigpath</a> - Sendmail configuration file path - defaults to `/etc'. Many newer distributions use `/etc/mail'.
<li><a name="sendmailmachines">sendmailmachines</a> - Your sendmail machines, one per line. This enables export of `/etc/virtusertable' and `/etc/sendmail.cw'.
<li><a name="sendmailrestart">sendmailrestart</a> - If defined, the command which is run on sendmail machines after files are copied.
+ <li><a name="session-start">session-start</a> - 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: <code>$ip</code>, <code>$nasip</code> and <code>$nasfqdn</code>, 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.
+ <li><a name="session-stop">session-stop</a> - 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: <code>$ip</code>, <code>$nasip</code> and <code>$nasfqdn</code>, 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.
<li><a name="shellmachine">shellmachine</a> - 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.
<li>shellmachine-useradd - The command(s) to run on shellmachine when an account is created. If this file does not exist, <code>useradd -d $dir -m -s $shell -u $uid $username</code> is the default. If the file exists but is empty, <code>cp -pr /etc/skel $dir; chown -R $uid.$gid $dir</code> is the default instead. Otherwise the contents of the file are treated as a double-quoted perl string, with the following variables available: <code>$username</code>, <code>$uid</code>, <code>$gid</code>, <code>$dir</code>, and <code>$shell</code>.
<li>shellmachine-userdel - The command(s) to run on shellmachine when an account is deleted. If this file does not exist, <code>userdel $username</code> is the default. If the file exists but is empty, <code>rm -rf $dir</code> is the default instead. Otherwise the contents of the file are treated as a double-quoted perl string, with the following variables available: <code>$username</code> and <code>$dir</code>.
diff --git a/htdocs/docs/session.html b/htdocs/docs/session.html
index b7939ac..3e88d56 100644
--- a/htdocs/docs/session.html
+++ b/htdocs/docs/session.html
@@ -39,10 +39,10 @@ Then:
<li><i>portnum</i>, <i>ip</i> or <i>nasport</i> and <i>nasnum</i> uniquely identify a port in the <a href="schema.html#port">port</a> database table.
</ul>
</ul>
+<h2>Callbacks</h2>
+<ul>
+ <li>Sesstion start - The command(s) specified in the <a href="config.html#session-start">session-start</a> configuration file are executed on the Freeside machine. The contents of the file are treated as a double-quoted perl string, with the following variables available: <code>$ip</code>, <code>$nasip</code> and <code>$nasfqdn</code>, 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.
+ <li>Session end - The command(s) specified in the <a href="config.html#session-stop">session-stop</a> configuration file are executed on the Freeside machine. The contents of the file are treated as a double-quoted perl string, with the following variables available: <code>$ip</code>, <code>$nasip</code> and <code>$nasfqdn</code>, 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.
+</ul>
</body>
-
-
-
-
-
-
+</html>