Attribute Value length using SQL

Gunther freeradius at caribsms.com
Sat Nov 5 02:20:33 CET 2005


I am running FR 1.0.5 with MySQL 4.1.12. All data is stored in MySQL.

My radgroupreply attribute values are SQL statements. It works very well.

But it seems I have reached the limit for the Value column.
My SQL output is setting the Session-Timeout.
The length of Attribute Value can be found in the
src/modules/rlm_sql/drivers/rlm_sql_mysql/db_mysql.sql

CREATE TABLE radgroupreply (
  id int(11) unsigned NOT NULL auto_increment,
  GroupName varchar(64) NOT NULL default '',
  Attribute varchar(32)  NOT NULL default '',
  op char(2) NOT NULL DEFAULT '=',
  Value varchar(253)  NOT NULL default '', <==
  prio int unsigned NOT NULL default '0',
  PRIMARY KEY  (id),
  KEY GroupName (GroupName(32))
) ;

I am trying to use a combination of the conditional syntax (e.g.
%{Foo:-%{Bar}}) in
connection with SQL statements. One sql statement is doing that and if false
another sql
statement is doing something else.
e.g 
`%{expr: %{sql:SELECT IF(NOW() > user_starttime,
IF(DATE_ADD(radacct_starttime, INTERVAL 30 MINUTE) > NOW(), ... and so on

I was trying to change the AV lenght from 253 to 1024, but radius is simply
cutting off after
the limit, resulting in an error in the log file (MYSQL check_error: 1054).

Log:
radius_xlat: Running registered xlat function of module expr for string
'%{sql:SELECT IF(NOW()>user_starttime,IF(DATE_ADD(radacct_starttime,INTERVAL
30 MINUTE)>NOW(),TIME_TO_SEC(TIMEDIFF(DATE_ADD(radacct_starttime, INTERVAL
30 MINUTE),NOW())),1),1) FROM phs_user,phs_radacct WHERE
user_username='%{User-Name}' AND radac'
radius_xlat: Running registered xlat function of module sql for string
'SELECT IF(NOW()>user_starttime,IF(DATE_ADD(radacct_starttime,INTERVAL 30
MINUTE)>NOW(),TIME_TO_SEC(TIMEDIFF(DATE_ADD(radacct_starttime, INTERVAL 30
MINUTE),NOW())),1),1) FROM phs_user,phs_radacct WHERE
user_username='%{User-Name}' AND radac'
rlm_sql (sql): - sql_xlat
radius_xlat:  'gunther at demo'
rlm_sql (sql): sql_set_user escaped user --> 'gunther at demo'
radius_xlat:  'SELECT
IF(NOW()>user_starttime,IF(DATE_ADD(radacct_starttime,INTERVAL 30
MINUTE)>NOW(),TIME_TO_SEC(TIMEDIFF(DATE_ADD(radacct_starttime, INTERVAL 30
MINUTE),NOW())),1),1) FROM phs_user,phs_radacct WHERE
user_username='gunther at demo' AND radac'
radius_xlat:  '/usr/local/var/log/radius/sqltrace.sql'
rlm_sql (sql): Reserving sql socket id: 2
rlm_sql_mysql: query:  SELECT
IF(NOW()>user_starttime,IF(DATE_ADD(radacct_starttime,INTERVAL 30
MINUTE)>NOW(),TIME_TO_SEC(TIMEDIFF(DATE_ADD(radacct_starttime, INTERVAL 30
MINUTE),NOW())),1),1) FROM phs_user,phs_radacct WHERE
user_username='gunther at demo' AND radac
rlm_sql_mysql: MYSQL check_error: 1054 received

I then tried to shorten tablenames etc., but even with that I still have
about 500+ bytes left.
Is there any reason the limit must be at 253?
Can the limit be changed ... in an easy way?

My complete Sessiont-Timeout Value:
`%{expr: %{sql:SELECT IF(NOW() > user_starttime,
IF(DATE_ADD(radacct_starttime, INTERVAL 30 MINUTE) > NOW(),
TIME_TO_SEC(TIMEDIFF(DATE_ADD(radacct_starttime, INTERVAL 30 MINUTE),
NOW())), 1), 1) FROM phs_user, phs_radacct WHERE
user_username='%{User-Name}' AND radacct_username=user_username AND
radacct_starttime >= user_starttime}  :-%{expr: %{sql:SELECT IF(NOW() >
user_starttime, IF(DATE_ADD(user_starttime, INTERVAL 24 HOUR) > NOW(),
TIME_TO_SEC(TIMEDIFF(DATE_ADD(NOW(), INTERVAL 30 MINUTE), NOW())), 1), 1)
FROM phs_user WHERE  user_username='%{User-Name}'}}`

Thanks!
Gunther





More information about the Freeradius-Users mailing list