From: Alan T. DeKok Date: Mon, 8 Nov 2021 16:47:11 +0000 (-0500) Subject: unify to inst->name, instead of inst->xlat_name X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99cf8e68b2de868c62a0a7c0080d3351059b5cd9;p=thirdparty%2Ffreeradius-server.git unify to inst->name, instead of inst->xlat_name --- diff --git a/src/modules/rlm_always/rlm_always.c b/src/modules/rlm_always/rlm_always.c index 0af6bcee41..153270e026 100644 --- a/src/modules/rlm_always/rlm_always.c +++ b/src/modules/rlm_always/rlm_always.c @@ -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); diff --git a/src/modules/rlm_cipher/rlm_cipher.c b/src/modules/rlm_cipher/rlm_cipher.c index 46329f0730..7ec2a91587 100644 --- a/src/modules/rlm_cipher/rlm_cipher.c +++ b/src/modules/rlm_cipher/rlm_cipher.c @@ -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, diff --git a/src/modules/rlm_date/rlm_date.c b/src/modules/rlm_date/rlm_date.c index 505a143c0a..8d46e87830 100644 --- a/src/modules/rlm_date/rlm_date.c +++ b/src/modules/rlm_date/rlm_date.c @@ -30,7 +30,7 @@ #include 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); diff --git a/src/modules/rlm_delay/rlm_delay.c b/src/modules/rlm_delay/rlm_delay.c index 65cfbeb478..b61fa74090 100644 --- a/src/modules/rlm_delay/rlm_delay.c +++ b/src/modules/rlm_delay/rlm_delay.c @@ -31,7 +31,7 @@ RCSID("$Id$") #include 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; diff --git a/src/modules/rlm_dhcpv4/rlm_dhcpv4.c b/src/modules/rlm_dhcpv4/rlm_dhcpv4.c index 9100702d26..704100f0eb 100644 --- a/src/modules/rlm_dhcpv4/rlm_dhcpv4.c +++ b/src/modules/rlm_dhcpv4/rlm_dhcpv4.c @@ -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. diff --git a/src/modules/rlm_escape/rlm_escape.c b/src/modules/rlm_escape/rlm_escape.c index a124772aee..810fac09fd 100644 --- a/src/modules/rlm_escape/rlm_escape.c +++ b/src/modules/rlm_escape/rlm_escape.c @@ -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); diff --git a/src/modules/rlm_expr/rlm_expr.c b/src/modules/rlm_expr/rlm_expr.c index a0a1bf2f7f..23044298a7 100644 --- a/src/modules/rlm_expr/rlm_expr.c +++ b/src/modules/rlm_expr/rlm_expr.c @@ -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; diff --git a/src/modules/rlm_icmp/rlm_icmp.c b/src/modules/rlm_icmp/rlm_icmp.c index 3919919b89..97ff433cc2 100644 --- a/src/modules/rlm_icmp/rlm_icmp.c +++ b/src/modules/rlm_icmp/rlm_icmp.c @@ -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); diff --git a/src/modules/rlm_idn/rlm_idn.c b/src/modules/rlm_idn/rlm_idn.c index 99e6d660ed..4c70171a6d 100644 --- a/src/modules/rlm_idn/rlm_idn.c +++ b/src/modules/rlm_idn/rlm_idn.c @@ -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); diff --git a/src/modules/rlm_lua/lua.c b/src/modules/rlm_lua/lua.c index 85f62b7656..d2b280a094 100644 --- a/src/modules/rlm_lua/lua.c +++ b/src/modules/rlm_lua/lua.c @@ -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 #include diff --git a/src/modules/rlm_lua/lua.h b/src/modules/rlm_lua/lua.h index 99613f6388..51c3e591eb 100644 --- a/src/modules/rlm_lua/lua.h +++ b/src/modules/rlm_lua/lua.h @@ -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. diff --git a/src/modules/rlm_lua/rlm_lua.c b/src/modules/rlm_lua/rlm_lua.c index cc23b1fcd7..21cdf9a239 100644 --- a/src/modules/rlm_lua/rlm_lua.c +++ b/src/modules/rlm_lua/rlm_lua.c @@ -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 #include @@ -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... diff --git a/src/modules/rlm_lua/util.c b/src/modules/rlm_lua/util.c index 08f6345a74..d57c0b8d09 100644 --- a/src/modules/rlm_lua/util.c +++ b/src/modules/rlm_lua/util.c @@ -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 diff --git a/src/modules/rlm_perl/rlm_perl.c b/src/modules/rlm_perl/rlm_perl.c index 8a3a05ddfe..55dcd75f69 100644 --- a/src/modules/rlm_perl/rlm_perl.c +++ b/src/modules/rlm_perl/rlm_perl.c @@ -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); diff --git a/src/modules/rlm_rest/rest.c b/src/modules/rlm_rest/rest.c index cf5e63784f..6a080c587a 100644 --- a/src/modules/rlm_rest/rest.c +++ b/src/modules/rlm_rest/rest.c @@ -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 #include diff --git a/src/modules/rlm_rest/rest.h b/src/modules/rlm_rest/rest.h index 4069e488de..259397c8b3 100644 --- a/src/modules/rlm_rest/rest.h +++ b/src/modules/rlm_rest/rest.h @@ -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. diff --git a/src/modules/rlm_rest/rlm_rest.c b/src/modules/rlm_rest/rlm_rest.c index 7239ca95af..466f73bc5e 100644 --- a/src/modules/rlm_rest/rlm_rest.c +++ b/src/modules/rlm_rest/rlm_rest.c @@ -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); diff --git a/src/modules/rlm_soh/rlm_soh.c b/src/modules/rlm_soh/rlm_soh.c index 5c93300ff0..86b708855c 100644 --- a/src/modules/rlm_soh/rlm_soh.c +++ b/src/modules/rlm_soh/rlm_soh.c @@ -28,7 +28,7 @@ RCSID("$Id$") #include 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;