From b7ba38e96ce74c282a35bc2c6f9c66e238cd6af0 Mon Sep 17 00:00:00 2001 From: kkalev Date: Tue, 25 Mar 2003 01:15:07 +0000 Subject: [PATCH] Add an extra configuration directive for the checkval module: notfound-reject = yes|no If set to yes and we dont find the item-name in the request then we send back a reject --- raddb/experimental.conf | 5 +++++ src/modules/rlm_checkval/rlm_checkval.c | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/raddb/experimental.conf b/raddb/experimental.conf index fad24bb..aa581f2 100644 --- a/raddb/experimental.conf +++ b/raddb/experimental.conf @@ -328,6 +328,11 @@ # The data type. Can be # string,integer,ipaddr,date,abinary,octets data-type = string + + # If set to yes and we dont find the item-name attribute in the + # request then we send back a reject + # DEFAULT is no + #notfound-reject = no } # diff --git a/src/modules/rlm_checkval/rlm_checkval.c b/src/modules/rlm_checkval/rlm_checkval.c index bb91b93..ece975d 100644 --- a/src/modules/rlm_checkval/rlm_checkval.c +++ b/src/modules/rlm_checkval/rlm_checkval.c @@ -55,6 +55,7 @@ typedef struct rlm_checkval_t { int dat_type; int item_attr; int chk_attr; + int notfound_reject; /* If we don't find the item_name in the request send back a reject */ } rlm_checkval_t; /* @@ -70,6 +71,7 @@ static CONF_PARSER module_config[] = { { "item-name", PW_TYPE_STRING_PTR, offsetof(rlm_checkval_t,item_name), NULL, NULL}, { "check-name", PW_TYPE_STRING_PTR, offsetof(rlm_checkval_t,check_name), NULL, NULL}, { "data-type", PW_TYPE_STRING_PTR, offsetof(rlm_checkval_t,data_type),NULL, "integer"}, + { "notfound-reject", PW_TYPE_BOOLEAN, offsetof(rlm_checkval_t,notfound_reject),NULL, "no"}, { NULL, -1, 0, NULL, NULL } /* end the list */ }; @@ -215,7 +217,19 @@ static int do_checkval(void *instance, REQUEST *request) if (!(item_vp = pairfind(request->packet->vps, data->item_attr))){ DEBUG2("rlm_checkval: Could not find item named %s in request", data->item_name); - return RLM_MODULE_NOTFOUND; + if (data->notfound_reject){ + char module_fmsg[MAX_STRING_LEN]; + VALUE_PAIR *module_fmsg_vp; + + snprintf(module_fmsg,sizeof(module_fmsg), + "rlm_checkval: Could not find item named %s in request", data->item_name); + module_fmsg_vp = pairmake("Module-Failure-Message", module_fmsg, T_OP_EQ); + pairadd(&request->packet->vps, module_fmsg_vp); + + return RLM_MODULE_REJECT; + } + else + return RLM_MODULE_NOTFOUND; } DEBUG2("rlm_checkval: Item Name: %s, Value: %s",data->item_name, item_vp->strvalue); tmp = request->config_items; -- 2.1.4