rlm_sqlcounter + PostgreSQL problem
Hi list! I have a problem with the rlm_sqlcounter. It send the Session-Time-Out correctly but when if check the time limit against the data base it always return 0. I've added some debugging output and recompile. This is the output: Tue Jul 5 14:46:51 2005 : Debug: rlm_sqlcounter: Entering module authorize code Tue Jul 5 14:46:51 2005 : Debug: sqlcounter_expand: 'SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='%{User-Name}' AND AcctStartTime > abstime(1120539600)' Tue Jul 5 14:46:51 2005 : Debug: radius_xlat: 'SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='ceruno' AND AcctStartTime > abstime(1120539600)' Tue Jul 5 14:46:51 2005 : Debug: sqlcounter_expand: '%{sqlcca3:SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='ceruno' AND AcctStartTime > abstime(1120539600)}' Tue Jul 5 14:46:51 2005 : Debug: rlm_sqlcounter: querystr: %{%S:SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='ceruno' AND AcctStartTime > abstime(1120539600)} Tue Jul 5 14:46:51 2005 : Debug: rlm_sqlcounter: responsestr: %{sqlcca3:SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='ceruno' AND AcctStartTime > abstime(1120539600)} Tue Jul 5 14:46:51 2005 : Debug: rlm_sqlcounter: Valor obtenido de la consulta: 0 Tue Jul 5 14:46:51 2005 : Debug: rlm_sqlcounter: Valor a checkar: 90 Tue Jul 5 14:46:51 2005 : Debug: rlm_sqlcounter: (Check item - counter) is greater than zero Tue Jul 5 14:46:51 2005 : Debug: rlm_sqlcounter: Authorized user ceruno, check_item=90, counter=0 Tue Jul 5 14:46:51 2005 : Debug: rlm_sqlcounter: Sent Reply-Item for user ceruno, Type=Session-Timeout, value=90 Tue Jul 5 14:46:51 2005 : Debug: modsingle[authorize]: returned from dailycounter (rlm_sqlcounter) for request 9 Tue Jul 5 14:46:51 2005 : Debug: modcall[authorize]: module "dailycounter" returns ok for request 9 Tue Jul 5 14:46:51 2005 : Debug: modsingle[authorize]: calling monthlycounter (rlm_sqlcounter) for request 9 Tue Jul 5 14:46:51 2005 : Debug: rlm_sqlcounter: Entering module authorize code Tue Jul 5 14:46:51 2005 : Debug: rlm_sqlcounter: Could not find Check item value pair Tue Jul 5 14:46:51 2005 : Debug: modsingle[authorize]: returned from monthlycounter (rlm_sqlcounter) for request 9 Tue Jul 5 14:46:51 2005 : Debug: modcall[authorize]: module "monthlycounter" returns noop for request 9 Tue Jul 5 14:46:51 2005 : Debug: modcall: group authorize returns ok for request 9 Tue Jul 5 14:46:51 2005 : Debug: rad_check_password: Found Auth-Type System Tue Jul 5 14:46:51 2005 : Debug: auth: type "System" Tue Jul 5 14:46:51 2005 : Debug: Processing the authenticate section of radiusd.conf Tue Jul 5 14:46:51 2005 : Debug: modcall: entering group authenticate for request 9 Tue Jul 5 14:46:51 2005 : Debug: modsingle[authenticate]: calling unix (rlm_unix) for request 9 Tue Jul 5 14:46:51 2005 : Debug: modsingle[authenticate]: returned from unix (rlm_unix) for request 9 Tue Jul 5 14:46:51 2005 : Debug: modcall[authenticate]: module "unix" returns ok for request 9 Tue Jul 5 14:46:51 2005 : Debug: modcall: group authenticate returns ok for request 9 Looking at the code in rlm_sqlcounter.c in the sqlcounter_authorize function (the lines starting with * is what I've added). /* third, wrap query with sql module & expand */ sprintf(querystr, "%%{%%S:%s}", responsestr); sqlcounter_expand(responsestr, MAX_QUERY_LEN, querystr, instance); /* Finally, xlat resulting SQL query */ radius_xlat(querystr, MAX_QUERY_LEN, responsestr, request, NULL); * DEBUG2("rlm_sqlcounter: querystr: %s",querystr); * DEBUG2("rlm_sqlcounter: responsestr: %s",responsestr); counter = atoi(querystr); * DEBUG2("rlm_sqlcounter: Valor obtenido de la consulta: %d",counter); * DEBUG2("rlm_sqlcounter: Valor a checkar: %d",check_vp->lvalue); If you compare the output above you will note that when 'counter = atoi(querystr)' happens the value of querystr is : ' %{%S:SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='ceruno' AND AcctStartTime > abstime(1120539600)}' . So I think is maybe a bug. I also have a question: Where the SQL query really happens? I couldn't figure it out :( I'am runnig in a FC3 with PostgreSQL 7.4.8 and the last stable release of freeRadius. (Version 1.0.4) I'll appreciate any help you can give me. Miguel.
On 7/5/05, Carlos Martínez-Troncoso Cera <cmartinez@uninorte.edu.co> wrote:
How are you testing? in the radacct table see if AcctSessionTime has some value, this is the data used for the counter, if this value is 0, the query is 0, you can test with NTRadPing sending in AcctSessionTime some value.
Well it has the values expected, > 0 for various for the users I'm testing with. I've also tested the queries outside radius directly in Postgres and I returns a number > 0, for example: SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='ceruno' AND AcctStartTime > abstime(1120539600). this query returns > 0 but when Radius does it, it apparently returns 0, I think there is a bug in someplace. (Did you read the last part of the email?) :
Looking at the code in rlm_sqlcounter.c in the sqlcounter_authorize function (the lines starting with * is what I've added).
/* third, wrap query with sql module & expand */ sprintf(querystr, "%%{%%S:%s}", responsestr); sqlcounter_expand(responsestr, MAX_QUERY_LEN, querystr, instance);
/* Finally, xlat resulting SQL query */ radius_xlat(querystr, MAX_QUERY_LEN, responsestr, request, NULL);
* DEBUG2("rlm_sqlcounter: querystr: %s",querystr); * DEBUG2("rlm_sqlcounter: responsestr: %s",responsestr); counter = atoi(querystr);
* DEBUG2("rlm_sqlcounter: Valor obtenido de la consulta: %d",counter); * DEBUG2("rlm_sqlcounter: Valor a checkar: %d",check_vp->lvalue);
If you compare the output above you will note that when 'counter = atoi(querystr)' happens the value of querystr is : ' %{%S:SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='ceruno' AND AcctStartTime > abstime(1120539600)}' . So I think is maybe a bug.
I also have a question: Where the SQL query really happens? I couldn't figure it out :(
I'am runnig in a FC3 with PostgreSQL 7.4.8 and the last stable release of freeRadius. (Version 1.0.4)
I'll appreciate any help you can give me.
Miguel.
Miguel. No sabia que usaran freeRadius por Curramba. :)
Hi erveryone, I make it work, I know how but not why: It wast working beacause by default is uses some-kind of modele called sqlcca3 which seems doesn't exist. I chaged to sql and worked fine. I other words I did this: original: sqlcounter dailycounter { driver = "rlm_sqlcounter" counter-name = Daily-Session-Time check-name = Max-Daily-Session sqlmod-inst = sqlcca3 key = User-Name reset = daily (...) } I changed the parameter sqlmod-inst to sql. Well i'm pretty new to this (4 days using radius ;) and maybe I'm wrong but I think xlat.c/radius_xlat() or xlat.c/decode_attribute function should complain when the module does not exist. I'll try to make a patch or something if someone tell I'm right. Thank you all. Miguel.
Miguel Cabrera <mfcabrera@gmail.com> wrote:
Well i'm pretty new to this (4 days using radius ;) and maybe I'm wrong but I think xlat.c/radius_xlat() or xlat.c/decode_attribute function should complain when the module does not exist.
It does. Run the server in debugging mode, and you will see the complaint message. Alan DeKok.
Hi Alan! Hi everyone!
It does. Run the server in debugging mode, and you will see the complaint message. Do you mean something like: radiusd -X -xx ? : I've done it, chek the output (specialy the highlighted text) at http://pastebin.com/309030 I can't see no complain and I also followed the behaviour of the code (so i think its may be a bug).
Another question, why does the rlm_sqlcounter comes with sqlcca3 as default sql module? What does it mean? is some kind of error? should I file a bug? Thanks. Miguel Cabrera.
Miguel Cabrera <mfcabrera@gmail.com> wrote:
Do you mean something like: radiusd -X -xx ? : I've done it, chek the output (specialy the highlighted text) at http://pastebin.com/309030
Hmm... Odd.
Another question, why does the rlm_sqlcounter comes with sqlcca3 as default sql module?
Because you're not using 1.0.4. It's fixed there. Alan Dekok.
Another error is the directory tree. /home/ceruno/DESARROLLO/RadiusCuentas/radius.install/var//log/radius/radacct" Note the double "//" after var. Take out the forward slash you have after the install location in your config. Alan DeKok wrote:
Miguel Cabrera <mfcabrera@gmail.com> wrote:
Do you mean something like: radiusd -X -xx ? : I've done it, chek the output (specialy the highlighted text) at http://pastebin.com/309030
Hmm... Odd.
Another question, why does the rlm_sqlcounter comes with sqlcca3 as default sql module?
Because you're not using 1.0.4. It's fixed there.
Alan Dekok. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Hi, Alan, ¿Radius?, Everyone On 7/7/05, Alan DeKok <aland@ox.org> wrote:
Miguel Cabrera <mfcabrera@gmail.com> wrote:
Do you mean something like: radiusd -X -xx ? : I've done it, chek the output (specialy the highlighted text) at http://pastebin.com/309030
Hmm... Odd.
Another question, why does the rlm_sqlcounter comes with sqlcca3 as default sql module?
Because you're not using 1.0.4. It's fixed there. hmmm ..... [ceruno@taganga RadiusCuentas]$ ls acctexample.pl freeradius-1.0.4 radius.etc documentacion.txt freeradius-1.0.4.tar.gz radius.install radius.log I'm using freeradius-1.0.4 in a new radius instalation (i've never installed freeRadius before) so the problem is still present. (can you check out the rlm_sqlcounter conf default conf files at the CVS?)
On 7/7/05, Radius <radius@kingmanaz.net> wrote:
Another error is the directory tree.
/home/ceruno/DESARROLLO/RadiusCuentas/radius.install/var//log/radius/radacct"
Note the double "//" after var. I dont think is a problem, for example, you can do an ls on //home//user///// and it will work.
Miguel.
participants (4)
-
Alan DeKok -
Carlos Martínez-Troncoso Cera -
Miguel Cabrera -
Radius