From: Arran Cudbard-Bell Date: Sat, 1 Jun 2024 01:29:04 +0000 (-0600) Subject: Move module xlat registrations into the module code X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9374ea2e0b9a1b49fc803a79e8f71269dcda2d4;p=thirdparty%2Ffreeradius-server.git Move module xlat registrations into the module code --- diff --git a/src/lib/io/master.h b/src/lib/io/master.h index dcd57485c42..b529dc11161 100644 --- a/src/lib/io/master.h +++ b/src/lib/io/master.h @@ -70,7 +70,7 @@ typedef struct fr_io_track_s { * creates the listener, and adds it to the scheduler. */ typedef struct { - module_instance_t const *mi; //!< our parent mi + module_instance_t *mi; //!< our parent mi module_list_t *clients; //!< Holds client modules created to represent ///< sockets created as clients connect to the ///< listener. diff --git a/src/lib/server/module.c b/src/lib/server/module.c index 489be1f3759..3f9a0da17fa 100644 --- a/src/lib/server/module.c +++ b/src/lib/server/module.c @@ -1611,6 +1611,15 @@ fr_slen_t module_instance_name_valid(char const *inst_name) return 0; } +/** Set the uctx pointer for a module instance + * + * @param[in] mi to set the uctx for. + * @param[in] uctx to set. + */ +void module_instance_uctx_set(module_instance_t *mi, void *uctx) +{ + mi->uctx = uctx; +} /** Allocate a new module and add it to a module list for later bootstrap/instantiation * diff --git a/src/lib/server/module.h b/src/lib/server/module.h index f4115b3f3f1..9ae74d4ac2a 100644 --- a/src/lib/server/module.h +++ b/src/lib/server/module.h @@ -317,6 +317,8 @@ struct module_instance_s { char const *name; //!< Instance name e.g. user_database. module_instance_t const *parent; //!< Parent module's instance (if any). + + void *uctx; //!< Extra data passed to module_instance_alloc. /** @} */ }; @@ -496,6 +498,8 @@ module_instance_t *module_instance_alloc(module_list_t *ml, module_instance_state_t init_state) CC_HINT(nonnull(1)) CC_HINT(warn_unused_result); +void module_instance_uctx_set(module_instance_t *mi, void *uctx); + /** @name Module list variants * * These are passed to the module_list_alloc function to allocate lists of different types @@ -508,7 +512,7 @@ module_instance_t *module_instance_alloc(module_list_t *ml, * * @{ */ -extern module_list_type_t const module_list_type_global; //!< Initialise a global module, with thread-specific data. +extern module_list_type_t const module_list_type_global; //!< Initialise a global module, with thread-specific data. extern module_list_type_t const module_list_type_thread_local; //!< Initialise a thread-local module, which is only used in a single thread. /** @} */ diff --git a/src/lib/server/module_ctx.h b/src/lib/server/module_ctx.h index ac5e32f79bd..1db004302cc 100644 --- a/src/lib/server/module_ctx.h +++ b/src/lib/server/module_ctx.h @@ -48,13 +48,13 @@ typedef struct { /** Temporary structure to hold arguments for instantiation calls */ typedef struct { - module_instance_t const *mi; //!< Instance of the module being instantiated. + module_instance_t *mi; //!< Instance of the module being instantiated. } module_inst_ctx_t; /** Temporary structure to hold arguments for detach calls */ typedef struct { - module_instance_t const *mi; //!< Module instance to detach. + module_instance_t *mi; //!< Module instance to detach. } module_detach_ctx_t; /** Temporary structure to hold arguments for thread_instantiation calls diff --git a/src/lib/server/module_rlm.c b/src/lib/server/module_rlm.c index 7c19c6571a4..c5282605065 100644 --- a/src/lib/server/module_rlm.c +++ b/src/lib/server/module_rlm.c @@ -1095,6 +1095,39 @@ static int module_method_validate(module_instance_t *mi) return 0; } +/** Allocate a rlm module instance + * + * These have extra space allocated to hold the dlist of associated xlats. + * + * @param[in] ml Module list to allocate from. + * @param[in] parent Parent module instance. + * @param[in] type Type of module instance. + * @param[in] mod_name Name of the module. + * @param[in] inst_name Name of the instance. + * @param[in] init_state Initial state of the module instance. + * @return + * - The allocated module instance on success. + * - NULL on failure. + */ +static inline CC_HINT(always_inline) +module_instance_t *module_rlm_instance_alloc(module_list_t *ml, + module_instance_t const *parent, + dl_module_type_t type, char const *mod_name, char const *inst_name, + module_instance_state_t init_state) +{ + module_instance_t *mi; + module_rlm_instance_t *mri; + + mi = module_instance_alloc(ml, parent, type, mod_name, inst_name, init_state); + if (unlikely(mi == NULL)) return NULL; + + MEM(mri = talloc(mi, module_rlm_instance_t)); + module_instance_uctx_set(mi, mri); + fr_rb_inline_init(&mri->xlats, module_rlm_xlat_t, node, xlat_func_cmp, NULL); + + return mi; +} + static int module_conf_parse(module_list_t *ml, CONF_SECTION *mod_conf) { char const *name; @@ -1136,7 +1169,7 @@ static int module_conf_parse(module_list_t *ml, CONF_SECTION *mod_conf) if (module_instance_name_from_conf(&inst_name, mod_conf) < 0) goto invalid_name; - mi = module_instance_alloc(ml, NULL, DL_MODULE_TYPE_MODULE, name, inst_name, 0); + mi = module_rlm_instance_alloc(ml, NULL, DL_MODULE_TYPE_MODULE, name, inst_name, 0); if (unlikely(mi == NULL)) { cf_log_perr(mod_conf, "Failed loading module"); return -1; diff --git a/src/lib/server/module_rlm.h b/src/lib/server/module_rlm.h index fd175057cae..75b0e95cb3b 100644 --- a/src/lib/server/module_rlm.h +++ b/src/lib/server/module_rlm.h @@ -29,13 +29,43 @@ RCSIDH(module_rlm_h, "$Id$") extern "C" { #endif +typedef struct module_rlm_s module_rlm_t; +typedef struct module_rlm_instance_s module_rlm_instance_t; + #include #include -typedef struct { +struct module_rlm_s { module_t common; //!< Common fields presented by all modules. module_method_binding_t *bindings; //!< named methods -} module_rlm_t; +}; + +struct module_rlm_instance_s { + fr_rb_tree_t xlats; //!< xlats registered to this module instance. + ///< This is used by the redundant/loadbalance + ///< xlats to register versions of the xlats + ///< exported by the module instances. +}; + +/** An xlat function registered to a module + */ +typedef struct { + xlat_t const *xlat; //!< The xlat function. + fr_rb_node_t node; //!< Entry in an rbtree of registered xlats. +} module_rlm_xlat_t; + +/** The output of module_rlm_by_name_and_method + * + * Everything needed to call a module method. + */ +typedef struct { + module_instance_t *mi; //!< The process modules also push module calls + ///< onto the stack for execution. So we need + ///< to use the common type here. + module_rlm_t const *rlm; //!< Cached module_rlm_t. + module_method_binding_t mmb; //!< Method we're calling. + tmpl_t *key; //!< Dynamic key, only set for dynamic modules. +} module_method_call_t; /** Cast a module_t to a module_rlm_t * @@ -55,6 +85,10 @@ void module_rlm_list_debug(void); * * @{ */ +xlat_t *module_rlm_xlat_register(TALLOC_CTX *ctx, module_inst_ctx_t const *mctx, + char const *name, xlat_func_t func, fr_type_t return_type) + CC_HINT(nonnull(2,4)); + fr_pool_t *module_rlm_connection_pool_init(CONF_SECTION *module, void *opaque, fr_pool_connection_create_t c, @@ -92,10 +126,12 @@ module_instance_t *module_rlm_by_name_and_method(module_method_t *method, call_e char const **name1, char const **name2, virtual_server_t const *vs, char const *asked_name); -module_instance_t *module_rlm_static_by_name(module_instance_t const *parent, char const *asked_name); +module_instance_t *module_rlm_dynamic_by_name(module_instance_t const *parent, char const *name); CONF_SECTION *module_rlm_by_name_virtual(char const *asked_name); +module_instance_t *module_rlm_static_by_name(module_instance_t const *parent, char const *name); +CONF_SECTION *module_rlm_virtual_by_name(char const *name); /** @} */ /** @name Support functions diff --git a/src/lib/unlang/module_priv.h b/src/lib/unlang/module_priv.h index 40151319832..4685075f548 100644 --- a/src/lib/unlang/module_priv.h +++ b/src/lib/unlang/module_priv.h @@ -34,9 +34,8 @@ extern "C" { */ typedef struct { unlang_t self; //!< Common fields in all #unlang_t tree nodes. - module_instance_t *mi; //!< Global instance of the module we're calling. - module_method_t method; //!< The entry point into the module. call_env_t const *call_env; //!< The per call parsed call environment. + module_method_call_t mmc; //!< Everything needed to call a module method. } unlang_module_t; /** A module stack entry diff --git a/src/lib/unlang/xlat_func.c b/src/lib/unlang/xlat_func.c index 9434a925f10..995ad57848e 100644 --- a/src/lib/unlang/xlat_func.c +++ b/src/lib/unlang/xlat_func.c @@ -32,10 +32,16 @@ RCSID("$Id$") static fr_rb_tree_t *xlat_root = NULL; -/* - * Compare two xlat_t structs, based ONLY on the module name. +/** Compare two xlat_t by the registered name + * + * @param[in] one First xlat_t to compare. + * @param[in] two Second xlat_t to compare. + * @return + * - -1 if one < two + * - 0 if one == two + * - 1 if one > two */ -static int8_t xlat_cmp(void const *one, void const *two) +static int8_t xlat_name_cmp(void const *one, void const *two) { xlat_t const *a = one, *b = two; size_t a_len, b_len; @@ -51,6 +57,22 @@ static int8_t xlat_cmp(void const *one, void const *two) return CMP(ret, 0); } +/** Compare two xlat_t by the underlying function + * + * @param[in] one First xlat_t to compare. + * @param[in] two Second xlat_t to compare. + * @return + * - -1 if one < two + * - 0 if one == two + * - 1 if one > two + */ +int8_t xlat_func_cmp(void const *one, void const *two) +{ + xlat_t const *a = one, *b = two; + + return CMP((uintptr_t)a->func, (uintptr_t)b->func); +} + /* * find the appropriate registered xlat function. */ @@ -267,47 +289,21 @@ xlat_t *xlat_func_register(TALLOC_CTX *ctx, char const *name, xlat_func_t func, return c; } -/** Register an xlat function for a module +/** Associate a module calling ctx with the xlat * - * @param[in] ctx Used to automate deregistration of the xlat function. - * @param[in] mctx Instantiation context from the module. - * Will be duplicated and passed to future xlat calls. - * @param[in] name of the xlat. Must be NULL, for "self-named" xlats. - * e.g. `cache`, `sql`, `delay`, etc. - * @param[in] func to register. - * @param[in] return_type what type of output the xlat function will produce. - * @return - * - A handle for the newly registered xlat function on success. - * - NULL on failure. + * @note Intended to be called from the module_rlm + * + * @param[in] x to set the mctx for. + * @param[in] mctx Is duplicated and about to the lifetime of the xlat. */ -xlat_t *xlat_func_register_module(TALLOC_CTX *ctx, module_inst_ctx_t const *mctx, - char const *name, xlat_func_t func, fr_type_t return_type) +void xlat_mctx_set(xlat_t *x, module_inst_ctx_t const *mctx) { module_inst_ctx_t *our_mctx = NULL; - xlat_t *c; - char inst_name[256]; - fr_assert_msg(name != mctx->mi->name, "`name` must not be the same as the module " - "instance name. Pass a NULL `name` arg if this is required"); - - if (!name) { - name = mctx->mi->name; - } else { - if ((size_t)snprintf(inst_name, sizeof(inst_name), "%s.%s", mctx->mi->name, name) >= sizeof(inst_name)) { - ERROR("%s: Instance name too long", __FUNCTION__); - return NULL; - } - name = inst_name; - } - - c = xlat_func_register(ctx, name, func, return_type); - if (!c) return NULL; - - MEM(our_mctx = talloc_zero(c, module_inst_ctx_t)); /* Original won't stick around */ + TALLOC_FREE(x->mctx); + MEM(our_mctx = talloc_zero(x, module_inst_ctx_t)); /* Original won't stick around */ memcpy(our_mctx, mctx, sizeof(*our_mctx)); - c->mctx = our_mctx; - - return c; + x->mctx = our_mctx; } /** Verify xlat arg specifications are valid @@ -557,7 +553,7 @@ int xlat_func_init(void) /* * Create the function tree */ - xlat_root = fr_rb_inline_talloc_alloc(NULL, xlat_t, node, xlat_cmp, _xlat_func_tree_free); + xlat_root = fr_rb_inline_talloc_alloc(NULL, xlat_t, func_node, xlat_name_cmp, _xlat_func_tree_free); if (!xlat_root) { ERROR("%s: Failed to create tree", __FUNCTION__); return -1; diff --git a/src/lib/unlang/xlat_func.h b/src/lib/unlang/xlat_func.h index e5b8a26b12f..96d4439571d 100644 --- a/src/lib/unlang/xlat_func.h +++ b/src/lib/unlang/xlat_func.h @@ -52,12 +52,14 @@ typedef int (*xlat_resolve_t)(xlat_exp_t *xlat, void *inst, xlat_res_rules_t con */ typedef int (*xlat_purify_t)(xlat_exp_t *xlat, void *inst, request_t *request); +int8_t xlat_func_cmp(void const *one, void const *two); + xlat_t *xlat_func_find_module(module_inst_ctx_t const *mctx, char const *name); -xlat_t *xlat_func_register_module(TALLOC_CTX *ctx, module_inst_ctx_t const *mctx, - char const *name, xlat_func_t func, fr_type_t return_type) CC_HINT(nonnull(2,4)); xlat_t *xlat_func_register(TALLOC_CTX *ctx, char const *name, xlat_func_t func, fr_type_t return_type) CC_HINT(nonnull(2)); +void xlat_mctx_set(xlat_t *x, module_inst_ctx_t const *mctx); + int xlat_func_args_set(xlat_t *xlat, xlat_arg_parser_t const args[]) CC_HINT(nonnull); void xlat_func_call_env_set(xlat_t *x, call_env_method_t const *env) CC_HINT(nonnull); diff --git a/src/lib/unlang/xlat_priv.h b/src/lib/unlang/xlat_priv.h index bdf7ab068ec..2f120137c79 100644 --- a/src/lib/unlang/xlat_priv.h +++ b/src/lib/unlang/xlat_priv.h @@ -33,6 +33,7 @@ extern "C" { #include #include #include +#include #include #include #include @@ -56,14 +57,17 @@ extern "C" { #endif typedef struct xlat_s { - fr_rb_node_t node; //!< Entry in the xlat function tree. + fr_rb_node_t func_node; //!< Entry in the xlat function tree. + fr_dlist_t mi_entry; //!< Entry in the list of functions + ///< registered to a module instance. + char const *name; //!< Name of xlat function. xlat_func_t func; //!< async xlat function (async unsafe). bool internal; //!< If true, cannot be redefined. fr_token_t token; //!< for expressions - module_inst_ctx_t const *mctx; //!< Original module instantiation ctx if this + module_inst_ctx_t *mctx; //!< Original module instantiation ctx if this ///< xlat was registered by a module. xlat_instantiate_t instantiate; //!< Instantiation function. diff --git a/src/modules/rlm_always/rlm_always.c b/src/modules/rlm_always/rlm_always.c index a80f04cc02b..46f1131c9df 100644 --- a/src/modules/rlm_always/rlm_always.c +++ b/src/modules/rlm_always/rlm_always.c @@ -174,7 +174,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) { xlat_t *xlat; - xlat = xlat_func_register_module(mctx->mi->boot, mctx, NULL, always_xlat, FR_TYPE_STRING); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, NULL, always_xlat, FR_TYPE_STRING); xlat_func_args_set(xlat, always_xlat_args); return 0; diff --git a/src/modules/rlm_brotli/rlm_brotli.c b/src/modules/rlm_brotli/rlm_brotli.c index c4e1a685037..7b3928c1318 100644 --- a/src/modules/rlm_brotli/rlm_brotli.c +++ b/src/modules/rlm_brotli/rlm_brotli.c @@ -383,11 +383,11 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) { xlat_t *xlat; - if (unlikely((xlat = xlat_func_register_module(mctx->mi->boot, mctx, "compress", brotli_xlat_compress, + if (unlikely((xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "compress", brotli_xlat_compress, FR_TYPE_OCTETS)) == NULL)) return -1; xlat_func_args_set(xlat, brotli_xlat_compress_args); - if (unlikely((xlat = xlat_func_register_module(mctx->mi->boot, mctx, "decompress", brotli_xlat_decompress, + if (unlikely((xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "decompress", brotli_xlat_decompress, FR_TYPE_OCTETS)) == NULL)) return -1; xlat_func_args_set(xlat, brotli_xlat_decompress_args); diff --git a/src/modules/rlm_cache/rlm_cache.c b/src/modules/rlm_cache/rlm_cache.c index 999dd4281c3..ccf92aec442 100644 --- a/src/modules/rlm_cache/rlm_cache.c +++ b/src/modules/rlm_cache/rlm_cache.c @@ -1487,11 +1487,11 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) /* * Register the cache xlat function */ - xlat = xlat_func_register_module(mctx->mi->boot, mctx, NULL, cache_xlat, FR_TYPE_VOID); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, NULL, cache_xlat, FR_TYPE_VOID); xlat_func_args_set(xlat, cache_xlat_args); xlat_func_call_env_set(xlat, &cache_method_env); - xlat = xlat_func_register_module(mctx->mi->boot, mctx, "ttl.get", cache_ttl_get_xlat, FR_TYPE_VOID); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "ttl.get", cache_ttl_get_xlat, FR_TYPE_VOID); xlat_func_call_env_set(xlat, &cache_method_env); return 0; diff --git a/src/modules/rlm_chap/rlm_chap.c b/src/modules/rlm_chap/rlm_chap.c index 3dc3476051b..3d2c63aa2a3 100644 --- a/src/modules/rlm_chap/rlm_chap.c +++ b/src/modules/rlm_chap/rlm_chap.c @@ -361,7 +361,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) { xlat_t *xlat; - if (unlikely((xlat = xlat_func_register_module(mctx->mi->boot, mctx, "password", xlat_func_chap_password, + if (unlikely((xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "password", xlat_func_chap_password, FR_TYPE_OCTETS)) == NULL)) return -1; xlat_func_args_set(xlat, xlat_func_chap_password_args); xlat_func_call_env_set(xlat, &chap_xlat_method_env); diff --git a/src/modules/rlm_cipher/rlm_cipher.c b/src/modules/rlm_cipher/rlm_cipher.c index b02fbc4cdbc..92098d6c842 100644 --- a/src/modules/rlm_cipher/rlm_cipher.c +++ b/src/modules/rlm_cipher/rlm_cipher.c @@ -1299,13 +1299,13 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) /* * Register decrypt xlat */ - xlat = xlat_func_register_module(mctx->mi->boot, mctx, "decrypt", cipher_rsa_decrypt_xlat, FR_TYPE_STRING); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "decrypt", cipher_rsa_decrypt_xlat, FR_TYPE_STRING); xlat_func_args_set(xlat, cipher_rsa_decrypt_xlat_arg); /* * Verify sign xlat */ - xlat = xlat_func_register_module(mctx->mi->boot, mctx, "verify", cipher_rsa_verify_xlat, FR_TYPE_BOOL); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "verify", cipher_rsa_verify_xlat, FR_TYPE_BOOL); xlat_func_args_set(xlat, cipher_rsa_verify_xlat_arg); } @@ -1331,20 +1331,20 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) /* * Register encrypt xlat */ - xlat = xlat_func_register_module(mctx->mi->boot, mctx, "encrypt", cipher_rsa_encrypt_xlat, FR_TYPE_OCTETS); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "encrypt", cipher_rsa_encrypt_xlat, FR_TYPE_OCTETS); xlat_func_args_set(xlat, cipher_rsa_encrypt_xlat_arg); /* * Register sign xlat */ - xlat = xlat_func_register_module(mctx->mi->boot, mctx, "sign", cipher_rsa_sign_xlat, FR_TYPE_OCTETS); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "sign", cipher_rsa_sign_xlat, FR_TYPE_OCTETS); xlat_func_args_set(xlat, cipher_rsa_sign_xlat_arg); /* * FIXME: These should probably be split into separate xlats * so we can optimise for return types. */ - xlat = xlat_func_register_module(mctx->mi->boot, mctx, "certificate", cipher_certificate_xlat, FR_TYPE_VOID); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "certificate", cipher_certificate_xlat, FR_TYPE_VOID); xlat_func_args_set(xlat, cipher_certificate_xlat_args); } break; diff --git a/src/modules/rlm_date/rlm_date.c b/src/modules/rlm_date/rlm_date.c index 005aa010e02..ff8ac7d6699 100644 --- a/src/modules/rlm_date/rlm_date.c +++ b/src/modules/rlm_date/rlm_date.c @@ -233,7 +233,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) { xlat_t *xlat; - xlat = xlat_func_register_module(mctx->mi->boot, mctx, NULL, xlat_date_convert, FR_TYPE_VOID); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, NULL, xlat_date_convert, FR_TYPE_VOID); xlat_func_args_set(xlat, xlat_date_convert_args); return 0; diff --git a/src/modules/rlm_delay/rlm_delay.c b/src/modules/rlm_delay/rlm_delay.c index d37ec641b7c..2cdb2b6fc7a 100644 --- a/src/modules/rlm_delay/rlm_delay.c +++ b/src/modules/rlm_delay/rlm_delay.c @@ -264,7 +264,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) { xlat_t *xlat; - xlat = xlat_func_register_module(mctx->mi->boot, mctx, NULL, xlat_delay, FR_TYPE_TIME_DELTA); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, NULL, xlat_delay, FR_TYPE_TIME_DELTA); xlat_func_args_set(xlat, xlat_delay_args); return 0; } diff --git a/src/modules/rlm_escape/rlm_escape.c b/src/modules/rlm_escape/rlm_escape.c index 29c2732723c..4a9d6b2cb06 100644 --- a/src/modules/rlm_escape/rlm_escape.c +++ b/src/modules/rlm_escape/rlm_escape.c @@ -195,11 +195,11 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) { xlat_t *xlat; - xlat = xlat_func_register_module(mctx->mi->boot, mctx, "escape", escape_xlat, FR_TYPE_STRING); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "escape", escape_xlat, FR_TYPE_STRING); xlat_func_args_set(xlat, escape_xlat_arg); xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE); - xlat = xlat_func_register_module(mctx->mi->boot, mctx, "unescape", unescape_xlat, FR_TYPE_STRING); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "unescape", unescape_xlat, FR_TYPE_STRING); xlat_func_args_set(xlat, unescape_xlat_arg); xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE); diff --git a/src/modules/rlm_exec/rlm_exec.c b/src/modules/rlm_exec/rlm_exec.c index 2463afe9a0c..34f2af4a903 100644 --- a/src/modules/rlm_exec/rlm_exec.c +++ b/src/modules/rlm_exec/rlm_exec.c @@ -506,7 +506,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) { xlat_t *xlat; - xlat = xlat_func_register_module(mctx->mi->boot, mctx, NULL, exec_xlat_oneshot, FR_TYPE_STRING); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, NULL, exec_xlat_oneshot, FR_TYPE_STRING); xlat_func_args_set(xlat, exec_xlat_args); return 0; diff --git a/src/modules/rlm_icmp/rlm_icmp.c b/src/modules/rlm_icmp/rlm_icmp.c index 852e0258b4c..fc972abb18b 100644 --- a/src/modules/rlm_icmp/rlm_icmp.c +++ b/src/modules/rlm_icmp/rlm_icmp.c @@ -519,7 +519,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) { xlat_t *xlat; - xlat = xlat_func_register_module(mctx->mi->boot, mctx, NULL, xlat_icmp, FR_TYPE_BOOL); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, NULL, xlat_icmp, FR_TYPE_BOOL); xlat_func_args_set(xlat, xlat_icmp_args); return 0; diff --git a/src/modules/rlm_idn/rlm_idn.c b/src/modules/rlm_idn/rlm_idn.c index 7f79f52d0e1..2a81a4fb3bc 100644 --- a/src/modules/rlm_idn/rlm_idn.c +++ b/src/modules/rlm_idn/rlm_idn.c @@ -152,7 +152,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) { xlat_t *xlat; - xlat = xlat_func_register_module(mctx->mi->boot, mctx, NULL, xlat_idna, FR_TYPE_STRING); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, NULL, xlat_idna, FR_TYPE_STRING); xlat_func_args_set(xlat, xlat_idna_arg); xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE); diff --git a/src/modules/rlm_json/rlm_json.c b/src/modules/rlm_json/rlm_json.c index 9508b2fc8e3..8cc447c7d89 100644 --- a/src/modules/rlm_json/rlm_json.c +++ b/src/modules/rlm_json/rlm_json.c @@ -576,7 +576,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) rlm_json_t const *inst = talloc_get_type_abort(mctx->mi->data, rlm_json_t); xlat_t *xlat; - xlat = xlat_func_register_module(mctx->mi->boot, mctx, "encode", json_encode_xlat, FR_TYPE_STRING); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "encode", json_encode_xlat, FR_TYPE_STRING); xlat_func_args_set(xlat, json_encode_xlat_arg); if (map_proc_register(mctx->mi->boot, inst, "json", mod_map_proc, diff --git a/src/modules/rlm_ldap/rlm_ldap.c b/src/modules/rlm_ldap/rlm_ldap.c index 0e4e3631bef..2319938300a 100644 --- a/src/modules/rlm_ldap/rlm_ldap.c +++ b/src/modules/rlm_ldap/rlm_ldap.c @@ -2663,15 +2663,15 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) boot->cache_da = boot->group_da; /* Default to the group_da */ } - xlat = xlat_func_register_module(mctx->mi->boot, mctx, NULL, ldap_xlat, FR_TYPE_STRING); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, NULL, ldap_xlat, FR_TYPE_STRING); xlat_func_args_set(xlat, ldap_xlat_arg); - if (unlikely(!(xlat = xlat_func_register_module(mctx->mi->boot, mctx, "memberof", ldap_memberof_xlat, + if (unlikely(!(xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "memberof", ldap_memberof_xlat, FR_TYPE_BOOL)))) return -1; xlat_func_args_set(xlat, ldap_memberof_xlat_arg); xlat_func_call_env_set(xlat, &xlat_memberof_method_env); - if (unlikely(!(xlat = xlat_func_register_module(mctx->mi->boot, mctx, "profile", ldap_profile_xlat, + if (unlikely(!(xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "profile", ldap_profile_xlat, FR_TYPE_BOOL)))) return -1; xlat_func_args_set(xlat, ldap_xlat_arg); xlat_func_call_env_set(xlat, &xlat_profile_method_env); diff --git a/src/modules/rlm_linelog/rlm_linelog.c b/src/modules/rlm_linelog/rlm_linelog.c index a76b2dd4f75..7207f935233 100644 --- a/src/modules/rlm_linelog/rlm_linelog.c +++ b/src/modules/rlm_linelog/rlm_linelog.c @@ -1040,7 +1040,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) XLAT_ARG_PARSER_TERMINATOR }; - xlat = xlat_func_register_module(mctx->mi->boot, mctx, NULL, linelog_xlat, FR_TYPE_SIZE); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, NULL, linelog_xlat, FR_TYPE_SIZE); xlat_func_args_set(xlat, linelog_xlat_args); xlat_func_call_env_set(xlat, &linelog_xlat_method_env ); diff --git a/src/modules/rlm_mschap/rlm_mschap.c b/src/modules/rlm_mschap/rlm_mschap.c index 57e15001f5d..9a7259e42f7 100644 --- a/src/modules/rlm_mschap/rlm_mschap.c +++ b/src/modules/rlm_mschap/rlm_mschap.c @@ -2490,7 +2490,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) { xlat_t *xlat; - xlat = xlat_func_register_module(mctx->mi->boot, mctx, NULL, mschap_xlat, FR_TYPE_VOID); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, NULL, mschap_xlat, FR_TYPE_VOID); xlat_func_args_set(xlat, mschap_xlat_args); xlat_func_call_env_set(xlat, &mschap_xlat_method_env); diff --git a/src/modules/rlm_perl/rlm_perl.c b/src/modules/rlm_perl/rlm_perl.c index 53a7e9e799d..6b08a7cfdf5 100644 --- a/src/modules/rlm_perl/rlm_perl.c +++ b/src/modules/rlm_perl/rlm_perl.c @@ -1102,7 +1102,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) { xlat_t *xlat; - xlat = xlat_func_register_module(mctx->mi->boot, mctx, NULL, perl_xlat, FR_TYPE_VOID); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, NULL, perl_xlat, FR_TYPE_VOID); xlat_func_args_set(xlat, perl_xlat_args); return 0; diff --git a/src/modules/rlm_redis/rlm_redis.c b/src/modules/rlm_redis/rlm_redis.c index 8738b91bc79..a393f98a94b 100644 --- a/src/modules/rlm_redis/rlm_redis.c +++ b/src/modules/rlm_redis/rlm_redis.c @@ -863,16 +863,16 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) rlm_redis_t const *inst = talloc_get_type_abort(mctx->mi->data, rlm_redis_t); xlat_t *xlat; - xlat = xlat_func_register_module(mctx->mi->boot, mctx, NULL, redis_xlat, FR_TYPE_VOID); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, NULL, redis_xlat, FR_TYPE_VOID); xlat_func_args_set(xlat, redis_args); /* * %redis.node([, idx]) */ - if (unlikely((xlat = xlat_func_register_module(mctx->mi->boot, mctx, "node", redis_node_xlat, FR_TYPE_STRING)) == NULL)) return -1; + if (unlikely((xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "node", redis_node_xlat, FR_TYPE_STRING)) == NULL)) return -1; xlat_func_args_set(xlat, redis_node_xlat_args); - if (unlikely((xlat = xlat_func_register_module(mctx->mi->boot, mctx, "remap", redis_remap_xlat, FR_TYPE_STRING)) == NULL)) return -1; + if (unlikely((xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "remap", redis_remap_xlat, FR_TYPE_STRING)) == NULL)) return -1; xlat_func_args_set(xlat, redis_remap_xlat_args); /* @@ -880,7 +880,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) * that'll call that function specifically. */ talloc_foreach(inst->lua.funcs, func) { - if (unlikely((xlat = xlat_func_register_module(mctx->mi->boot, mctx, func->name, redis_lua_func_xlat, FR_TYPE_VOID)) == NULL)) return -1; + if (unlikely((xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, func->name, redis_lua_func_xlat, FR_TYPE_VOID)) == NULL)) return -1; xlat_func_args_set(xlat, redis_lua_func_args); xlat_func_instantiate_set(xlat, redis_lua_func_instantiate, redis_lua_func_inst_t, NULL, func); } diff --git a/src/modules/rlm_rest/rlm_rest.c b/src/modules/rlm_rest/rlm_rest.c index 3482463dcc9..323dac69d51 100644 --- a/src/modules/rlm_rest/rlm_rest.c +++ b/src/modules/rlm_rest/rlm_rest.c @@ -1363,7 +1363,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) { xlat_t *xlat; - xlat = xlat_func_register_module(mctx->mi->boot, mctx, NULL, rest_xlat, FR_TYPE_STRING); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, NULL, rest_xlat, FR_TYPE_STRING); xlat_func_args_set(xlat, rest_xlat_args); xlat_func_call_env_set(xlat, &rest_call_env_xlat); diff --git a/src/modules/rlm_sql/rlm_sql.c b/src/modules/rlm_sql/rlm_sql.c index 2c68ff5e804..2bc7858942d 100644 --- a/src/modules/rlm_sql/rlm_sql.c +++ b/src/modules/rlm_sql/rlm_sql.c @@ -2179,7 +2179,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) * register function automatically adds the * module instance name as a prefix. */ - xlat = xlat_func_register_module(boot, mctx, "group", sql_group_xlat, FR_TYPE_BOOL); + xlat = module_rlm_xlat_register(boot, mctx, "group", sql_group_xlat, FR_TYPE_BOOL); if (!xlat) { cf_log_perr(conf, "Failed registering %s expansion", group_attribute); return -1; @@ -2204,7 +2204,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) /* * Register the SQL xlat function */ - xlat = xlat_func_register_module(boot, mctx, NULL, sql_xlat, FR_TYPE_VOID); /* Returns an integer sometimes */ + xlat = module_rlm_xlat_register(boot, mctx, NULL, sql_xlat, FR_TYPE_VOID); /* Returns an integer sometimes */ if (!xlat) { cf_log_perr(conf, "Failed registering %s expansion", mctx->mi->name); return -1; diff --git a/src/modules/rlm_test/rlm_test.c b/src/modules/rlm_test/rlm_test.c index 369ca2a7589..c1b2845a775 100644 --- a/src/modules/rlm_test/rlm_test.c +++ b/src/modules/rlm_test/rlm_test.c @@ -480,10 +480,10 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) INFO("inst->tmpl_m is NULL"); } - if (!(xlat = xlat_func_register_module(mctx->mi->boot, mctx, "passthrough", test_xlat_passthrough, FR_TYPE_VOID))) return -1; + if (!(xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "passthrough", test_xlat_passthrough, FR_TYPE_VOID))) return -1; xlat_func_args_set(xlat, test_xlat_passthrough_args); - if (!(xlat = xlat_func_register_module(mctx->mi->boot, mctx, "fail", test_xlat_fail, FR_TYPE_VOID))) return -1; + if (!(xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "fail", test_xlat_fail, FR_TYPE_VOID))) return -1; xlat_func_args_set(xlat, test_xlat_fail_args); return 0; diff --git a/src/modules/rlm_unbound/rlm_unbound.c b/src/modules/rlm_unbound/rlm_unbound.c index fa0dcd08703..14a4371bf4a 100644 --- a/src/modules/rlm_unbound/rlm_unbound.c +++ b/src/modules/rlm_unbound/rlm_unbound.c @@ -493,7 +493,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) return -1; } - if(!(xlat = xlat_func_register_module(mctx->mi->boot, mctx, NULL, xlat_unbound, FR_TYPE_VOID))) return -1; + if(!(xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, NULL, xlat_unbound, FR_TYPE_VOID))) return -1; xlat_func_args_set(xlat, xlat_unbound_args); return 0; diff --git a/src/modules/rlm_unix/rlm_unix.c b/src/modules/rlm_unix/rlm_unix.c index f7f19a154f1..8b9abb1ff5a 100644 --- a/src/modules/rlm_unix/rlm_unix.c +++ b/src/modules/rlm_unix/rlm_unix.c @@ -190,7 +190,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) * function automatically adds the module instance name * as a prefix. */ - xlat = xlat_func_register_module(mctx->mi->boot, mctx, "group", unix_group_xlat, FR_TYPE_BOOL); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "group", unix_group_xlat, FR_TYPE_BOOL); if (!xlat) { PERROR("Failed registering group expansion"); return -1; diff --git a/src/modules/rlm_winbind/rlm_winbind.c b/src/modules/rlm_winbind/rlm_winbind.c index f878efc418c..688982fd485 100644 --- a/src/modules/rlm_winbind/rlm_winbind.c +++ b/src/modules/rlm_winbind/rlm_winbind.c @@ -545,7 +545,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) * function automatically adds the module instance name * as a prefix. */ - xlat = xlat_func_register_module(mctx->mi->boot, mctx, "group", winbind_group_xlat, FR_TYPE_BOOL); + xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "group", winbind_group_xlat, FR_TYPE_BOOL); if (!xlat) { cf_log_err(conf, "Failed registering group expansion"); return -1;