2GB problems
Tas Dionisakos
tas at newman.unimelb.edu.au
Sun Jan 28 23:37:14 CET 2007
I have just applied the patch yet it still doesn't work, it produces the
same result. It is still producing a negative value, are there any
workarounds?
Tas.
Alan DeKok wrote:
> Tas Dionisakos wrote:
>
>> I have setup a captive portal with mysql,chilli, and freeradius.
>>
>> My portal allows users access base on data use (quota), I am using the
>> rlm_sqlcounter (from freeradius 1.1.4) to measure the usage on login.
>>
>> The problem Im having is that if I assign a quota more than 2gb
>> freeradius sees the bytes in a negative value for some reason, I have
>> attached rad logs.
>>
>
> Try this patch. If it works, please say so on the list.
>
> Alan DeKok.
> --
> http://deployingradius.com - The web site of the book
> http://deployingradius.com/blog/ - The blog
>
> ------------------------------------------------------------------------
>
> Index: rlm_sqlcounter.c
> ===================================================================
> RCS file: /source/radiusd/src/modules/rlm_sqlcounter/rlm_sqlcounter.c,v
> retrieving revision 1.11.2.3.2.6
> diff -u -r1.11.2.3.2.6 rlm_sqlcounter.c
> --- rlm_sqlcounter.c 18 Nov 2006 14:45:19 -0000 1.11.2.3.2.6
> +++ rlm_sqlcounter.c 25 Jan 2007 09:03:40 -0000
> @@ -175,8 +175,8 @@
> last = data->reset[len - 1];
> if (!isalpha((int) last))
> last = 'd';
> -/* num = atoi(data->reset); */
> - DEBUG("rlm_sqlcounter: num=%d, last=%c",num,last);
> + num = atoi(data->reset);
> + DEBUG("rlm_sqlcounter: num=%u, last=%c",num,last);
> }
> if (strcmp(data->reset, "hourly") == 0 || last == 'h') {
> /*
> @@ -392,6 +392,7 @@
>
> check_pairs = check_pairs; /* shut the compiler up */
> reply_pairs = reply_pairs;
> + request = request;
>
> /* first, expand %k, %b and %e in query */
> sqlcounter_expand(querystr, MAX_QUERY_LEN, data->query, instance);
> @@ -596,7 +597,7 @@
> {
> rlm_sqlcounter_t *data = (rlm_sqlcounter_t *) instance;
> int ret=RLM_MODULE_NOOP;
> - int counter=0;
> + uint32_t counter=0;
> int res=0;
> DICT_ATTR *dattr;
> VALUE_PAIR *key_vp, *check_vp;
> @@ -659,13 +660,18 @@
> /* Finally, xlat resulting SQL query */
> radius_xlat(querystr, MAX_QUERY_LEN, responsestr, request, sql_escape_func);
>
> - counter = atoi(querystr);
> + counter = strtoul(querystr, NULL, 10);
>
>
> /*
> * Check if check item > counter
> */
> - res=check_vp->lvalue - counter;
> + if (check_vp->lvalue > counter) {
> + res = check_vp->lvalue - counter;
> + } else {
> + res = - ((int) (counter - check_vp->lvalue));
> + }
> +
> if (res > 0) {
> DEBUG2("rlm_sqlcounter: (Check item - counter) is greater than zero");
> /*
> @@ -692,7 +698,7 @@
> }
>
> if ((reply_item = pairfind(request->reply->vps, data->reply_attr)) != NULL) {
> - if (reply_item->lvalue > res)
> + if (reply_item->lvalue > (uint32_t) res)
> reply_item->lvalue = res;
> } else {
> if ((reply_item = paircreate(data->reply_attr, PW_TYPE_INTEGER)) == NULL) {
> @@ -705,7 +711,7 @@
>
> ret=RLM_MODULE_OK;
>
> - DEBUG2("rlm_sqlcounter: Authorized user %s, check_item=%d, counter=%d",
> + DEBUG2("rlm_sqlcounter: Authorized user %s, check_item=%d, counter=%u",
> key_vp->strvalue,check_vp->lvalue,counter);
> DEBUG2("rlm_sqlcounter: Sent Reply-Item for user %s, Type=%s, value=%d",
> key_vp->strvalue,data->reply_name,reply_item->lvalue);
> @@ -729,7 +735,7 @@
>
> ret=RLM_MODULE_REJECT;
>
> - DEBUG2("rlm_sqlcounter: Rejected user %s, check_item=%d, counter=%d",
> + DEBUG2("rlm_sqlcounter: Rejected user %s, check_item=%d, counter=%u",
> key_vp->strvalue,check_vp->lvalue,counter);
> }
>
>
> ------------------------------------------------------------------------
>
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
--
*************************************
Tas Dionisakos
IT Manager
St Mary’s College and Newman College
The University of Melbourne
T: 03 9342 1708
M: 0439 655 565
E: tas at newman.unimelb.edu.au
C: (0o (||||)(||||) o0)
*************************************
More information about the Freeradius-Users
mailing list