With some help from Mike I created a logging module for SQL which logs the
reasons that people are rejected. This is great for troubleshooting tech
support calls. The module is small so I went ahead and attached it.
In your configuration file you need:
<Log RejectSQL>
DBSource dbi:mysql:dbname:host
DBUsername dbusername
DBAuth dbpassword
Table dbtablename
</Log RejectSQL>
Table structure:
CREATE TABLE rejectlog (
userid varchar(50) DEFAULT '' NOT NULL,
reason varchar(128) DEFAULT '' NOT NULL,
mdate timestamp(14),
KEY userid (userid)
);
Enjoy.
Steve
package Radius::LogRejectSQL;
use Radius::LogSQL;
use vars qw($VERSION @ISA);
BEGIN
{
@ISA = qw(Radius::LogSQL);
}
# Even this might be unnecessary
sub new
{
my ($class, $file) = @_;
my $self = $class->SUPER::new($file);
return $self;
}
sub log
{
my ($self, $p, $s) = @_;
return unless $s =~ /^Access rejected for (.*): (.*)$/;
my ($n, $r) = ($1, $2);
# (Re)-connect to the database if necessary,
return undef if !$self->reconnect;
$n = $self->{dbh}->quote($n);
$r = $self->{dbh}->quote($r);
my $q = "insert into $self->{Table} (userid, reason)
values ($n, $r)";
$self->do($q);
}
1;