From: Alan T. DeKok Date: Sun, 14 Jun 2015 16:29:18 +0000 (-0400) Subject: Port fix from sqlcounter X-Git-Tag: release_3_0_9~179 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1de3ac3b227878edfa905d4c8d8347cad01e1ca1;p=thirdparty%2Ffreeradius-server.git Port fix from sqlcounter --- diff --git a/src/modules/rlm_counter/rlm_counter.c b/src/modules/rlm_counter/rlm_counter.c index 0bb2e766e08..48f8c42571c 100644 --- a/src/modules/rlm_counter/rlm_counter.c +++ b/src/modules/rlm_counter/rlm_counter.c @@ -328,9 +328,21 @@ static int mod_bootstrap(CONF_SECTION *conf, void *instance) { rlm_counter_t *inst = instance; ATTR_FLAGS flags; - DICT_ATTR const *da; + memset(&flags, 0, sizeof(flags)); + flags.compare = 1; /* ugly hack */ + da = dict_attrbyname(inst->counter_name); + if (da && (da->type != PW_TYPE_INTEGER)) { + cf_log_err_cs(conf, "Counter attribute %s MUST be integer", inst->counter_name); + return -1; + } + + if (!da && (dict_addattr(inst->counter_name, -1, 0, PW_TYPE_INTEGER, flags) < 0)) { + cf_log_err_cs(conf, "Failed to create counter attribute %s: %s", inst->counter_name, fr_strerror()); + return -1; + } + if (paircompare_register_byname(inst->counter_name, NULL, true, counter_cmp, inst) < 0) { cf_log_err_cs(conf, "Failed to create counter attribute %s: %s", inst->counter_name, fr_strerror()); return -1; @@ -347,7 +359,7 @@ static int mod_bootstrap(CONF_SECTION *conf, void *instance) /* * Create a new attribute for the check item. */ - memset(&flags, 0, sizeof(flags)); + flags.compare = 0; if (dict_addattr(inst->check_name, -1, 0, PW_TYPE_INTEGER, flags) < 0) { cf_log_err_cs(conf, "Failed to create check attribute %s: %s", inst->counter_name, fr_strerror()); return -1;