Hi,
I've got a stand-alone perl program that hits the RADONLINE db and makes
entries in an access database for sendmail. On it's own, it works fine,
but I'm trying to make it work as a subroutine called from a PostAuthHook
in my Handler for IPass requests:
[from radius.cfg...]
AuthBy Ipass_SQL
AuthBy Ipass_User
# call an external program to open up mail relaying for
# this user
# PostAuthHook file:"%D/write-access.pl"
[...]
I've been playing around with trying to get it to work, but I'm not
totally familiar with the whole idea of subroutines and local vs. global
variables. At this time, I get the following error:
Wed Jan 10 20:03:59 2001: NOTICE: SIGHUP received: restarting
Wed Jan 10 20:03:59 2001: ERR: Compilation error in PostAuthHook(): Can't
declare subroutine entry in my at (eval 535) line 46, at EOF
I've changed all my variables to be in the format 'my $foo="bar";', but
I'm having trouble with getting a while loop that goes through an array
working (the log entry above always seems to be around the while loop).
I'm also curious if there's a better way to be hitting the database since
radiator already has a connection to it...
I've included the whole mess below in hopes that someone can give me a
hand with this. Running standalone is an option as well, I guess, I'd
just have to run this very frequently.
Thanks,
Charles
# -*- mode: Perl -*-
# PopAuth
# don't really know what the above does...
# CSS 01/10/01
# small program to update a sendmail (or possibly other) access
# list based on current logged in users outside of our normal
# IP range. Specifically, for IPass users. This can be run
# standalone out of cron or be called by a PostAuthHook in the
# handler/realm used for IPass requests.
# the m4 file used to tweak sendmail is here:
# http://www.sendmail.org/~ca/email/rules/popauth.m4
# It goes in the "hack" directory under sendmail's cf directory.
sub
{
# config options
my $dbhost = "localhost";
my $dbuser = "xxx";
my $dbpass = "xxx";
my $dbname = "radius";
my $dbtext = "/usr/local/etc/mail/popauth";
my $localips = "216.223.19";
my $makemap = "/usr/sbin/makemap";
my $dbtype = "hash";
my $dbfile = "/usr/local/etc/mail/popauth.db";
# needed for standalone operation...
#use DBI;
# connect to the db
my $dbhandle = DBI->connect("DBI:mysql:$dbname:$dbhost","$dbuser","$dbpass")
or die $DBI::errstr;
# get file handle
open (POPAUTH, ">$dbtext") || die ("Can't open $dbtext for writing.\n");
# our query
my $dbquery = "select FRAMEDIPADDRESS from RADONLINE where (FRAMEDIPADDRESS
NOT LIKE '$localips%' AND FRAMEDIPADDRESS IS NOT NULL)";
my $query = $dbhandle->prepare($dbquery);
$query->execute or die $DBI::errstr;
# this is where the complaints come from
while (@query_result = $query->fetchrow_array)
{
print POPAUTH "$query_result[0]\tOK\n";
print "$query_result[0]\tOK\n";
}
close POPAUTH;
my $dbhandle->disconnect;
my $rc = system ("$makemap $dbtype $dbfile < $dbtext");
if ($rc > 0)
{
print "Unable to execute command $makemap, exit code $rc\n";
}
return;
}
===
Archive at http://www.starport.net/~radiator/
Announcements on [EMAIL PROTECTED]
To unsubscribe, email '[EMAIL PROTECTED]' with
'unsubscribe radiator' in the body of the message.