[RADIATOR] Accessing Timestamp in Postauthhook during Access-Request

Hugh Irvine hugh at open.com.au
Thu Feb 18 16:07:51 CST 2010


Hello Chris -

The Timestamp is an integer number of seconds and you have defined it in your database as a string.

If you want a string you should use one of the special characters and call format_special on it.

Here is an example:


Radiator-4.6 hugh$ less timestamp.pl 

# -*- mode: Perl -*-
#
# Author: Hugh Irvine (hugh at open.com.au)
# Copyright (C) 2010 Open System Consultants
# 

sub 
{
    my $p = ${$_[0]};

    my $timestamp = &Radius::Util::format_special('%F', $p);

    &main::log($main::LOG_DEBUG, "Timestamp is $timestamp");

    return;
}


See section 5.2 in the Radiator 4.6 reference manual ("doc/ref.pdf") or the code in "Radius/Util.pm".

regards

Hugh


On 19 Feb 2010, at 08:23, Chris Bland wrote:

> Hi guys,
> 
> I have what seems like it should be trivial but has been driving me nuts 
> for more than a day.  I wrote a postauthhook to categorize users within 
> a realm and create log entries in separate database tables.  Everything 
> works find except for getting the Timestamp.  My code includes the 
> following:
> 
>    my $p = ${$_[0]};
>    my $rp = ${$_[1]};
>    my $result = ${$_[2]};
>    my $reason = ${$_[3]};
> 
>    my $timestamp = $p->get_attr('Timestamp');
> 
> then I execute the following sql statement
> 
> insert into $authlog (TIME_STAMP,USERNAME,TYPE,REASON) values 
> ('$timestamp','$username',$reqtype,'$reason')";
> 
> When I look in my db logs I see
> 
> insert into iauthlog (TIME_STAMP,USERNAME,TYPE,REASON) values 
> ('','chris at fdu.edu',1,'')
> 
> My table is constructed like this
> +------------+-------------+------+-----+---------+-------+
> | Field      | Type        | Null | Key | Default | Extra |
> +------------+-------------+------+-----+---------+-------+
> | USERNAME   | varchar(50) | YES  |     | NULL    |       |
> | TIME_STAMP | varchar(50) | YES  |     | NULL    |       |
> | TYPE       | int(1)      | YES  |     | NULL    |       |
> | REASON     | varchar(50) | YES  |     | NULL    |       |
> | IPADD      | varchar(20) | YES  |     | NULL    |       |
> +------------+-------------+------+-----+---------+-------+
> 
> I keep losing the Timestamp.  I have tried to pull time from both the 
> reply packet as well as the current request but neither works.  We are 
> running version Radiator-3.14-1 on a RHEL4 server.
> 
> Any help is appreciated,
> 
> -Chris
> _______________________________________________
> radiator mailing list
> radiator at open.com.au
> http://www.open.com.au/mailman/listinfo/radiator



NB: 

Have you read the reference manual ("doc/ref.html")?
Have you searched the mailing list archive (www.open.com.au/archives/radiator)?
Have you had a quick look on Google (www.google.com)?
Have you included a copy of your configuration file (no secrets), 
together with a trace 4 debug showing what is happening?

-- 
Radiator: the most portable, flexible and configurable RADIUS server
anywhere. Available on *NIX, *BSD, Windows, MacOS X.
Includes support for reliable RADIUS transport (RadSec),
and DIAMETER translation agent.
-
Nets: internetwork inventory and management - graphical, extensible,
flexible with hardware, software, platform and database independence.
-
CATool: Private Certificate Authority for Unix and Unix-like systems.





More information about the radiator mailing list