]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add "fr_dict_t**" to module definitions
authorAlan T. DeKok <aland@freeradius.org>
Wed, 1 May 2019 19:42:43 +0000 (15:42 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 2 May 2019 10:39:01 +0000 (06:39 -0400)
so that modules which are protocol-specific can catch errors

src/lib/server/module.h
src/lib/unlang/compile.c
src/modules/rlm_chap/rlm_chap.c

index ad385b527e48b438d7e3fe402ddfe3f10726d85c..5dcafe1e1d61efb22a7d40b01cfb73f278ae9d98 100644 (file)
@@ -177,6 +177,7 @@ struct rad_module_s {
                                                                //!< for modules.
        module_method_t                 methods[MOD_COUNT];     //!< Pointers to the various section callbacks.
        module_method_names_t const     *method_names;          //!< named methods
+       fr_dict_t                       **dict;                 //!< pointer to local fr_dict_t*
 };
 
 /** Per instance data
index cc321cf2b7baff681df797ca66c259ab7b6db022..4d17977a908184af25417c9b2fc0fc73f582a57d 100644 (file)
@@ -3037,6 +3037,19 @@ static unlang_t *compile_module(unlang_t *parent, unlang_compile_t *unlang_ctx,
        unlang_t *c;
        unlang_module_t *single;
 
+       /*
+        *      Can't use "chap" in "dhcp".
+        */
+       if (inst->module->dict && *inst->module->dict && unlang_ctx->rules && unlang_ctx->rules->dict_def &&
+           (unlang_ctx->rules->dict_def != fr_dict_internal) &&
+           (*inst->module->dict != unlang_ctx->rules->dict_def)) {
+               cf_log_err(ci, "The \"%s\" module can only used with 'namespace = %s'.  It cannot be used with 'namespace = %s'.",
+                          inst->module->name,
+                          fr_dict_root(*inst->module->dict)->name,
+                          fr_dict_root(unlang_ctx->rules->dict_def)->name);
+               return NULL;
+       }
+
        /*
         *      Check if the module in question has the necessary
         *      component.
index c51915d2cb843272f2f2ad63f8f254351fa9a2c4..434121c2906160ca1060f97b2ed680fa086f3f27 100644 (file)
@@ -210,6 +210,7 @@ module_t rlm_chap = {
        .name           = "chap",
        .inst_size      = sizeof(rlm_chap_t),
        .bootstrap      = mod_bootstrap,
+       .dict           = &dict_radius,
        .methods = {
                [MOD_AUTHENTICATE]      = mod_authenticate,
                [MOD_AUTHORIZE]         = mod_authorize,