]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Update module_rlm_by_name_and_method() to return method_env
authorNick Porter <nick@portercomputing.co.uk>
Tue, 28 Feb 2023 10:18:46 +0000 (10:18 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Fri, 10 Mar 2023 17:18:34 +0000 (17:18 +0000)
src/lib/server/module_rlm.c
src/lib/server/module_rlm.h
src/lib/unlang/compile.c

index c1e254c702811478803a49b4071cdce59716000d..b2c3289d90b82abd46cba1fb8a6bedaccada0322 100644 (file)
@@ -418,6 +418,7 @@ bool module_rlm_section_type_set(request_t *request, fr_dict_attr_t const *type_
  * and ensures the module implements the specified method.
  *
  * @param[out] method          the method function we will call
+ * @param[out] method_env      the module_call_env to evaluate when compiling the method.
  * @param[in,out] component    the default component to use.  Updated to be the found component
  * @param[out] name1           name1 of the method being called
  * @param[out] name2           name2 of the method being called
@@ -428,7 +429,8 @@ bool module_rlm_section_type_set(request_t *request, fr_dict_attr_t const *type_
  *
  *  If the module exists but the method doesn't exist, then `method` is set to NULL.
  */
-module_instance_t *module_rlm_by_name_and_method(module_method_t *method, UNUSED rlm_components_t *component,
+module_instance_t *module_rlm_by_name_and_method(module_method_t *method, module_method_env_t const **method_env,
+                                                UNUSED rlm_components_t *component,
                                                 char const **name1, char const **name2,
                                                 char const *name)
 {
@@ -485,6 +487,7 @@ module_instance_t *module_rlm_by_name_and_method(module_method_t *method, UNUSED
                        if (methods->name1 == CF_IDENT_ANY) {
                        found:
                                *method = methods->method;
+                               if (method_env) *method_env = methods->method_env;
                                if (name1) *name1 = method_name1;
                                if (name2) *name2 = method_name2;
                                return mi;
@@ -685,6 +688,7 @@ module_instance_t *module_rlm_by_name_and_method(module_method_t *method, UNUSED
                        *name1 = p;
                        *name2 = NULL;
                        *method = methods->method;
+                       if (method_env) *method_env = methods->method_env;
                        break;
                }
 
@@ -752,6 +756,7 @@ module_instance_t *module_rlm_by_name_and_method(module_method_t *method, UNUSED
                *name1 = methods->name1;
                *name2 = name + (q - inst_name);
                *method = methods->method;
+               if (method_env) *method_env = methods->method_env;
                break;
        }
 
@@ -865,7 +870,7 @@ static int module_rlm_bootstrap_virtual(CONF_SECTION *cs)
                         *      want to know if we need to register a
                         *      redundant xlat for the virtual module.
                         */
-                       mi = module_rlm_by_name_and_method(NULL, NULL, NULL, NULL, cf_pair_attr(cp));
+                       mi = module_rlm_by_name_and_method(NULL, NULL, NULL, NULL, NULL, cf_pair_attr(cp));
                        if (!mi) {
                                cf_log_err(sub_ci, "Module instance \"%s\" referenced in %s block, does not exist",
                                           cf_pair_attr(cp), cf_section_name1(cs));
index aaeabf3091921ca542ed2fe74a5e154f644713c4..e01450c8410c113124aece5ddac922bca965631a 100644 (file)
@@ -84,7 +84,8 @@ bool          module_rlm_section_type_set(request_t *request, fr_dict_attr_t const *type
  *
  * @{
  */
-module_instance_t      *module_rlm_by_name_and_method(module_method_t *method, rlm_components_t *component,
+module_instance_t      *module_rlm_by_name_and_method(module_method_t *method, module_method_env_t const ** method_env,
+                                                  rlm_components_t *component,
                                                   char const **name1, char const **name2,
                                                   char const *asked_name);
 
index 2cde92a2285752c7f6093124e8d043e6b4b10198..16e79cd4f09fdbe2ff742b630387f67cb935bafd 100644 (file)
@@ -4786,6 +4786,7 @@ static unlang_t *compile_item(unlang_t *parent, unlang_compile_t *unlang_ctx, CO
        bool                    policy;
        unlang_op_compile_t     compile;
        unlang_t                *c;
+       module_method_env_t const       *method_env = NULL;
 
        if (cf_item_is_section(ci)) {
                cs = cf_item_to_section(ci);
@@ -4955,7 +4956,7 @@ check_for_module:
         *      name2, etc.
         */
        UPDATE_CTX2;
-       inst = module_rlm_by_name_and_method(&method, &unlang_ctx2.component,
+       inst = module_rlm_by_name_and_method(&method, &method_env, &unlang_ctx2.component,
                                             &unlang_ctx2.section_name1, &unlang_ctx2.section_name2,
                                             realname);
        if (inst) {