]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
unify to inst->name, instead of inst->xlat_name
authorAlan T. DeKok <aland@freeradius.org>
Mon, 8 Nov 2021 16:47:11 +0000 (11:47 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 8 Nov 2021 16:47:11 +0000 (11:47 -0500)
18 files changed:
src/modules/rlm_always/rlm_always.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_dhcpv4/rlm_dhcpv4.c
src/modules/rlm_escape/rlm_escape.c
src/modules/rlm_expr/rlm_expr.c
src/modules/rlm_icmp/rlm_icmp.c
src/modules/rlm_idn/rlm_idn.c
src/modules/rlm_lua/lua.c
src/modules/rlm_lua/lua.h
src/modules/rlm_lua/rlm_lua.c
src/modules/rlm_lua/util.c
src/modules/rlm_perl/rlm_perl.c
src/modules/rlm_rest/rest.c
src/modules/rlm_rest/rest.h
src/modules/rlm_rest/rlm_rest.c
src/modules/rlm_soh/rlm_soh.c

index 0af6bcee4167bed5435a076d7dc6c3654ef42309..153270e02689da7f6921715435e3cacbf214f477 100644 (file)
@@ -35,8 +35,9 @@ RCSID("$Id$")
  *     going to return.
  */
 typedef struct {
-       char const      *xlat_name;
+       char const      *name;
        char const      *rcode_str;     //!< The base value.
+       module_instance_t *mi;
 
        rlm_rcode_t     rcode;          //!< The integer constant representing rcode_str.
        uint32_t        simulcount;
@@ -77,18 +78,12 @@ static xlat_action_t always_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
                                 fr_value_box_list_t *in)
 {
        rlm_always_t const      *inst = talloc_get_type_abort_const(*((void const * const *)xlat_inst),rlm_always_t);
-       module_instance_t       *mi;
+       module_instance_t       *mi = inst->mi;
        char const              *status;
        char const              *p;
        fr_value_box_t          *vb;
        fr_value_box_t          *in_head = fr_dlist_head(in);
 
-       mi = module_by_name(NULL, inst->xlat_name);
-       if (!mi) {
-               RERROR("Can't find the module that registered this xlat: %s", inst->xlat_name);
-               return XLAT_ACTION_FAIL;
-       }
-
        /*
         *      Expand to the existing status
         */
@@ -134,12 +129,17 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        rlm_always_t    *inst = instance;
        xlat_t          *xlat;
 
-       inst->xlat_name = cf_section_name2(conf);
-       if (!inst->xlat_name) {
-               inst->xlat_name = cf_section_name1(conf);
+       inst->name = cf_section_name2(conf);
+       if (!inst->name) inst->name = cf_section_name1(conf);
+
+       inst->mi = module_by_name(NULL, inst->name);
+       if (!inst->mi) {
+               cf_log_err(conf, "Can't find the module instance data for this module: %s", inst->name);
+               return -1;
        }
 
-       xlat = xlat_register(inst, inst->xlat_name, always_xlat, false);
+
+       xlat = xlat_register(inst, inst->name, always_xlat, false);
        xlat_func_args(xlat, always_xlat_args);
        xlat_async_instantiate_set(xlat, always_xlat_instantiate, rlm_always_t *, NULL, inst);
 
index 46329f07306b0f70affb9dc48b7e1e5c158f1f10..7ec2a915870670b62991ee950622016c45a80198 100644 (file)
@@ -176,7 +176,7 @@ typedef struct {
  *
  */
 typedef struct {
-       char const              *xlat_name;                     //!< Name of xlat we registered.
+       char const              *name;                  //!< Name of xlat we registered.
        cipher_type_t           type;                           //!< Type of encryption to use.
 
        /** Supported cipher types
@@ -1311,8 +1311,8 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
 {
        rlm_cipher_t    *inst = talloc_get_type_abort(instance, rlm_cipher_t);
 
-       inst->xlat_name = cf_section_name2(conf);
-       if (!inst->xlat_name) inst->xlat_name = cf_section_name1(conf);
+       inst->name = cf_section_name2(conf);
+       if (!inst->name) inst->name = cf_section_name1(conf);
 
        switch (inst->type) {
        case RLM_CIPHER_TYPE_RSA:
@@ -1334,7 +1334,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
                        /*
                         *      Register decrypt xlat
                         */
-                       xlat_name = talloc_asprintf(inst, "%s_decrypt", inst->xlat_name);
+                       xlat_name = talloc_asprintf(inst, "%s_decrypt", inst->name);
                        xlat = xlat_register(inst, xlat_name, cipher_rsa_decrypt_xlat, false);
                        xlat_func_mono(xlat, &cipher_rsa_decrypt_xlat_arg);
                        xlat_async_instantiate_set(xlat, cipher_xlat_instantiate,
@@ -1351,7 +1351,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
                        /*
                         *      Verify sign xlat
                         */
-                       xlat_name = talloc_asprintf(inst, "%s_verify", inst->xlat_name);
+                       xlat_name = talloc_asprintf(inst, "%s_verify", inst->name);
                        xlat = xlat_register(inst, xlat_name, cipher_rsa_verify_xlat, false);
                        xlat_func_args(xlat, cipher_rsa_verify_xlat_arg);
                        xlat_async_instantiate_set(xlat, cipher_xlat_instantiate,
@@ -1389,7 +1389,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
                        /*
                         *      Register encrypt xlat
                         */
-                       xlat_name = talloc_asprintf(inst, "%s_encrypt", inst->xlat_name);
+                       xlat_name = talloc_asprintf(inst, "%s_encrypt", inst->name);
                        xlat = xlat_register(inst, xlat_name, cipher_rsa_encrypt_xlat, false);
                        xlat_func_mono(xlat, &cipher_rsa_encrypt_xlat_arg);
                        xlat_async_instantiate_set(xlat, cipher_xlat_instantiate,
@@ -1405,7 +1405,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
                        /*
                         *      Register sign xlat
                         */
-                       xlat_name = talloc_asprintf(inst, "%s_sign", inst->xlat_name);
+                       xlat_name = talloc_asprintf(inst, "%s_sign", inst->name);
                        xlat = xlat_register(inst, xlat_name, cipher_rsa_sign_xlat, false);
                        xlat_func_mono(xlat, &cipher_rsa_sign_xlat_arg);
                        xlat_async_instantiate_set(xlat, cipher_xlat_instantiate,
@@ -1418,7 +1418,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
                                                          inst);
                        talloc_free(xlat_name);
 
-                       xlat_name = talloc_asprintf(inst, "%s_certificate", inst->xlat_name);
+                       xlat_name = talloc_asprintf(inst, "%s_certificate", inst->name);
                        xlat = xlat_register(inst, xlat_name, cipher_certificate_xlat, false);
                        xlat_func_args(xlat, cipher_certificate_xlat_args);
                        xlat_async_instantiate_set(xlat, cipher_xlat_instantiate,
index 505a143c0a57341c3131b7dda8c8b92fa666eaed..8d46e87830d24a716445fa0a667334f6bbf92ae2 100644 (file)
@@ -30,7 +30,7 @@
 #include <time.h>
 
 typedef struct {
-       char const *xlat_name;
+       char const *name;
        char const *fmt;
        bool utc;
 } rlm_date_t;
@@ -236,12 +236,10 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        rlm_date_t      *inst = instance;
        xlat_t          *xlat;
 
-       inst->xlat_name = cf_section_name2(conf);
-       if (!inst->xlat_name) {
-               inst->xlat_name = cf_section_name1(conf);
-       }
+       inst->name = cf_section_name2(conf);
+       if (!inst->name) inst->name = cf_section_name1(conf);
 
-       xlat = xlat_register(inst, inst->xlat_name, xlat_date_convert, false);
+       xlat = xlat_register(inst, inst->name, xlat_date_convert, false);
        xlat_func_args(xlat,xlat_date_convert_args);
        xlat_async_instantiate_set(xlat, mod_xlat_instantiate, rlm_date_t *, NULL, inst);
 
index 65cfbeb478200b865405da3eb3a7e956fbaa090f..b61fa740907bbc2b8501fc919757c98e8b2c2b05 100644 (file)
@@ -31,7 +31,7 @@ RCSID("$Id$")
 #include <freeradius-devel/util/time.h>
 
 typedef struct {
-       char const      *xlat_name;             //!< Name of our xlat function.
+       char const      *name;          //!< Name of our xlat function.
        tmpl_t  *delay;                 //!< How long we delay for.
        bool            relative;               //!< Whether the delay is relative to the start of request processing.
        bool            force_reschedule;       //!< Whether we should force rescheduling of the request.
@@ -280,10 +280,10 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        rlm_delay_t     *inst = instance;
        xlat_t          *xlat;
 
-       inst->xlat_name = cf_section_name2(conf);
-       if (!inst->xlat_name) inst->xlat_name = cf_section_name1(conf);
+       inst->name = cf_section_name2(conf);
+       if (!inst->name) inst->name = cf_section_name1(conf);
 
-       xlat = xlat_register(inst, inst->xlat_name, xlat_delay, true);
+       xlat = xlat_register(inst, inst->name, xlat_delay, true);
        xlat_func_args(xlat, xlat_delay_args);
        xlat_async_instantiate_set(xlat, mod_xlat_instantiate, rlm_delay_t *, NULL, inst);
        return 0;
index 9100702d26f8c463393311123b9158df80849b86..704100f0eb6a8e91e153ea54c48836896a2777f4 100644 (file)
@@ -71,7 +71,6 @@ fr_dict_attr_autoload_t rlm_dhcpv4_dict_attr[] = {
  */
 typedef struct {
        char const              *name;
-       char const              *xlat_name;
 
        fr_udp_queue_config_t   config;         //!< UDP queue config
 
@@ -117,9 +116,8 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
 {
        rlm_dhcpv4_t    *inst = talloc_get_type_abort(instance, rlm_dhcpv4_t);
 
-       inst->xlat_name = cf_section_name2(conf);
-       if (!inst->xlat_name) inst->xlat_name = cf_section_name1(conf);
-       inst->name = inst->xlat_name;
+       inst->name = cf_section_name2(conf);
+       if (!inst->name) inst->name = cf_section_name1(conf);
 
        /*
         *      Ensure that we have a destination address.
index a124772aee522f0addbe5870c70f40fc5708c043..810fac09fdca0fa174e8dbb658240b3de5229454 100644 (file)
@@ -35,7 +35,7 @@ USES_APPLE_DEPRECATED_API
  *     Define a structure for our module configuration.
  */
 typedef struct {
-       char const *xlat_name;
+       char const *name;
        char const *allowed_chars;
 } rlm_escape_t;
 
@@ -199,13 +199,11 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        char            *unescape;
        xlat_t          *xlat;
 
-       inst->xlat_name = cf_section_name2(conf);
-       if (!inst->xlat_name) {
-               inst->xlat_name = cf_section_name1(conf);
-       }
+       inst->name = cf_section_name2(conf);
+       if (!inst->name) inst->name = cf_section_name1(conf);
 
-       MEM(unescape = talloc_asprintf(NULL, "un%s", inst->xlat_name));
-       xlat = xlat_register(NULL, inst->xlat_name, escape_xlat, false);
+       MEM(unescape = talloc_asprintf(NULL, "un%s", inst->name));
+       xlat = xlat_register(NULL, inst->name, escape_xlat, false);
        xlat_func_mono(xlat, &escape_xlat_arg);
        xlat_async_instantiate_set(xlat, mod_xlat_instantiate, rlm_escape_t *, NULL, inst);
 
index a0a1bf2f7f1941b48204cd49f1c7425ee64d7434..23044298a794c0b5ed6220bed778755f61be296d 100644 (file)
@@ -38,7 +38,7 @@ USES_APPLE_DEPRECATED_API
  *     Define a structure for our module configuration.
  */
 typedef struct {
-       char const *xlat_name;
+       char const *name;
 } rlm_expr_t;
 
 /** Calculate powers
@@ -610,12 +610,10 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        rlm_expr_t      *inst = instance;
        xlat_t          *xlat;
 
-       inst->xlat_name = cf_section_name2(conf);
-       if (!inst->xlat_name) {
-               inst->xlat_name = cf_section_name1(conf);
-       }
+       inst->name = cf_section_name2(conf);
+       if (!inst->name) inst->name = cf_section_name1(conf);
 
-       xlat = xlat_register(inst, inst->xlat_name, expr_xlat, false);
+       xlat = xlat_register(inst, inst->name, expr_xlat, false);
        xlat_func_mono(xlat, &expr_xlat_arg);
 
        return 0;
index 3919919b8998b0cb04383e30126ad7a3f49c693c..97ff433cc2d91ccba38e0b097b61b95c838dd70c 100644 (file)
@@ -39,7 +39,6 @@ RCSID("$Id$")
  */
 typedef struct {
        char const      *name;
-       char const      *xlat_name;
        char const      *interface;
        fr_time_delta_t timeout;
        fr_ipaddr_t     src_ipaddr;
@@ -538,11 +537,10 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        rlm_icmp_t      *inst = instance;
        xlat_t          *xlat;
 
-       inst->xlat_name = cf_section_name2(conf);
-       if (!inst->xlat_name) inst->xlat_name = cf_section_name1(conf);
-       inst->name = inst->xlat_name;
+       inst->name = cf_section_name2(conf);
+       if (!inst->name) inst->name = cf_section_name1(conf);
 
-       xlat = xlat_register(inst, inst->xlat_name, xlat_icmp, true);
+       xlat = xlat_register(inst, inst->name, xlat_icmp, true);
        xlat_func_args(xlat, xlat_icmp_args);
        xlat_async_instantiate_set(xlat, mod_xlat_instantiate, rlm_icmp_t *, NULL, inst);
        xlat_async_thread_instantiate_set(xlat, mod_xlat_thread_instantiate, xlat_icmp_thread_inst_t, NULL, inst);
index 99e6d660ed74a153697fdc3ad1fee1a4b94c5888..4c70171a6d99141f9fb346f360249db2f82aa377 100644 (file)
@@ -32,7 +32,7 @@ RCSID("$Id$")
  *      Structure for module configuration
  */
 typedef struct {
-       char const      *xlat_name;
+       char const      *name;
        bool            use_std3_ascii_rules;
        bool            allow_unassigned;
 } rlm_idn_t;
@@ -159,17 +159,12 @@ static xlat_action_t xlat_idna(TALLOC_CTX *ctx, fr_dcursor_t *out, request_t *re
 static int mod_bootstrap(void *instance, CONF_SECTION *conf)
 {
        rlm_idn_t       *inst = instance;
-       char const      *xlat_name;
        xlat_t          *xlat;
 
-       xlat_name = cf_section_name2(conf);
-       if (!xlat_name) {
-               xlat_name = cf_section_name1(conf);
-       }
-
-       inst->xlat_name = xlat_name;
+       inst->name = cf_section_name2(conf);
+       if (!inst->name) inst->name = cf_section_name1(conf);
 
-       xlat = xlat_register(inst, inst->xlat_name, xlat_idna, false);
+       xlat = xlat_register(inst, inst->name, xlat_idna, false);
        xlat_func_mono(xlat, &xlat_idna_arg);
        xlat_async_instantiate_set(xlat, mod_xlat_instantiate, rlm_idn_t *, NULL, inst);
 
index 85f62b7656415e4c03b95ea24c30b96a3cefbe83..d2b280a0947bfd661970dfd8073fa3d774d755bb 100644 (file)
@@ -26,7 +26,7 @@
 RCSID("$Id$")
 
 #define LOG_PREFIX "rlm_lua (%s) - "
-#define LOG_PREFIX_ARGS inst->xlat_name
+#define LOG_PREFIX_ARGS inst->name
 
 #include <freeradius-devel/server/base.h>
 #include <freeradius-devel/util/debug.h>
index 99613f638832dc975a1b7e3d6c704d48f58b85e4..51c3e591ebcc06a2436a05ac65f4f54f80eeb814 100644 (file)
@@ -46,7 +46,7 @@ typedef struct {
                                                //!< basis, or use a single mutex protected interpreter.
 
        bool            jit;                    //!< Whether the linked interpreter is Lua 5.1 or LuaJIT.
-       const char      *xlat_name;             //!< Name of this instance.
+       const char      *name;                  //!< Name of this instance.
        const char      *module;                //!< Full path to lua script to load and execute.
 
        const char      *func_instantiate;      //!< Name of function to run on instantiation.
index cc23b1fcd7157fe7a99986cde9e017b921b4d59a..21cdf9a239bfe0f10e658d2b9a068a0820d64b63 100644 (file)
@@ -26,7 +26,7 @@
 RCSID("$Id$")
 
 #define LOG_PREFIX "rlm_lua (%s) - "
-#define LOG_PREFIX_ARGS inst->xlat_name
+#define LOG_PREFIX_ARGS inst->name
 
 #include <freeradius-devel/server/base.h>
 #include <freeradius-devel/util/debug.h>
@@ -138,8 +138,8 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
        rlm_lua_t *inst = instance;
        rlm_rcode_t rcode;
 
-       inst->xlat_name = cf_section_name2(conf);
-       if (!inst->xlat_name) inst->xlat_name = cf_section_name1(conf);
+       inst->name = cf_section_name2(conf);
+       if (!inst->name) inst->name = cf_section_name1(conf);
 
        /*
         *      Get an instance global interpreter to use with various things...
index 08f6345a74b025108ac44ef92e467d635afb5aa0..d57c0b8d09e365806abe2163f84bfbe036810fa6 100644 (file)
@@ -25,7 +25,7 @@
 RCSID("$Id$")
 
 #define LOG_PREFIX "rlm_lua (%s) - "
-#define LOG_PREFIX_ARGS inst->xlat_name
+#define LOG_PREFIX_ARGS inst->name
 
 #include <freeradius-devel/server/base.h>
 
index 8a3a05ddfef32f72640a725c269308a4318ed0d8..55dcd75f69f96e34f138cd9a5c5c44b7fdbc908f 100644 (file)
@@ -60,6 +60,8 @@ extern char **environ;
  *     be used as the instance handle.
  */
 typedef struct {
+       char const      *name;
+
        /* Name of the perl module */
        char const      *module;
 
@@ -72,7 +74,6 @@ typedef struct {
        char const      *func_preacct;
        char const      *func_detach;
        char const      *func_post_auth;
-       char const      *xlat_name;
        char const      *perl_flags;
        PerlInterpreter *perl;
        bool            perl_parsed;
@@ -639,12 +640,11 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
 {
        rlm_perl_t      *inst = instance;
        xlat_t          *xlat;
-       char const      *xlat_name;
 
-       xlat_name = cf_section_name2(conf);
-       if (!xlat_name) xlat_name = cf_section_name1(conf);
+       inst->name = cf_section_name2(conf);
+       if (!inst->name) inst->name = cf_section_name1(conf);
 
-       xlat = xlat_register(NULL, xlat_name, perl_xlat, false);
+       xlat = xlat_register(NULL, inst->name, perl_xlat, false);
        xlat_func_args(xlat, perl_xlat_args);
 
        xlat_async_instantiate_set(xlat, mod_xlat_instantiate, rlm_perl_xlat_t, NULL, inst);
index cf5e63784f4bd9a57efa3b4d7671832fe9182f2b..6a080c587a47d46ca5c2d494830cd234c969c91c 100644 (file)
@@ -26,7 +26,7 @@
 RCSID("$Id$")
 
 #define LOG_PREFIX "rlm_rest (%s) - "
-#define LOG_PREFIX_ARGS inst->xlat_name
+#define LOG_PREFIX_ARGS inst->name
 
 #include <ctype.h>
 #include <string.h>
index 4069e488de472659d7be37225fa0520ad99462b4..259397c8b33201ae2d81f7a1afa0b6b8213c5827 100644 (file)
@@ -146,7 +146,7 @@ typedef struct {
  *     Structure for module configuration
  */
 typedef struct {
-       char const              *xlat_name;     //!< Instance name.
+       char const              *name;          //!< Instance name.
 
        char const              *connect_proxy; //!< Send request via this proxy.
 
index 7239ca95af161f4c0128a8b64e763fde350e5852..466f73bc5ef5d7d5efaef37449896de05accd864 100644 (file)
@@ -1124,7 +1124,7 @@ static int mod_thread_instantiate(CONF_SECTION const *conf, void *instance, fr_e
         *      thread safe.
         */
        my_conf = cf_section_dup(NULL, NULL, conf, cf_section_name1(conf), cf_section_name2(conf), true);
-       t->pool = fr_pool_init(NULL, my_conf, instance, rest_mod_conn_create, NULL, inst->xlat_name);
+       t->pool = fr_pool_init(NULL, my_conf, instance, rest_mod_conn_create, NULL, inst->name);
        talloc_free(my_conf);
 
        if (!t->pool) {
@@ -1208,10 +1208,10 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        rlm_rest_t      *inst = instance;
        xlat_t          *xlat;
 
-       inst->xlat_name = cf_section_name2(conf);
-       if (!inst->xlat_name) inst->xlat_name = cf_section_name1(conf);
+       inst->name = cf_section_name2(conf);
+       if (!inst->name) inst->name = cf_section_name1(conf);
 
-       xlat = xlat_register(inst, inst->xlat_name, rest_xlat, true);
+       xlat = xlat_register(inst, inst->name, rest_xlat, true);
        xlat_func_args(xlat, rest_xlat_args);
        xlat_async_thread_instantiate_set(xlat, mod_xlat_thread_instantiate, rest_xlat_thread_inst_t, NULL, inst);
 
index 5c93300ff09e4d101620814fe7568f9c012bea7e..86b708855c243be1ad464ef4e35ae7466461d675 100644 (file)
@@ -28,7 +28,7 @@ RCSID("$Id$")
 #include <freeradius-devel/soh/base.h>
 
 typedef struct {
-       char const *xlat_name;
+       char const *name;
        bool dhcp;
 } rlm_soh_t;
 
@@ -271,16 +271,13 @@ static unlang_action_t CC_HINT(nonnull) mod_authorize(rlm_rcode_t *p_result, UNU
 
 static int mod_bootstrap(void *instance, CONF_SECTION *conf)
 {
-       char const      *name;
        rlm_soh_t       *inst = instance;
        xlat_t          *xlat;
 
-       name = cf_section_name2(conf);
-       if (!name) name = cf_section_name1(conf);
-       inst->xlat_name = name;
-       if (!inst->xlat_name) return -1;
+       inst->name = cf_section_name2(conf);
+       if (!inst->name) inst->name = cf_section_name1(conf);
 
-       xlat = xlat_register(inst, inst->xlat_name, soh_xlat, false);
+       xlat = xlat_register(inst, inst->name, soh_xlat, false);
        xlat_func_args(xlat, soh_xlat_args);
 
        return 0;