Hello Tim,

On Fri, 27 Jun 2003 05:16 am, Tim Jung wrote:
> Ok well if the stored procedure is what is expecting a numeric rather than
> char is there a way to tell Radiator to try to convert that field to a
> number before it passes it? I would assume that I can't simply change the
> database itself, and a lot of the Rodopi stored procedures are locked as
> well.
>
> Any suggestions as to what exactly to do would be much appreciated.

You could try altering the insert query so that it munges the connect-info 
field before insertion.

But I have a better idea. 
I have attached a new version of AuthRODOPI.pm for Radiator 3.6 that 
integerifies the Connect-Info before insertion.

Please let me know how you go with this.
Cheers.

>
> Tim Jung
> System Admin
> Internet Gateway
> [EMAIL PROTECTED]
>
>
> ----- Original Message -----
> From: "Mike McCauley" <[EMAIL PROTECTED]>
> To: "Hugh Irvine" <[EMAIL PROTECTED]>; "Tim Jung" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Wednesday, June 25, 2003 7:37 PM
> Subject: Re: (RADIATOR) Radiator 3.5 & Rodopi 5.2sp3
>
> > Hello Tim,
> >
> > On Thu, 26 Jun 2003 09:57 am, Hugh Irvine wrote:
> > > Hello Tim -
> > >
> > > The message appears to be complaining about a data conversion from a
> > > string to a numeric.
> > >
> > > It is not obvious to me from the log which field is causing the
> > > problem, so you should check your database log to see exactly what is
> > > happening. You may need to adjust the column definition in the database
> > > to accomodate the data.
> >
> > Hugh is correct: your NAS is sending a string in a field that the Rodopi
> > stored procedure expects to be an integer. Its hard to be sure which one
>
> has
>
> > the problem, but I suspect that it might be the Connect-Info field, which
>
> in
>
> > this example is  '45333/26400 V.90/V.42/V.42bis QC'. In my test Rodopi
> > database, the stored procedure expects a numeric() there, even though it
>
> does
>
> > nothing with it.
> >
> > Cheers.
> >
> > > regards
> > >
> > > Hugh
> > >
> > > On Thursday, Jun 26, 2003, at 08:33 Australia/Melbourne, Tim Jung wrote:
> > > > I was wondering if someone could tell me why I am getting these
> > > > errors from
> > > > time to time in the Radiator log on my Linux box? It looks like it is
> > > > getting data from the Remote Access server and isn't able to dump it
> > > > into
> > > > the MS-SQL database that Rodopi uses.
> > > >
> > > > Wed Jun 25 17:20:43 2003: ERR: do failed for 'exec
> > > > Interface_VircomDetails
> > > > '00138AEE', 'Jun 25, 2003 17:16', 'paulhostkoetter', '67.95.10.115',
> > > > 13777,
> > > > 'Framed-User', 'PPP', '64.48.129.119', '6367240300',
> > > > 'stl-01.cvx.algx.net:6000',
> > > > 'Stop', 0, 141096, 1550059, 1500, 3410, 4373, 'User-Request',
> > > > 'Async', '45333/26400 V.90/V.42/V.42bis QC',
> > > > '6367541208'': Server message number=8114 severity=16 state=1 line=0
> > > > server=BILLINGprocedure=Interface_VircomDetailstext=Error converting
> > > > data
> > > > type varchar to numeric.
> > > >
> > > > I don't get this every single time, but I do seem to get it often
> > > > enough
> > > > that it is annoying and messes with keeping track of multiple logins
> > > > and
> > > > such.
> > > >
> > > > Let me know how to fix this or what I can do about it. Thanks.
> > > >
> > > > Tim Jung
> > > > System Admin
> > > > Internet Gateway
> > > > [EMAIL PROTECTED]
> > > >
> > > >
> > > > ===
> > > > Archive at http://www.open.com.au/archives/radiator/
> > > > Announcements on [EMAIL PROTECTED]
> > > > To unsubscribe, email '[EMAIL PROTECTED]' with
> > > > 'unsubscribe radiator' in the body of the message.
> > >
> > > NB: have you included a copy of your configuration file (no secrets),
> > > together with a trace 4 debug showing what is happening?
> >
> > --
> > Mike McCauley                               [EMAIL PROTECTED]
> > Open System Consultants Pty. Ltd            Unix, Perl, Motif, C++, WWW
> > 24 Bateman St Hampton, VIC 3188 Australia   http://www.open.com.au
> > Phone +61 3 9598-0985                       Fax   +61 3 9598-0955
> >
> > Radiator: the most portable, flexible and configurable RADIUS server
> > anywhere. SQL, proxy, DBM, files, LDAP, NIS+, password, NT, Emerald,
> > Platypus, Freeside, TACACS+, PAM, external, Active Directory, EAP, TLS,
> > TTLS, PEAP etc on Unix, Windows, MacOS etc.
> >
> > ===
> > Archive at http://www.open.com.au/archives/radiator/
> > Announcements on [EMAIL PROTECTED]
> > To unsubscribe, email '[EMAIL PROTECTED]' with
> > 'unsubscribe radiator' in the body of the message.

-- 
Mike McCauley                               [EMAIL PROTECTED]
Open System Consultants Pty. Ltd            Unix, Perl, Motif, C++, WWW
24 Bateman St Hampton, VIC 3188 Australia   http://www.open.com.au
Phone +61 3 9598-0985                       Fax   +61 3 9598-0955

Radiator: the most portable, flexible and configurable RADIUS server 
anywhere. SQL, proxy, DBM, files, LDAP, NIS+, password, NT, Emerald, 
Platypus, Freeside, TACACS+, PAM, external, Active Directory, EAP, TLS, 
TTLS, PEAP etc on Unix, Windows, MacOS etc.
# AuthRODOPI.pm
#
# Object for handling Authentication and accounting from Rodopi
# (http://www.rodopi.com)
# This is a subclass of SQL that can also get radius attributes
# from Rodopis special attribute tables.
#
# We only need to override the findUser function so that it 
# extracts reply items from RadConfifgs and RadATConfigs
#
# Author: Mike McCauley ([EMAIL PROTECTED])
# Copyright (C) 1997 Open System Consultants
# $Id: AuthRODOPI.pm,v 1.13 2002/05/23 02:02:44 mikem Exp mikem $

package Radius::AuthRODOPI;
@ISA = qw(Radius::AuthSQL);
use Radius::AuthSQL;
use strict;

%Radius::AuthRODOPI::ConfigKeywords = 
    ('TimeBanking'      => 'flag',
     'AcctSQLStatement' => 'string', # This alters the AuthSQL def
     );

#####################################################################
# Do per-instance default initialization
# This is called by Configurabel during Configurable::new before
# the config file is parsed. Its a good place initalze 
# instance variables
# that might get overridden when the config file is parsed.
sub initialize
{
    my ($self) = @_;

    $self->SUPER::initialize;
    $self->{AuthSelect} = 'exec Interface_VircomUsers %0';
    $self->{AcctSQLStatement} = "exec Interface_VircomDetails 
%0, '%1', %2, %3, %4, %5, %6, %7, %8, %9,
%10, %11, %12, %13, %14, %15, %16, %17, %18, %19,
%20";
}

#####################################################################
# Handle a request
# This function is called for each packet. $p points to a Radius::
# packet
# We just do special handling for accounting, and pass auths
# to AuthSQL
sub handle_request
{
    my ($self, $p, $dummy, $extra_checks) = @_;

    my $type = ref($self);
    return ($main::IGNORE, "Ignored due to IgnoreAuthentication")
	if $self->{IgnoreAuthentication} 
           && $p->code eq 'Access-Request';
    return ($main::IGNORE, "Ignored due to IgnoreAccounting")
	if $self->{IgnoreAccounting} 
           && $p->code eq 'Accounting-Request';

    if ($p->code eq 'Accounting-Request')
    {
	# (Re)-connect to the database if necessary,
	# No reply will be sent to the original requester if we 
	# fail to connect
	return ($main::IGNORE, 'Database failure')
	    if !$self->reconnect;

	# We are calling a stored procedure intended for Vircom
	# Get a whole bunch of additional attributes for 
	# Interface_VircomDetails. Its convenient to name them by
	# their standard Radius attribute number
	my $q = &Radius::Util::format_special
	    ($self->{AcctSQLStatement},
	     $p, undef,
	     $self->quote($p->getAttrByNum
			  ($Radius::Radius::ACCT_SESSION_ID)),
	     $self->formatDate($p->get_attr('Timestamp')),
	     $self->quote($p->getAttrByNum
			  ($Radius::Radius::USER_NAME)),
	     $self->quote($p->getAttrByNum
			  ($Radius::Radius::NAS_IP_ADDRESS)),
	     $self->getIntegerAttribute($p, $Radius::Radius::NAS_PORT),
	     $self->quote($p->getAttrByNum
			  ($Radius::Radius::SERVICE_TYPE)),
	     $self->quote($p->getAttrByNum
			  ($Radius::Radius::FRAMED_PROTOCOL)),
	     $self->quote($p->getAttrByNum
			  ($Radius::Radius::FRAMED_IP_ADDRESS)),
	     $self->quote($p->getAttrByNum
			  ($Radius::Radius::CALLING_STATION_ID)),
	     $self->quote($p->getAttrByNum
			  ($Radius::Radius::NAS_IDENTIFIER)),
	     $self->quote($p->getAttrByNum
			  ($Radius::Radius::ACCT_STATUS_TYPE)),
	     $self->getIntegerAttribute
	     ($p, $Radius::Radius::ACCT_DELAY_TIME),
	     $self->getIntegerAttribute
	     ($p, $Radius::Radius::ACCT_INPUT_OCTETS),
	     $self->getIntegerAttribute
	     ($p, $Radius::Radius::ACCT_OUTPUT_OCTETS),
	     $self->getIntegerAttribute
	     ($p, $Radius::Radius::ACCT_SESSION_TIME),
	     $self->getIntegerAttribute
	     ($p, $Radius::Radius::ACCT_INPUT_PACKETS),
	     $self->getIntegerAttribute
	     ($p, $Radius::Radius::ACCT_OUTPUT_PACKETS),
	     $self->quote
	     ($p->getAttrByNum($Radius::Radius::ACCT_TERMINATE_CAUSE)),
	     $self->quote
	     ($p->getAttrByNum($Radius::Radius::NAS_PORT_TYPE)),
	     $self->quote
	     (int $p->getAttrByNum($Radius::Radius::CONNECT_INFO)),
	     $self->quote
	     ($p->getAttrByNum($Radius::Radius::CALLED_STATION_ID)));
	my $sth = $self->do($q);
	
	return ($main::ACCEPT);
    }
    else
    {
	# Everything else is handled by AuthSQL
	return $self->SUPER::handle_request($p, $p->{rp}, $extra_checks);
    }

}

#####################################################################
# Find a the named user by looking in the database, and constructing
# User object if we found the named user
# This is tailored exactly to Rodopi's user database
sub findUser
{
    my ($self, $name, $p) = @_;

    # (Re)-connect to the database if necessary, 
    return (undef, 1) unless $self->reconnect;

    # We use a stored procedure intended for use by Vircom
    # It returns all the check and reply items for this user,
    # Including the password as check item Password
    my $qname = $self->quote($name);
    my $q = &Radius::Util::format_special($self->{AuthSelect},
					  $p, undef, $qname);
    my $sth = $self->prepareAndExecute($q);
    return undef unless $sth;

    my $user;
    my ($attr_name, $attr_value, $check_item);
    while (($attr_name, $attr_value, $check_item)
	   = $sth->fetchrow())
    {
	$user = new Radius::User $name if !$user;
#	print "got $attr_name, $attr_value, $check_item\n";
	# Dictionaries may not agree, so we use the 
	# attribute number to find the name
	if ($check_item)
	{
	    $user->get_check->add_attr($attr_name, 
				       $attr_value);
	}
	else
	{
	    $user->get_reply->add_attr($attr_name,
				       $attr_value);
	}
    }
    $sth->finish;
    return $user;
}

#####################################################################
# Retrieve an integer attribute for SQL. This is a bit faster than
# using DBI::quote
sub getIntegerAttribute
{
    my ($self, $p, $attr) = @_;

    my $value = $p->getAttrByNum($attr);
    return defined $value ? int $value : 'NULL';
}

1;

Reply via email to