From: Alan T. DeKok Date: Wed, 1 May 2019 19:42:43 +0000 (-0400) Subject: add "fr_dict_t**" to module definitions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c09596ca14be0a798dd6d85a2b8025e2ac7c876e;p=thirdparty%2Ffreeradius-server.git add "fr_dict_t**" to module definitions so that modules which are protocol-specific can catch errors --- diff --git a/src/lib/server/module.h b/src/lib/server/module.h index ad385b527e4..5dcafe1e1d6 100644 --- a/src/lib/server/module.h +++ b/src/lib/server/module.h @@ -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 diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index cc321cf2b7b..4d17977a908 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -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. diff --git a/src/modules/rlm_chap/rlm_chap.c b/src/modules/rlm_chap/rlm_chap.c index c51915d2cb8..434121c2906 100644 --- a/src/modules/rlm_chap/rlm_chap.c +++ b/src/modules/rlm_chap/rlm_chap.c @@ -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,