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 logout 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 logout );
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 'logout' => $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 logout subroutines, or false
81 HASHREF should have the following keys: usrename, password, logout and portnum.
82 logout 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 my $method = $AUTOLOAD;
94 socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
95 connect(SOCK, sockaddr_un($fs_sessiond_socket)) or die "connect: $!";
96 print SOCK "$method\n";
98 print SOCK join("\n", %{$hashref}, 'END' ), "\n";
101 chomp( my $r = <SOCK> );
109 $Id: SessionClient.pm,v 1.3 2000-12-03 20:25:20 ivan Exp $