Attribute Value length using SQL
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@demo' rlm_sql (sql): sql_set_user escaped user --> 'gunther@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@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@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
"Gunther" <freeradius@caribsms.com> wrote:
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).
RADIUS has a maximum attribute length of 253. You CAN NOT change it. Alan DeKok.
Alan DeKok wrote:
"Gunther" <freeradius@caribsms.com> wrote:
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).
RADIUS has a maximum attribute length of 253. You CAN NOT change it.
Alan DeKok.
Thanks! Yes, I see it in rfc2138 (0-253 octets) ... But isn't the feature I am talking about more part of the expression module and enhanced functionality of FreeRadius? I was reading in the Changelog: * Preliminary 'expression' module, to allow you to do cool things like: Session-Timeout = `%{expr:3600 - %{sql:SELECT ...}}` I saw that and started using it ... more and more. The result of the SQL statement is not supposed to be longer than 253, but the actual statement could be much longer. I actually changed the MAX_STRING_LEN size from 254 to 762 in include/libradius.h and it seems to work. Have to do more testing. But I am not really fond of the fact that I change the max string length for everything in FreeRadius. I would prefer to have just some extended space for sql statements for users who are using that feature. But if you tell me that is not the way to go ... I would need to look for another way. These SQL statements are just very convenient. Thanks! Gunther
"Gunther" <freeradius@caribsms.com> wrote:
Thanks! Yes, I see it in rfc2138 (0-253 octets) ... But isn't the feature I am talking about more part of the expression module and enhanced functionality of FreeRadius?
Yes, but the data structures used by the code are still based on RADIUS ones. If you want to use longer strings, rlm_policy in the CVS snapshot may help. Alan DeKok.
participants (2)
-
Alan DeKok -
Gunther