]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Move module xlat registrations into the module code
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 1 Jun 2024 01:29:04 +0000 (19:29 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 8 Jun 2024 19:11:00 +0000 (15:11 -0400)
33 files changed:
src/lib/io/master.h
src/lib/server/module.c
src/lib/server/module.h
src/lib/server/module_ctx.h
src/lib/server/module_rlm.c
src/lib/server/module_rlm.h
src/lib/unlang/module_priv.h
src/lib/unlang/xlat_func.c
src/lib/unlang/xlat_func.h
src/lib/unlang/xlat_priv.h
src/modules/rlm_always/rlm_always.c
src/modules/rlm_brotli/rlm_brotli.c
src/modules/rlm_cache/rlm_cache.c
src/modules/rlm_chap/rlm_chap.c
src/modules/rlm_cipher/rlm_cipher.c
src/modules/rlm_date/rlm_date.c
src/modules/rlm_delay/rlm_delay.c
src/modules/rlm_escape/rlm_escape.c
src/modules/rlm_exec/rlm_exec.c
src/modules/rlm_icmp/rlm_icmp.c
src/modules/rlm_idn/rlm_idn.c
src/modules/rlm_json/rlm_json.c
src/modules/rlm_ldap/rlm_ldap.c
src/modules/rlm_linelog/rlm_linelog.c
src/modules/rlm_mschap/rlm_mschap.c
src/modules/rlm_perl/rlm_perl.c
src/modules/rlm_redis/rlm_redis.c
src/modules/rlm_rest/rlm_rest.c
src/modules/rlm_sql/rlm_sql.c
src/modules/rlm_test/rlm_test.c
src/modules/rlm_unbound/rlm_unbound.c
src/modules/rlm_unix/rlm_unix.c
src/modules/rlm_winbind/rlm_winbind.c

index dcd57485c420f7946e54c6af239ef04135712617..b529dc111611d22530837d001975acb7b307a55d 100644 (file)
@@ -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.
index 489be1f37599ad574566ff1c057197bdd88c395f..3f9a0da17fa79cc6183a86627da59159e2910c7d 100644 (file)
@@ -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
  *
index f4115b3f3f102ad5867e3c8c486e65254d9345ad..9ae74d4ac2a789167aa812171cb6366842e2f338 100644 (file)
@@ -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.
 /** @} */
 
index ac5e32f79bd42d5f0f592e0044ed299c1ee5aacc..1db004302cc4620d69a8ece0a5fdbb22f1ca6a86 100644 (file)
@@ -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
index 7c19c6571a49e994d6161901ed06d84ef30e8fe3..c52826050656d2975d1cab97dcfc5ea159d882fa 100644 (file)
@@ -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;
index fd175057cae2f5192082b68d1244f3e65d599917..75b0e95cb3baa64986b141794f6e45a68480133a 100644 (file)
@@ -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 <freeradius-devel/server/module.h>
 #include <freeradius-devel/server/virtual_servers.h>
 
-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
index 401513198326680b272dd994f2e1cb12404d14da..4685075f548f3525501c8722ddc35b3a33ccb73a 100644 (file)
@@ -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
index 9434a925f10d53dbdc5dfef8ab82e88362b90ccb..995ad57848e30d8069340ecb63cd741f32d17046 100644 (file)
@@ -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;
index e5b8a26b12fffe822cc34c9c0ac91b073a09f3f5..96d4439571d1e8a92cd8306cbbe94a4bb22b0f6e 100644 (file)
@@ -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);
index bdf7ab068ec85e73d93f5828e9eaec0a6a36260b..2f120137c794f2ce84d4a30cb9caa706f15ba897 100644 (file)
@@ -33,6 +33,7 @@ extern "C" {
 #include <freeradius-devel/unlang/xlat_ctx.h>
 #include <freeradius-devel/unlang/xlat.h>
 #include <freeradius-devel/unlang/xlat_func.h>
+#include <freeradius-devel/server/module_ctx.h>
 #include <freeradius-devel/io/pair.h>
 #include <freeradius-devel/util/talloc.h>
 #include <freeradius-devel/build.h>
@@ -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.
index a80f04cc02bd20105c83cfb3161fd630e9aef2f6..46f1131c9dfa25ae8cce6cb5c98353438bd35506 100644 (file)
@@ -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;
index c4e1a685037167b3ee53f09d67aca1c520d58580..7b3928c13189dbc7d818be506d729cc2f74c4811 100644 (file)
@@ -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);
 
index 999dd4281c3ae632f614e58b0eeecceb32ebc756..ccf92aec4420d1590c28416a1c287611d5564f0f 100644 (file)
@@ -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;
index 3dc3476051b0659fd3b95321180cf8e624cd7e49..3d2c63aa2a3ad957522edd95371dcaea53e0a4f7 100644 (file)
@@ -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);
index b02fbc4cdbc5e0d41b6199e64a1addcc75a0f29a..92098d6c8425197cf0a65f87903cb81ea8d6353d 100644 (file)
@@ -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;
index 005aa010e02b7da7bdcc98f362d02383a2af8091..ff8ac7d66991e77b455370cfd0aaf6b5aac17855 100644 (file)
@@ -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;
index d37ec641b7cad9a36976a4ba2fb343fbaa03c1a4..2cdb2b6fc7ace42e6ef934c9b94ad08d12a5d6c4 100644 (file)
@@ -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;
 }
index 29c2732723c6470f8ef173a633918f410875875e..4a9d6b2cb0673e0aadc59954b4705abb9c329658 100644 (file)
@@ -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);
 
index 2463afe9a0cb6c573db59fc7047d6fa06c7b63ba..34f2af4a9037f3dbcf452f0b9268ad4ce030c1a1 100644 (file)
@@ -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;
index 852e0258b4c99ce1edb54296e36b2844c7bb2f3e..fc972abb18b9dcbdb4595c20d9d9870bae0b13fb 100644 (file)
@@ -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;
index 7f79f52d0e1657e0269b02aafca0525b05bd57fb..2a81a4fb3bcc34c3f7b450aa3f06a2628d63fd3f 100644 (file)
@@ -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);
 
index 9508b2fc8e32dbe62213f1c390f24cb70b5fea7a..8cc447c7d890b2870d66730ab44ea78371ef73f7 100644 (file)
@@ -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,
index 0e4e3631bef56832bab260575e3d424110f02968..2319938300a2174d3a37da8be4a0099cc390e6b3 100644 (file)
@@ -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);
index a76b2dd4f75416c807faa0d0438c37e73d1a1169..7207f935233b4641f63cf73b62c26d5f41af7f95 100644 (file)
@@ -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 );
 
index 57e15001f5d4d9d1a7c03f52f349d31ad64ff0c8..9a7259e42f72e9b9ec5579289ca0dc81a99b34ec 100644 (file)
@@ -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);
 
index 53a7e9e799dab4e4d0dae423ab95add966df6eed..6b08a7cfdf54969e4805517ec468f304b794535f 100644 (file)
@@ -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;
index 8738b91bc79e89104fb17534bf717972b5d3060c..a393f98a94b4a32ca24ecc1c59adc2e0c5b668df 100644 (file)
@@ -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(<key>[, 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);
        }
index 3482463dcc9915d0f744cba44b9bd450aa7a62ef..323dac69d5168a10ecbefde348a41e146d8865d7 100644 (file)
@@ -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);
 
index 2c68ff5e804fa7cfbbfa9dcd0bc23585c395200b..2bc7858942df03206ae6ac7ae596d63ca27ff406 100644 (file)
@@ -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;
index 369ca2a7589ae33227226f5c747c33f135d0b4d6..c1b2845a77538da22542881d336345e15de064d6 100644 (file)
@@ -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;
index fa0dcd08703cb01c2ad708d0780621a438ba4552..14a4371bf4a4ef91a23980d43956188a8af52813 100644 (file)
@@ -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;
index f7f19a154f1733b0918c9b7394b895fcb3827a7b..8b9abb1ff5ae11db9442ca9aaf51c61961c1ff14 100644 (file)
@@ -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;
index f878efc418c48f1aad22c4505d0c5977eaf2f52c..688982fd48532c696eed580c1eccc1a545d64e07 100644 (file)
@@ -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;