(RADIATOR) Hooks in Accounting only servers?
Hugh Irvine
hugh at open.com.au
Thu Jan 10 22:03:05 CST 2002
Hello Cassidy -
On Fri, 11 Jan 2002 11:21, Cassidy B. Larson wrote:
> I'm working on a new little feature that takes the 'Account-Output-Octets'
> and 'Account-Input-Octets' within the Accounting Stop packet and
> increments a particular users monthly record in a table I have created. If
> there
> is not a record for the month with this username it creates one with the
> information.
>
> My current setup is that I have separated my Authentication and Accounting
> servers into two different config files while running two different
> Radiator processes
> each with its own config.
>
> Can PostAuthHooks work within an accounting only radiator?
>
Yes, hooks work for both authentication and accounting.
> I'm getting these errors in my accounting-logfile upon restarting my
> radius: ERR: Unknown keyword '...../raddb/datatransmit.hook' in
> /usr/local/etc/radius-accounting.cfg line 0
>
> Wierd I know...
> Here's a snipit from my radius-accounting.cfg file...
>
> <Handler Realm=infowest.com>
> <AuthBy GROUP>
> AuthByPolicy ContinueWhileReject
> <AuthBy GROUP>
> AuthByPolicy ContinueWhileAccept
> AuthBy DefaultAuth
> <AuthBy FILE>
> Filename /data/radiator/raddb/users
> </AuthBy>
> PostAuthHook
> file:"/data/radiator/raddb/datatransmit.hook"
>
> The file above does exist. Here is is, if anybody cares.. It doesn't
> produce any errors when
> run directly with perl.
>
> sub {
> my $p = ${$_[0]};
> my $identifier;
> my $d;
>
> my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
> localtime(time());
> $year += 1900;
> $mon += 1;
> my $DATE = "'".$year."-".$mon."'";
>
> my $username = $p->get_attr('Username');
> my $class = $p->get_attr('Class');
> my $IN = $p->get_attr('Acct-Input-Octets');
> my $OUT = $p->get_attr('Acct-Output-Octets');
>
> if (!$IN) { $IN = 0; }
> if (!$OUT) { $OUT = 0; }
>
> my $dbh =
> DBI->connect("DBI:mysql:****:**********","radiusupdate","*********");
>
> if (($d = $dbh->do("SELECT USERNAME from DATATRANSMIT where
> USERNAME=if('$class' LIKE '%#IW', '
> $username\@infowest.com',if('$class' LIKE
> '%#NU','$username\@netutah.com','$username')) AND DATE=$DATE")) > 0) {
> $dbh->do("UPDATE DATATRANSMIT SET
> IN_TRANSFER=IN_TRANSFER+$IN,OUT_TRANSFER+$OUT where USERNAME=if('$class'
> LIKE '%#IW', '$username\@infowest.com',if('$class' LIKE
> '%#NU','$username\@netutah.
> com','$username')) AND DATE=$DATE");
> } else {
> $dbh->do("INSERT INTO DATATRANSMIT
> (USERNAME,DATE,IN_TRANSFER,OUT_TRANSFER) VALUES (if('$class' LIKE '%#IW',
> '$username\@infowest.com',if('$class' LIKE
> '%#NU','$username\@netutah.com','$username')),$DATE,$IN,$OUT)");
> }
> $dbh->disconnect || warn $dbh->errstr;
> return;
> }
>
> Within the goodies/hooks.txt file that Hugh always refers people to, I see
> this:
> <Handler ....>
> <AuthBy ....>
> ....
> </AuthBy>
> PostAuthHook file:"%D/replaceProfiles"
> </Handler>
>
> So I assume my syntax in my radius config is correct.. Problem being the
> error in the logfile.
>
> Ideas?
>
I suspect the problem is because the file:"..." is on a separate line.
<Handler Realm=infowest.com>
<AuthBy GROUP>
AuthByPolicy ContinueWhileReject
<AuthBy GROUP>
AuthByPolicy ContinueWhileAccept
AuthBy DefaultAuth
<AuthBy FILE>
Filename /data/radiator/raddb/users
</AuthBy>
PostAuthHook
file:"/data/radiator/raddb/datatransmit.hook"
You should use a "\" to continue the line:
</AuthBy>
PostAuthHook \
file:"/data/radiator/raddb/datatransmit.hook"
regards
Hugh
--
Radiator: the most portable, flexible and configurable RADIUS server
anywhere. Available on *NIX, *BSD, Windows 95/98/2000, NT, MacOS X.
-
Nets: internetwork inventory and management - graphical, extensible,
flexible with hardware, software, platform and database independence.
===
Archive at http://www.open.com.au/archives/radiator/
Announcements on radiator-announce at open.com.au
To unsubscribe, email 'majordomo at open.com.au' with
'unsubscribe radiator' in the body of the message.
More information about the radiator
mailing list