rlm_sql_ippool and rlm_sql_counter won't work with dynamic modules... but that's OK, because the way they depend on other modules is stupid, and needs to be fixed anyway.
*
* @param[in] mi Module instance to get the thread-specific data for.
*/
-static module_thread_instance_t *mlg_thread_data_get(module_instance_t *mi)
+static module_thread_instance_t *mlg_thread_data_get(module_instance_t const *mi)
{
- mlg_module_instance_t *mlg_mi = (mlg_module_instance_t *)talloc_get_type_abort(mi, module_instance_t);
+ mlg_module_instance_t const *mlg_mi = (mlg_module_instance_t const *)talloc_get_type_abort_const(mi, module_instance_t);
module_thread_instance_t *ti;
fr_assert_msg(mlg_mi->inst_idx <= talloc_array_length(mlg_thread_inst_list),
if (mltl_mi->ti) module_thread_detach(mltl_mi->ti);
}
-static module_thread_instance_t *mltl_thread_data_get(module_instance_t *mi)
+static module_thread_instance_t *mltl_thread_data_get(module_instance_t const *mi)
{
- mltl_module_instance_t *mltl_mi = (mltl_module_instance_t *)talloc_get_type_abort(mi, module_instance_t);
+ mltl_module_instance_t const *mltl_mi = (mltl_module_instance_t *)talloc_get_type_abort_const(mi, module_instance_t);
return mltl_mi->ti;
}
* - NULL if no data exists.
* - Pointer to the data on success.
*/
-typedef module_thread_instance_t *(*module_list_thread_data_get_t)(module_instance_t *mi);
+typedef module_thread_instance_t *(*module_list_thread_data_get_t)(module_instance_t const *mi);
/** A list of modules
*
* - NULL if module has no thread instance data.
*/
static inline CC_HINT(warn_unused_result) CC_HINT(always_inline)
-module_thread_instance_t *module_thread(module_instance_t *mi)
+module_thread_instance_t *module_thread(module_instance_t const *mi)
{
return mi->ml->thread_data_get(mi);
}
* Module names are allowed to contain '.'
* so we search for the bare module name first.
*/
- mi = module_instance_by_name(rlm_modules_static, NULL, name);
+ mi = module_rlm_static_by_name(NULL, name);
if (mi) {
virtual_server_method_t const *allowed_list;
return inst->cs;
}
-module_thread_instance_t *module_rlm_thread_by_data(void const *data)
-{
- return module_thread_by_data(rlm_modules_static, data);
-}
-
-module_instance_t *module_rlm_by_name(module_instance_t const *parent, char const *asked_name)
+module_instance_t *module_rlm_static_by_name(module_instance_t const *parent, char const *asked_name)
{
return module_instance_by_name(rlm_modules_static, parent, asked_name);
}
char const **name1, char const **name2,
char const *asked_name);
-module_thread_instance_t *module_rlm_thread_by_data(void const *data);
-
-module_instance_t *module_rlm_by_name(module_instance_t const *parent, char const *asked_name);
+module_instance_t *module_rlm_static_by_name(module_instance_t const *parent, char const *asked_name);
CONF_SECTION *module_rlm_by_name_virtual(char const *asked_name);
module_ctx_t *mctx;
mctx = module_ctx_from_inst(xt, call->func->mctx);
- mctx->thread = module_rlm_thread_by_data(mctx->mi->data)->data;
+ mctx->thread = module_thread(mctx->mi)->data;
xt->mctx = mctx;
}
fr_value_box_list_t *url, map_list_t const *maps)
{
rlm_ldap_t const *inst = talloc_get_type_abort_const(mod_inst, rlm_ldap_t);
- fr_ldap_thread_t *thread = talloc_get_type_abort(module_rlm_thread_by_data(inst)->data, fr_ldap_thread_t);
+ fr_ldap_thread_t *thread = talloc_get_type_abort(module_thread(inst->mi)->data, fr_ldap_thread_t);
LDAPURLDesc *ldap_url;
int ldap_url_ret;
static unlang_action_t CC_HINT(nonnull) mod_authenticate(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
{
rlm_ldap_t const *inst = talloc_get_type_abort_const(mctx->mi->data, rlm_ldap_t);
- fr_ldap_thread_t *thread = talloc_get_type_abort(module_rlm_thread_by_data(inst)->data, fr_ldap_thread_t);
+ fr_ldap_thread_t *thread = talloc_get_type_abort(module_thread(inst->mi), fr_ldap_thread_t);
ldap_auth_ctx_t *auth_ctx;
ldap_auth_call_env_t *call_env = talloc_get_type_abort(mctx->env_data, ldap_auth_call_env_t);
if (inst->edir && inst->edir_autz) {
fr_pair_t *password = fr_pair_find_by_da(&request->control_pairs,
NULL, attr_cleartext_password);
- fr_ldap_thread_t *thread = talloc_get_type_abort(module_rlm_thread_by_data(inst)->data,
+ fr_ldap_thread_t *thread = talloc_get_type_abort(module_thread(inst->mi)->data,
fr_ldap_thread_t);
if (!password) {
static unlang_action_t CC_HINT(nonnull) mod_authorize(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
{
rlm_ldap_t const *inst = talloc_get_type_abort_const(mctx->mi->data, rlm_ldap_t);
- fr_ldap_thread_t *thread = talloc_get_type_abort(module_rlm_thread_by_data(inst)->data, fr_ldap_thread_t);
+ fr_ldap_thread_t *thread = talloc_get_type_abort(module_thread(inst->mi)->data, fr_ldap_thread_t);
ldap_autz_ctx_t *autz_ctx;
fr_ldap_map_exp_t *expanded;
ldap_autz_call_env_t *call_env = talloc_get_type_abort(mctx->env_data, ldap_autz_call_env_t);
ldap_acct_section_t *section, ldap_usermod_call_env_t *call_env)
{
rlm_rcode_t rcode = RLM_MODULE_FAIL;
- fr_ldap_thread_t *thread = talloc_get_type_abort(module_rlm_thread_by_data(inst)->data, fr_ldap_thread_t);
+ fr_ldap_thread_t *thread = talloc_get_type_abort(module_thread(inst->mi)->data, fr_ldap_thread_t);
ldap_user_modify_ctx_t *usermod_ctx = NULL;
int total = 0, last_pass = 0;
rlm_ldap_t *inst = talloc_get_type_abort(mctx->mi->data, rlm_ldap_t);
CONF_SECTION *conf = mctx->mi->conf;
+ inst->mi = mctx->mi; /* Cached for IO callbacks */
inst->group.da = boot->group_da;
inst->group.cache_da = boot->cache_da;
fr_ldap_config_t handle_config; //!< Connection configuration instance.
fr_trunk_conf_t trunk_conf; //!< Trunk configuration
fr_trunk_conf_t bind_trunk_conf; //!< Trunk configuration for trunk used for bind auths
+
+ module_instance_t const *mi; //!< Module instance data for thread lookups.
} rlm_ldap_t;
/** Call environment used in LDAP authorization
module_instance_t const *sql_inst;
fr_assert(inst->query && *inst->query);
- sql_inst = module_rlm_by_name(NULL, inst->sql_name);
+ sql_inst = module_rlm_static_by_name(NULL, inst->sql_name);
if (!sql_inst) {
cf_log_err(conf, "Module \"%s\" not found", inst->sql_name);
return -1;
inst->name = talloc_asprintf(inst, "%s - %s", mctx->mi->name, inst->sql_name);
- sql = module_rlm_by_name(NULL, inst->sql_name);
+ sql = module_rlm_static_by_name(NULL, inst->sql_name);
if (!sql) {
cf_log_err(conf, "failed to find sql instance named %s",
inst->sql_name);
/*
* Lookup the sql module instance.
*/
- sql_inst = module_rlm_by_name(NULL, inst->sql_name);
+ sql_inst = module_rlm_static_by_name(NULL, inst->sql_name);
if (!sql_inst) return -1;
sql = talloc_get_type_abort(sql_inst->data, rlm_sql_t);