From: Alan T. DeKok Date: Thu, 27 Oct 2011 07:24:29 +0000 (+0200) Subject: Clean upo logic See bug #181 X-Git-Tag: release_3_0_0_beta0~540 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5082577369da650ee3c75971abcf9b8674a584f0;p=thirdparty%2Ffreeradius-server.git Clean upo logic See bug #181 If we're almost at the expiry time, add the next time period ONLY if the reply is Session-Timeoout. --- diff --git a/src/modules/rlm_sqlcounter/rlm_sqlcounter.c b/src/modules/rlm_sqlcounter/rlm_sqlcounter.c index ae006ad94b8..0bd3dbb0deb 100644 --- a/src/modules/rlm_sqlcounter/rlm_sqlcounter.c +++ b/src/modules/rlm_sqlcounter/rlm_sqlcounter.c @@ -684,7 +684,7 @@ static int sqlcounter_authorize(void *instance, REQUEST *request) * Check if check item > counter */ if (check_vp->vp_integer > counter) { - unsigned int res = check_vp->lvalue - counter; + unsigned int res = check_vp->vp_integer - counter; DEBUG2("rlm_sqlcounter: Check item is greater than query result"); /* @@ -694,25 +694,27 @@ static int sqlcounter_authorize(void *instance, REQUEST *request) * that acceptable? */ - /* - * User is allowed, but set Session-Timeout. - * Stolen from main/auth.c - */ - /* * If we are near a reset then add the next - * limit, so that the user will not need to - * login again + * limit, so that the user will not need to login + * again. Do this only for Session-Timeout. */ - if (data->reset_time && + if ((data->reply_attr->attr == PW_SESSION_TIMEOUT) && + data->reset_time && (res >= (data->reset_time - request->timestamp))) { res = data->reset_time - request->timestamp; res += check_vp->vp_integer; } - if ((reply_item = pairfind(request->reply->vps, data->reply_attr->attr, data->reply_attr->vendor)) != NULL) { + /* + * Limit the reply attribute to the minimum of + * the existing value, or this new one. + */ + reply_item = pairfind(request->reply->vps, data->reply_attr->attr, data->reply_attr->vendor); + if (reply_item) { if (reply_item->vp_integer > res) reply_item->vp_integer = res; + } else { reply_item = radius_paircreate(request, &request->reply->vps,