Sql Counter reads only the first 4 digits
Hi all, I've a strange problem with sql counter on freeradius both 1.1.7 and 2.1.5 versions. Actually executing SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='mauro' from SQL Server Management Studio gives me 294841 (Yes, that's a lot of seconds, is a test user) while the output of radiusd -X (ver 2.1.5) is: ------------------------------------ rlm_sqlcounter: Entering module authorize code sqlcounter_expand: 'SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='%{ User-Name}'' [sessioncounter] expand: SELECT SUM(AcctSessionTime) FROM radacct WHERE U serName='%{User-Name}' -> SELECT SUM(AcctSessionTime) FROM radacct WHERE UserNam e='mauro' sqlcounter_expand: '%{sql:SELECT SUM(AcctSessionTime) FROM radacct WHERE UserNa me='mauro'}' [sessioncounter] sql_xlat [sessioncounter] expand: %{User-Name} -> mauro [sessioncounter] sql_set_user escaped user --> 'mauro' [sessioncounter] expand: SELECT SUM(AcctSessionTime) FROM radacct WHERE U serName='mauro' -> SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='maur o' [sessioncounter] expand: /usr/var/log/radius/sqltrace.sql -> /usr/var/log /radius/sqltrace.sql rlm_sql (sql): Reserving sql socket id: 3 query: SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='mauro' [sessioncounter] sql_xlat finished rlm_sql (sql): Released sql socket id: 3 [sessioncounter] expand: %{sql:SELECT SUM(AcctSessionTime) FROM radacct W HERE UserName='mauro'} -> 2948 rlm_sqlcounter: Check item is greater than query result rlm_sqlcounter: Authorized user mauro, check_item=3600, counter=2948 rlm_sqlcounter: Sent Reply-Item for user mauro, Type=Session-Timeout, value=652 ++[sessioncounter] returns ok ------------------------------------ That's' totally wrong since 294841 is much bigger than 3600 and not smaller... And this happens with users from different groups and with different SUM(AcctSessionTime). *Every* time SUM(AcctSessionTime) is bigger than 9999 it looses the fifth digit of the response, better it looses every digits after the fourth!!! What's wrong??? I'd appreciate any help or ideas. This happens on two different Slackware 12.1 and 12.2 machines both with freeradius 1.1.7 and a Slackware 12.2 with freeradius 2.1.5 Mauro Iorio.
Mauro Iorio - Smart Soft s.r.l. wrote:
I’ve a strange problem with sql counter on freeradius both 1.1.7 and 2.1.5 versions.
Actually executing
SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='mauro'
What happens when you replace that SELECT statement with a hard-coded number, like 123456? Does it still truncate the result? Alan DeKok.
What happens when you replace that SELECT statement with a hard-coded number, like 123456? Does it still truncate the result?
Alan DeKok.
Yes, it does. Check the following output: ----------------------------------------- rlm_sqlcounter: Entering module authorize code sqlcounter_expand: 'SELECT 123456 FROM radacct WHERE UserName='%{User-Name}'' [sessioncounter] expand: SELECT 123456 FROM radacct WHERE UserName='%{Use r-Name}' -> SELECT 123456 FROM radacct WHERE UserName='mauro' sqlcounter_expand: '%{sql:SELECT 123456 FROM radacct WHERE UserName='mauro'}' [sessioncounter] sql_xlat [sessioncounter] expand: %{User-Name} -> mauro [sessioncounter] sql_set_user escaped user --> 'mauro' [sessioncounter] expand: SELECT 123456 FROM radacct WHERE UserName='mauro ' -> SELECT 123456 FROM radacct WHERE UserName='mauro' [sessioncounter] expand: /usr/var/log/radius/sqltrace.sql -> /usr/var/log /radius/sqltrace.sql rlm_sql (sql): Reserving sql socket id: 3 query: SELECT 123456 FROM radacct WHERE UserName='mauro' [sessioncounter] sql_xlat finished rlm_sql (sql): Released sql socket id: 3 [sessioncounter] expand: %{sql:SELECT 123456 FROM radacct WHERE UserName= 'mauro'} -> 1234 rlm_sqlcounter: Check item is greater than query result rlm_sqlcounter: Authorized user mauro, check_item=3600, counter=1234 rlm_sqlcounter: Sent Reply-Item for user mauro, Type=Session-Timeout, value=2366 ++[sessioncounter] returns ok WARNING: Please update your configuration, and remove 'Auth-Type = Local' WARNING: Use the PAP or CHAP modules instead. User-Password in the request is correct. +- entering group post-auth {...} ++[exec] returns noop Sending Access-Accept of id 213 to 192.168.4.203 port 44967 Session-Timeout = 2366 Finished request 0. ----------------------------------------- But when I use isql or tsql tools and runs the same query I get (since I have 12 records in radacct): SQL> select 123456 from radacct where username = 'mauro' +------------+ | | +------------+ | 123456 | | 123456 | | 123456 | | 123456 | | 123456 | | 123456 | | 123456 | | 123456 | | 123456 | | 123456 | | 123456 | | 123456 | +------------+ SQLRowCount returns 12 12 rows fetched So I think everything about unixodbc drivers is working properly. Mauro Iorio.
select 123456 from radacct where username = 'mauro' LIMIT 1 On Wed, May 20, 2009 at 2:44 PM, Mauro Iorio - Smart Soft s.r.l. < m.iorio@smartsoft.it> wrote:
What happens when you replace that SELECT statement with a hard-coded number, like 123456? Does it still truncate the result?
Alan DeKok.
Yes, it does. Check the following output:
-----------------------------------------
rlm_sqlcounter: Entering module authorize code sqlcounter_expand: 'SELECT 123456 FROM radacct WHERE UserName='%{User-Name}'' [sessioncounter] expand: SELECT 123456 FROM radacct WHERE UserName='%{Use r-Name}' -> SELECT 123456 FROM radacct WHERE UserName='mauro' sqlcounter_expand: '%{sql:SELECT 123456 FROM radacct WHERE UserName='mauro'}' [sessioncounter] sql_xlat [sessioncounter] expand: %{User-Name} -> mauro [sessioncounter] sql_set_user escaped user --> 'mauro' [sessioncounter] expand: SELECT 123456 FROM radacct WHERE UserName='mauro ' -> SELECT 123456 FROM radacct WHERE UserName='mauro' [sessioncounter] expand: /usr/var/log/radius/sqltrace.sql -> /usr/var/log /radius/sqltrace.sql rlm_sql (sql): Reserving sql socket id: 3 query: SELECT 123456 FROM radacct WHERE UserName='mauro' [sessioncounter] sql_xlat finished rlm_sql (sql): Released sql socket id: 3 [sessioncounter] expand: %{sql:SELECT 123456 FROM radacct WHERE UserName= 'mauro'} -> 1234 rlm_sqlcounter: Check item is greater than query result rlm_sqlcounter: Authorized user mauro, check_item=3600, counter=1234 rlm_sqlcounter: Sent Reply-Item for user mauro, Type=Session-Timeout, value=2366 ++[sessioncounter] returns ok WARNING: Please update your configuration, and remove 'Auth-Type = Local' WARNING: Use the PAP or CHAP modules instead. User-Password in the request is correct. +- entering group post-auth {...} ++[exec] returns noop Sending Access-Accept of id 213 to 192.168.4.203 port 44967 Session-Timeout = 2366 Finished request 0.
-----------------------------------------
But when I use isql or tsql tools and runs the same query I get (since I have 12 records in radacct):
SQL> select 123456 from radacct where username = 'mauro' +------------+ | | +------------+ | 123456 | | 123456 | | 123456 | | 123456 | | 123456 | | 123456 | | 123456 | | 123456 | | 123456 | | 123456 | | 123456 | | 123456 | +------------+ SQLRowCount returns 12 12 rows fetched
So I think everything about unixodbc drivers is working properly.
Mauro Iorio.
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Uh... no.
If it works for Ivan, then the problem is most likely in the unixodbc drivers.
Alan DeKok.
But when I run the same query in both isql and tsql the result is correct. So I think that unixodbc and freetds are ok. I'll try to recompile them anyway... Other ideas? Mauro Iorio.
Mauro Iorio - Smart Soft s.r.l. wrote:
But when I run the same query in both isql and tsql the result is correct. So I think that unixodbc and freetds are ok. I'll try to recompile them anyway...
Other ideas?
Instrument the FreeRADIUS source code. Follow the data from SQL, through the rlm_sql_FOO module, to rlm_sql, etc. See where it's being truncated. To put it another way, no one else has access to a system that can reproduce this. Only you do. Alan DeKok.
Mauro Iorio - Smart Soft s.r.l. wrote:
Yes, it does. Check the following output: ... [sessioncounter] expand: %{sql:SELECT 123456 FROM radacct WHERE UserName='mauro'} -> 1234
Hmm... I don't use the unixodbc drivers, so I can't test it here. I don't see anything in the code that would chop the results at 4 digits. Alan DeKok.
Mauro Iorio - Smart Soft s.r.l. wrote:
I’ve a strange problem with sql counter on freeradius both 1.1.7 and 2.1.5 versions.
Actually executing
SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='mauro'
What happens when you replace that SELECT statement with a hard-coded number, like 123456? Does it still truncate the result?
Alan DeKok. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
I can't replicate this. 2.1.6 prerelease on Slackware. sqlcounter_expand: '%{sql:SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='kaliki'}' [noresetcounter] sql_xlat [noresetcounter] expand: %{Stripped-User-Name} -> [noresetcounter] expand: %{User-Name} -> kaliki [noresetcounter] expand: %{%{User-Name}:-DEFAULT} -> kaliki [noresetcounter] expand: %{%{Stripped-User-Name}:-%{%{User-Name}:-DEFAULT}} -> kaliki [noresetcounter] sql_set_user escaped user --> 'kaliki' [noresetcounter] expand: SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='kaliki' -> SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='kaliki' rlm_sql (sql): Reserving sql socket id: 2 [noresetcounter] sql_xlat finished rlm_sql (sql): Released sql socket id: 2 [noresetcounter] expand: %{sql:SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='kaliki'} -> 1289790 rlm_sqlcounter: (Check item - counter) is less than zero rlm_sqlcounter: Rejected user kaliki, check_item=3600, counter=1289790 ++[noresetcounter] returns reject Ivan Kalik Kalik Informatika ISP
participants (4)
-
Alan DeKok -
Ivan Kalik -
Marinko Tarlac -
Mauro Iorio - Smart Soft s.r.l.