1 package FS::SessionClient;
4 use vars qw($AUTOLOAD $VERSION @ISA @EXPORT_OK $fs_sessiond_socket);
12 @ISA = qw( Exporter );
13 @EXPORT_OK = qw( login logoff portnum );
15 $fs_sessiond_socket = "/usr/local/freeside/fs_sessiond_socket";
17 $ENV{'PATH'} ='/usr/bin:/bin';
18 $ENV{'SHELL'} = '/bin/sh';
19 $ENV{'IFS'} = " \t\n";
22 $ENV{'BASH_ENV'} = '';
24 my $freeside_uid = scalar(getpwnam('freeside'));
25 die "not running as the freeside user\n" if $> != $freeside_uid;
29 FS::SessionClient - Freeside session client API
33 use FS::SessionClient qw( login portnum logoff );
36 'username' => $username,
37 'password' => $password,
38 'login' => $timestamp,
39 'portnum' => $portnum,
42 $portnum = portnum( { 'ip' => $ip } ) or die "unknown ip!"
43 $portnum = portnum( { 'nasnum' => $nasnum, 'nasport' => $nasport } )
44 or die "unknown nasnum/nasport";
47 'username' => $username,
48 'password' => $password,
49 'logoff' => $timestamp,
50 'portnum' => $portnum,
55 This modules provides an API for a remote session application.
57 It needs to be run as the freeside user. Because of this, the program which
58 calls these subroutines should be written very carefully.
66 HASHREF should have the following keys: username, password, login and portnum.
67 login is a UNIX timestamp; if not specified, will default to the current time.
68 Starts a new session for the specified user and portnum. The password is
69 optional, but must be correct if specified.
71 Returns a scalar error message, or the empty string for success.
75 HASHREF should contain a single key: ip, or the two keys: nasnum and nasport.
76 Returns a portnum suitable for the login and logoff subroutines, or false
81 HASHREF should have the following keys: usrename, password, logoff and portnum.
82 logoff is a UNIX timestamp; if not specified, will default to the current time.
83 Starts a new session for the specified user and portnum. The password is
84 optional, but must be correct if specified.
86 Returns a scalar error message, or the empty string for success.
92 socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
93 connect(SOCK, sockaddr_un($fs_sessiond_socket)) or die "connect: $!";
94 print SOCK "$AUTOLOAD\n";
96 print SOCK join("\n", %{$hashref}, 'END' ), "\n";
99 chomp( my $r = <SOCK> );
107 $Id: SessionClient.pm,v 1.2 2000-11-07 15:00:37 ivan Exp $