expr in SQL no working

Gunther freeradius at caribsms.com
Sun Oct 2 11:21:34 CEST 2005


I am running Fedora FC4 with FR 1.0.4 (yum updated) with MySQL 4.1.12.

I am trying to use in rad_reply table for Session-Timeout with the following
value:

`%{expr: %{sql:SELECT IF(NOW() <= user_stoptime,
(TIME_TO_SEC(TIMEDIFF(user_stoptime, IF(NOW() >= user_starttime, now(),
DATE_SUB(user_stoptime, INTERVAL 1 SECOND))))), 1) FROM phs_user WHERE
user_username='%{User-Name}'}}`

This doesn't work as the Session-Timeout value is not assigned.
The sql statement alone works fine and returns the correct value.

I then tried to get a simple expression up and running in rad_reply:
Attr			Op	Value
Session-Timeout 	=	`%{expr:3600 - 300}`
No success.

In debug mode I can see that the expr module is loaded:
Module: Loaded expr
Module: Instantiated expr (expr)

I then compiled and installed 1.0.5 ... with the same result.

Then I created a user in the ./raddb/users file and assigned the
Session-Timeout with above SQL statement
and it works fine.

What is wrong getting the Session-Timeout from the rad_reply table?
When I assign a fixed value, e.g. 3500 in the sql row, it works fine.
Anything with MySQL collation maybe? I changed it to different languages ...
no success. 

This is the debug output when I use the users file, when using sql, I do not
get this.
Debug: rlm_sql (sql): - sql_xlat
Debug: radius_xlat:  'gunther'
Debug: rlm_sql (sql): sql_set_user escaped user --> 'gunther'
Debug: radius_xlat:  'SELECT IF(NOW() <= user_stoptime,
TIME_TO_SEC(TIMEDIFF(user_stoptime, IF(NOW() >= user_starttime, now(),
DATE_SUB(user_stoptime, INTERVAL 1 SECOND)))), 1) FROM phs_user WHERE
user_username='gunther4''
Debug: radius_xlat:  '/var/log/radius/sqltrace.sql'
Debug: rlm_sql (sql): Reserving sql socket id: 2
Debug: rlm_sql_mysql: query:  SELECT IF(NOW() <= user_stoptime,
TIME_TO_SEC(TIMEDIFF(user_stoptime, IF(NOW() >= user_starttime, now(),
DATE_SUB(user_stoptime, INTERVAL 1 SECOND)))), 1) FROM phs_user WHERE
user_username='gunther4'
Debug: rlm_sql (sql): - sql_xlat finished
Debug: rlm_sql (sql): Released sql socket id: 2
Debug: radius_xlat:  ' 1'
Debug: radius_xlat:  '1'

When I use the sql table, sql_xlat is not in the debug output.


Gunther





More information about the Freeradius-Users mailing list