How to get current datetime in freeradius?

Houman houmie at gmail.com
Tue Oct 1 23:56:59 CEST 2019


Hello Nathan,

Fair point. I have tried your way like this, but I get an error with
Event-Timestamp. This is not predefined like %{User-Name} I take it. So how
do I get that?

/etc/freeradius/3.0/sites-enabled/default[565]: (Expires-At <
%{Event-Timestamp}) {
/etc/freeradius/3.0/sites-enabled/default[565]:               ^ Failed to
parse value for attribute


preacct {
    update request {
                Expires-At = "%{sql:SELECT expires_at FROM main_db.`user`
WHERE main_db.`user`.username ='%{User-Name}'}"
        }
        if (Expires-At < %{Event-Timestamp}) {
                update disconnect {
                        &User-Name = "%{User-Name}"
                }
        }

Many Thanks,
Houman


On Tue, 1 Oct 2019 at 13:52, Nathan Ward <lists+freeradius at daork.net> wrote:

>
> > On 1/10/2019, at 1:35 PM, Christian Strauf <strauf at rz.tu-clausthal.de>
> wrote:
> >
> > Hi Houman,
> >
> >> Is there a way to get the current date and time in
> >> /etc/freeradius/3.0/sites-enabled/default?
> >> I checked man unlang but couldn't find anything.
> > have a look here:
> >
> >
> https://wiki.freeradius.org/config/run_time_variables#one-character-variables
> <
> https://wiki.freeradius.org/config/run_time_variables#one-character-variables
> >
>
> You may also want to consider using the Event-Timestamp or some other
> attribute, rather than the time on the system doing the processing of the
> packet - so that if there are delays or similar the packet is processed
> correctly as though there was not any delays.
>
> In this case it probably doesn’t matter, other cases it might, so a good
> habit to get in to at least considering it.
>
> --
> Nathan Ward
>
> -
> List info/subscribe/unsubscribe? See
> http://www.freeradius.org/list/users.html


More information about the Freeradius-Users mailing list