Unix TimeStamp Based Login

Fajar A. Nugraha list at fajar.net
Sun May 13 16:10:57 CEST 2012


On Sun, May 13, 2012 at 8:50 PM, jomajo <ster.efx at gmail.com> wrote:
> Hello!
>
> Maybe somebody know or maybe already implemented , Unix TimeStamp based
> login?

Not that I know of

>
> For example if I have "radcheck" table like this:
>
> http://freeradius.1045715.n5.nabble.com/file/n5708187/freeradius_unix.png
>

Looks similar to a "hack" I made. Not with login time though.

> How should Freeradius know, that he need's to look at start_time and
> end_time field in this table, and let the user to log in just at this
> specific time slot?

AFAIK the closest thing in the default FR setup is rlm_logintime
(http://wiki.freeradius.org/Rlm_logintime), but it's not what you need
since you want unix timestamps. You have to create your own solution.

>
> I know that I need to change this SQL statement:
>
>        authorize_check_query = "SELECT id, username, attribute1, value, op1 \
>         FROM ${authcheck_table} \
>         WHERE username = '%{SQL-User-Name}' \
>         ORDER BY id"
>
> Thanks if you have a minute to help me figure this out.

You could try

(1) Ask whomever designed the table.
Your table schema is not standard. If you're taking over an existing
solution, and it was based on FR, then your predecessor should know
best why he made that table the way it is.

(2) Learn SQL
You could mix the default query with sql's datetime functions, something like

authorize_check_query = "SELECT ....
  WHERE ...
  AND start_time >= unix_timestamp() \
  AND stop_time <= unix_timestamp() \
  ORDER BY id"

the example might not work for your setup, and might not be what you
need (e.g. "login time" vs "time allowed to be connected"), but should
give you some basic idea where to start.

(3) Hire someone with more knowledge in FR and whatever SQL server you're using.

-- 
Fajar


More information about the Freeradius-Users mailing list