]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
set data type from 'key' if necessary.
authorAlan T. DeKok <aland@freeradius.org>
Wed, 23 Sep 2020 15:33:49 +0000 (11:33 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 23 Sep 2020 15:35:25 +0000 (11:35 -0400)
otherwise, check the data type of key against data_type

src/modules/rlm_csv/rlm_csv.c

index 7eca69cd6b74f470ce4638842e2b57b14ba95c19..e32364fb51b53e83ba8376b136793e472792a55e 100644 (file)
@@ -535,8 +535,13 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
                return -1;
        }
 
+
        if (!inst->data_type_name || !*inst->data_type_name) {
-               inst->data_type = FR_TYPE_STRING;
+               if (inst->key && tmpl_is_attr(inst->key)) {
+                       inst->data_type = tmpl_da(inst->key)->type;
+               } else {
+                       inst->data_type = FR_TYPE_STRING;
+               }
 
        } else {
                inst->data_type = fr_table_value_by_str(fr_value_box_type_table, inst->data_type_name, FR_TYPE_INVALID);
@@ -556,8 +561,15 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
                default:
                        goto invalid_type;
                }
+
+               if (inst->key && tmpl_is_attr(inst->key) && (tmpl_da(inst->key)->type != inst->data_type)) {
+                       cf_log_err(conf, "The data type of 'key' does not match data_type '%s'",
+                                  inst->data_type_name);
+                       return -1;
+               }
        }
 
+
        /*
         *      IP addresses go into tries.  Everything else into binary tries.
         */