Add support for 'never' counter expiration.
authorkkalev <kkalev>
Tue, 18 Dec 2001 21:49:07 +0000 (21:49 +0000)
committerkkalev <kkalev>
Tue, 18 Dec 2001 21:49:07 +0000 (21:49 +0000)
Patch by Aleksandr Kuzminsky <ingoth@nbi.com.ua>

raddb/radiusd.conf.in
src/modules/rlm_counter/rlm_counter.c

index 999a1ed..5feac49 100644 (file)
@@ -579,7 +579,7 @@ modules {
        #  count-attribute.
        #
        #  The 'reset' parameter defines when the counters are all reset to
-       #  zero.  It can be hourly, daily, weekly, or monthly.
+       #  zero.  It can be hourly, daily, weekly, monthly or never.
        #
        #  The counter-name is the name of the attribute in the 'users'
        #  file used to access that counter.  e.g.
index 046669e..9f553ed 100644 (file)
@@ -55,7 +55,7 @@ static const char rcsid[] = "$Id$";
  */
 typedef struct rlm_counter_t {
        char *filename;  /* name of the database file */
-       char *reset;  /* daily, weekly, monthly */
+       char *reset;  /* daily, weekly, monthly, never */
        char *key_name;  /* User-Name */
        char *count_attribute;  /* Acct-Session-Time */
        char *counter_name;  /* Daily-Session-Time */
@@ -163,6 +163,8 @@ static int find_next_reset(rlm_counter_t *data, time_t timeval)
                tm->tm_mday = 1;
                tm->tm_mon++;
                data->reset_time = mktime(tm);
+       } else if (strcmp(data->reset, "never") == 0) {
+               data->reset_time = 0;
        } else {
                radlog(L_ERR, "rlm_counter: Unknown reset timer \"%s\"",
                                data->reset);
@@ -275,10 +277,6 @@ static int counter_instantiate(CONF_SECTION *conf, void **instance)
        /*
         * Find the attribute for the allowed protocol
         */
-       if (data->service_type == NULL) {
-               radlog(L_ERR, "rlm_counter: 'allowed-servicetype' must be set.");
-               exit(0);
-       }
        if (data->service_type != NULL) {
                if ((dval = dict_valbyname(PW_SERVICE_TYPE, data->service_type)) == NULL) {
                        radlog(L_ERR, "rlm_counter: Failed to find attribute number for %s",
@@ -534,7 +532,7 @@ static int counter_authorize(void *instance, REQUEST *request)
                 * not need to login again
                 */
 
-               if (res >= (data->reset_time - request->timestamp))
+               if (data->reset_time && res >= (data->reset_time - request->timestamp))
                        res += check_vp->lvalue;
 
                DEBUG2("rlm_counter: (Check item - counter) is greater than zero");