Adding new stack frames is expensive, and there's no need to do this as we can just mutate the module's frame
/** Complete mschap authentication after any tmpls have been expanded.
*
*/
-static unlang_action_t mod_authenticate_resume(unlang_result_t *p_result, request_t *request, void *uctx)
+static unlang_action_t mod_authenticate_resume(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
{
- mschap_auth_ctx_t *auth_ctx = talloc_get_type_abort(uctx, mschap_auth_ctx_t);
+ mschap_auth_ctx_t *auth_ctx = talloc_get_type_abort(mctx->rctx, mschap_auth_ctx_t);
mschap_auth_call_env_t *env_data = talloc_get_type_abort(auth_ctx->env_data, mschap_auth_call_env_t);
rlm_mschap_t const *inst = talloc_get_type_abort_const(auth_ctx->inst, rlm_mschap_t);
fr_pair_t *challenge = NULL;
*/
if (!auth_ctx->nt_password) {
REDEBUG("Missing Password.NT - required for change password request");
- RETURN_UNLANG_FAIL;
+ RETURN_MODULE_FAIL;
}
if (!env_data->chap_nt_enc_pw) {
REDEBUG("chap_nt_enc_pw option is not set - required for change password request");
- RETURN_UNLANG_INVALID;
+ RETURN_MODULE_INVALID;
}
mschap_process_cpw_request(&rcode, inst, request, auth_ctx);
} /* else we weren't asked to use MPPE */
finish:
- RETURN_UNLANG_RCODE(rcode);
-}
-
-/** When changing passwords using the ntlm_auth helper, evaluate the domain tmpl
- *
- */
-static unlang_action_t mod_authenticate_domain_tmpl_push(unlang_result_t *p_result, request_t *request, void *uctx)
-{
- mschap_auth_ctx_t *auth_ctx = talloc_get_type_abort(uctx, mschap_auth_ctx_t);
- mschap_auth_call_env_t *env_data = talloc_get_type_abort(auth_ctx->env_data, mschap_auth_call_env_t);
-
- fr_value_box_list_init(&auth_ctx->cpw_ctx->cpw_domain);
- if (unlang_tmpl_push(auth_ctx, &auth_ctx->cpw_ctx->cpw_domain, request,
- env_data->ntlm_cpw_domain, NULL) < 0) RETURN_UNLANG_FAIL;
-
- return UNLANG_ACTION_PUSHED_CHILD;
+ RETURN_MODULE_RCODE(rcode);
}
#ifdef WITH_TLS
case AUTH_INTERNAL:
#ifdef WITH_TLS
if (mschap_new_pass_decrypt(request, auth_ctx) < 0) RETURN_MODULE_FAIL;
- if (unlang_function_push(NULL, request, NULL, mod_authenticate_resume, NULL, 0,
- UNLANG_SUB_FRAME, auth_ctx) < 0) RETURN_MODULE_FAIL;
+
+ if (unlang_module_yield(request, mod_authenticate_resume, NULL, 0, auth_ctx) != UNLANG_ACTION_YIELD) {
+ RETURN_MODULE_FAIL;
+ }
fr_value_box_list_init(&auth_ctx->cpw_ctx->local_cpw_result);
if (unlang_tmpl_push(auth_ctx, &auth_ctx->cpw_ctx->local_cpw_result, request,
RETURN_MODULE_FAIL;
}
- if (unlang_function_push(NULL, request, env_data->ntlm_cpw_domain ? mod_authenticate_domain_tmpl_push : NULL,
- mod_authenticate_resume, NULL, 0,
- UNLANG_SUB_FRAME, auth_ctx) < 0) RETURN_MODULE_FAIL;
+ /*
+ * Run the resumption function where we're done with:
+ */
+ if (unlang_module_yield(request, mod_authenticate_resume, NULL, 0, auth_ctx) != UNLANG_ACTION_YIELD) {
+ RETURN_MODULE_FAIL;
+ };
+
+ /*
+ * a) Expanding the domain, if specified
+ */
+ if (env_data->ntlm_cpw_domain) {
+ fr_value_box_list_init(&auth_ctx->cpw_ctx->cpw_domain);
+ if (unlang_tmpl_push(auth_ctx, &auth_ctx->cpw_ctx->cpw_domain, request,
+ env_data->ntlm_cpw_domain, NULL) < 0) RETURN_MODULE_FAIL;
+ }
fr_value_box_list_init(&auth_ctx->cpw_ctx->cpw_user);
+
+ /*
+ * b) Expanding the username
+ */
if (unlang_tmpl_push(auth_ctx, &auth_ctx->cpw_ctx->cpw_user, request,
env_data->ntlm_cpw_username, NULL) < 0) RETURN_MODULE_FAIL;
break;
return UNLANG_ACTION_PUSHED_CHILD;
}
- return unlang_function_push(NULL, request, mod_authenticate_resume, NULL, NULL, 0, UNLANG_SUB_FRAME, 0);
+ /*
+ * Not doing password change, just jump straight to the resumption function...
+ */
+ {
+ module_ctx_t our_mctx = *mctx;
+ our_mctx.rctx = auth_ctx;
+
+ return mod_authenticate_resume(p_result, &our_mctx, request);
+ }
}
/*
#include <freeradius-devel/server/map_proc.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/server/pairmove.h>
+#include <freeradius-devel/server/rcode.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/dict.h>
#include <freeradius-devel/util/skip.h>
#include <freeradius-devel/util/table.h>
+#include <freeradius-devel/unlang/action.h>
#include <freeradius-devel/unlang/function.h>
#include <freeradius-devel/unlang/xlat_func.h>
+#include <freeradius-devel/unlang/module.h>
+#include <freeradius-devel/unlang/map.h>
#include <sys/stat.h>
unlang_xlat_yield(request, sql_xlat_select_resume, NULL, 0, query_ctx);
if (unlang_function_push(NULL, request, inst->select, NULL, NULL, 0, UNLANG_SUB_FRAME, query_ctx) != UNLANG_ACTION_PUSHED_CHILD) return XLAT_ACTION_FAIL;
-
return XLAT_ACTION_PUSH_UNLANG;
}
unlang_xlat_yield(request, sql_xlat_select_resume, NULL, 0, query_ctx);
if (unlang_function_push(NULL, request, inst->select, NULL, NULL, 0, UNLANG_SUB_FRAME, query_ctx) != UNLANG_ACTION_PUSHED_CHILD) return XLAT_ACTION_FAIL;
-
return XLAT_ACTION_PUSH_UNLANG;
}
group_ctx->query->vb_strvalue, SQL_QUERY_SELECT));
if (unlang_function_push(NULL, request, NULL, sql_get_grouplist_resume, NULL, 0, UNLANG_SUB_FRAME, group_ctx) < 0) return UNLANG_ACTION_FAIL;
-
return unlang_function_push(NULL, request, inst->select, NULL, NULL, 0, UNLANG_SUB_FRAME, group_ctx->query_ctx);
}
if (unlang_xlat_yield(request, sql_group_xlat_query_resume, NULL, 0, xlat_ctx) != XLAT_ACTION_YIELD) return XLAT_ACTION_FAIL;
- if (sql_get_grouplist(xlat_ctx->group_ctx, thread->trunk, request) != UNLANG_ACTION_PUSHED_CHILD)
- return XLAT_ACTION_FAIL;
+ if (sql_get_grouplist(xlat_ctx->group_ctx, thread->trunk, request) != UNLANG_ACTION_PUSHED_CHILD) {
+ return XLAT_ACTION_FAIL;
+ }
return XLAT_ACTION_PUSH_UNLANG;
}
* Before each query is run, &request.SQL-Group is populated with the value of the group being evaluated.
*
* @param p_result Result of current authorization.
- * @param request Current request.
- * @param uctx Current authorization context.
+ * @param mctx Current request.
+ * @param request Current authorization context.
* @return one of the RLM_MODULE_* values.
*/
-static unlang_action_t mod_autz_group_resume(unlang_result_t *p_result, request_t *request, void *uctx)
+static unlang_action_t CC_HINT(nonnull) mod_autz_group_resume(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
{
- sql_autz_ctx_t *autz_ctx = talloc_get_type_abort(uctx, sql_autz_ctx_t);
+ sql_autz_ctx_t *autz_ctx = talloc_get_type_abort(mctx->rctx, sql_autz_ctx_t);
sql_autz_call_env_t *call_env = autz_ctx->call_env;
sql_group_ctx_t *group_ctx = autz_ctx->group_ctx;
fr_sql_map_ctx_t *map_ctx = autz_ctx->map_ctx;
sql_fall_through_t do_fall_through = FALL_THROUGH_DEFAULT;
fr_pair_t *vp;
- switch (p_result->rcode) {
+ switch (*p_result) {
case RLM_MODULE_USER_SECTION_REJECT:
return UNLANG_ACTION_CALCULATE_RESULT;
switch(autz_ctx->status) {
case SQL_AUTZ_GROUP_MEMB:
- if (unlang_function_repeat_set(request, mod_autz_group_resume) < 0) RETURN_UNLANG_FAIL;
+ if (unlang_module_yield(request, mod_autz_group_resume, NULL, 0, mctx->rctx) != UNLANG_ACTION_YIELD) RETURN_MODULE_FAIL;
MEM(autz_ctx->group_ctx = talloc(autz_ctx, sql_group_ctx_t));
*autz_ctx->group_ctx = (sql_group_ctx_t) {
.inst = inst,
}
if (call_env->group_check_query) {
- if (unlang_function_repeat_set(request, mod_autz_group_resume) < 0) RETURN_UNLANG_FAIL;
+ if (unlang_module_yield(request, mod_autz_group_resume, NULL, 0, mctx->rctx) != UNLANG_ACTION_YIELD) RETURN_MODULE_FAIL;
if (unlang_tmpl_push(autz_ctx, &autz_ctx->query, request,
- call_env->group_check_query, NULL) < 0) RETURN_UNLANG_FAIL;
+ call_env->group_check_query, NULL) < 0) RETURN_MODULE_FAIL;
return UNLANG_ACTION_PUSHED_CHILD;
}
.query = query,
};
- if (unlang_function_repeat_set(request, mod_autz_group_resume) < 0) RETURN_UNLANG_FAIL;
+ if (unlang_module_yield(request, mod_autz_group_resume, NULL, 0, mctx->rctx) != UNLANG_ACTION_YIELD) RETURN_MODULE_FAIL;
if (sql_get_map_list(request, map_ctx, autz_ctx->trunk) == UNLANG_ACTION_PUSHED_CHILD) {
autz_ctx->status = autz_ctx->status & SQL_AUTZ_STAGE_GROUP ? SQL_AUTZ_GROUP_CHECK_RESUME : SQL_AUTZ_PROFILE_CHECK_RESUME;
return UNLANG_ACTION_PUSHED_CHILD;
if (call_env->group_reply_query) {
group_reply_push:
- if (unlang_function_repeat_set(request, mod_autz_group_resume) < 0) RETURN_UNLANG_FAIL;
+ if (unlang_module_yield(request, mod_autz_group_resume, NULL, 0, mctx->rctx) != UNLANG_ACTION_YIELD) RETURN_MODULE_FAIL;
if (unlang_tmpl_push(autz_ctx, &autz_ctx->query, request,
- call_env->group_reply_query, NULL) < 0) RETURN_UNLANG_FAIL;
+ call_env->group_reply_query, NULL) < 0) RETURN_MODULE_FAIL;
autz_ctx->status = autz_ctx->status & SQL_AUTZ_STAGE_GROUP ? SQL_AUTZ_GROUP_REPLY : SQL_AUTZ_PROFILE_REPLY;
return UNLANG_ACTION_PUSHED_CHILD;
}
.expand_rhs = true,
};
- if (unlang_function_repeat_set(request, mod_autz_group_resume) < 0) RETURN_UNLANG_FAIL;
+ if (unlang_module_yield(request, mod_autz_group_resume, NULL, 0, mctx->rctx) != UNLANG_ACTION_YIELD) RETURN_MODULE_FAIL;
if (sql_get_map_list(request, map_ctx, autz_ctx->trunk) == UNLANG_ACTION_PUSHED_CHILD) {
autz_ctx->status = autz_ctx->status & SQL_AUTZ_STAGE_GROUP ? SQL_AUTZ_GROUP_REPLY_RESUME : SQL_AUTZ_PROFILE_REPLY_RESUME;
return UNLANG_ACTION_PUSHED_CHILD;
if (radius_legacy_map_list_apply(request, &autz_ctx->reply_tmp, NULL) < 0) {
RPEDEBUG("Failed applying reply item");
REXDENT();
- RETURN_UNLANG_FAIL;
+ RETURN_MODULE_FAIL;
}
REXDENT();
map_list_talloc_free(&autz_ctx->reply_tmp);
}
}
- if (!autz_ctx->user_found) RETURN_UNLANG_NOTFOUND;
+ if (!autz_ctx->user_found) RETURN_MODULE_NOTFOUND;
- RETURN_UNLANG_RCODE(autz_ctx->rcode);
+ RETURN_MODULE_RCODE(autz_ctx->rcode);
}
/** Resume function called after authorization check / reply tmpl expansion
*
* @param p_result Result of current authorization.
+ * @param mctx Module call ctx.
* @param request Current request.
- * @param uctx Current authorization context.
* @return one of the RLM_MODULE_* values.
*/
-static unlang_action_t mod_authorize_resume(unlang_result_t *p_result, request_t *request, void *uctx)
+static unlang_action_t CC_HINT(nonnull) mod_authorize_resume(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
{
- sql_autz_ctx_t *autz_ctx = talloc_get_type_abort(uctx, sql_autz_ctx_t);
+ sql_autz_ctx_t *autz_ctx = talloc_get_type_abort(mctx->rctx, sql_autz_ctx_t);
sql_autz_call_env_t *call_env = autz_ctx->call_env;
rlm_sql_t const *inst = autz_ctx->inst;
fr_value_box_t *query = fr_value_box_list_pop_head(&autz_ctx->query);
/*
* If a previous async call returned one of the "failure" results just return.
*/
- switch (p_result->rcode) {
+ switch (*p_result) {
case RLM_MODULE_USER_SECTION_REJECT:
return UNLANG_ACTION_CALCULATE_RESULT;
.query = query,
};
- if (unlang_function_repeat_set(request, mod_authorize_resume) < 0) RETURN_UNLANG_FAIL;
+ if (unlang_module_yield(request, mod_authorize_resume, NULL, 0, autz_ctx) != UNLANG_ACTION_YIELD) RETURN_MODULE_FAIL;
if (sql_get_map_list(request, map_ctx, autz_ctx->trunk) == UNLANG_ACTION_PUSHED_CHILD){
autz_ctx->status = SQL_AUTZ_CHECK_RESUME;
return UNLANG_ACTION_PUSHED_CHILD;
if (!call_env->reply_query) goto skip_reply;
- if (unlang_function_repeat_set(request, mod_authorize_resume) < 0) RETURN_UNLANG_FAIL;
- if (unlang_tmpl_push(autz_ctx, &autz_ctx->query, request, call_env->reply_query, NULL) < 0) RETURN_UNLANG_FAIL;
+ if (unlang_module_yield(request, mod_authorize_resume, NULL, 0, autz_ctx) != UNLANG_ACTION_YIELD) RETURN_MODULE_FAIL;
+ if (unlang_tmpl_push(autz_ctx, &autz_ctx->query, request, call_env->reply_query, NULL) < 0) RETURN_MODULE_FAIL;
autz_ctx->status = SQL_AUTZ_REPLY;
return UNLANG_ACTION_PUSHED_CHILD;
.expand_rhs = true,
};
- if (unlang_function_repeat_set(request, mod_authorize_resume) < 0) RETURN_UNLANG_FAIL;
+ if (unlang_module_yield(request, mod_authorize_resume, NULL, 0, autz_ctx) != UNLANG_ACTION_YIELD) RETURN_MODULE_FAIL;
if (sql_get_map_list(request, map_ctx, autz_ctx->trunk) == UNLANG_ACTION_PUSHED_CHILD){
autz_ctx->status = SQL_AUTZ_REPLY_RESUME;
return UNLANG_ACTION_PUSHED_CHILD;
if (radius_legacy_map_list_apply(request, &autz_ctx->reply_tmp, NULL) < 0) {
RPEDEBUG("Failed applying item");
REXDENT();
- RETURN_UNLANG_FAIL;
+ RETURN_MODULE_FAIL;
}
REXDENT();
break;
}
- if (unlang_function_repeat_set(request, mod_autz_group_resume) < 0) RETURN_UNLANG_FAIL;
+ if (unlang_module_yield(request, mod_autz_group_resume, NULL, 0, autz_ctx) != UNLANG_ACTION_YIELD) RETURN_MODULE_FAIL;
if (unlang_tmpl_push(autz_ctx, &autz_ctx->query, request,
- call_env->membership_query, NULL) < 0) RETURN_UNLANG_FAIL;
+ call_env->membership_query, NULL) < 0) RETURN_MODULE_FAIL;
autz_ctx->status = SQL_AUTZ_GROUP_MEMB;
return UNLANG_ACTION_PUSHED_CHILD;
}
MEM(pair_update_request(&autz_ctx->sql_group, inst->group_da) >= 0);
autz_ctx->status = SQL_AUTZ_PROFILE_START;
- return mod_autz_group_resume(p_result, request, autz_ctx);
+ return mod_autz_group_resume(p_result, mctx, request);
}
break;
default:
- fr_assert(0);
+ fr_assert_msg(0, "Invalid status %d in mod_authorize_resume", autz_ctx->status);
}
- if (!autz_ctx->user_found) RETURN_UNLANG_NOTFOUND;
- RETURN_UNLANG_RCODE(autz_ctx->rcode);
+ if (!autz_ctx->user_found) RETURN_MODULE_NOTFOUND;
+ RETURN_MODULE_RCODE(autz_ctx->rcode);
}
/** Start of module authorize method
MEM(autz_ctx->map_ctx = talloc_zero(autz_ctx, fr_sql_map_ctx_t));
talloc_set_destructor(autz_ctx, sql_autz_ctx_free);
- if (unlang_function_push(NULL, request, NULL,
- (call_env->check_query || call_env->reply_query) ? mod_authorize_resume : mod_autz_group_resume,
- NULL, 0, UNLANG_SUB_FRAME, autz_ctx) < 0) {
+ if (unlang_module_yield(request,
+ (call_env->check_query || call_env->reply_query) ? mod_authorize_resume : mod_autz_group_resume,
+ NULL, 0, autz_ctx) != UNLANG_ACTION_YIELD) {
error:
talloc_free(autz_ctx);
RETURN_MODULE_FAIL;
redundant_ctx->query_vb->vb_strvalue, SQL_QUERY_OTHER));
unlang_module_yield(request, mod_sql_redundant_query_resume, NULL, 0, redundant_ctx);
-
return unlang_function_push(NULL, request, inst->query, NULL, NULL, 0, UNLANG_SUB_FRAME, redundant_ctx->query_ctx);
}
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/dict.h>
#include <freeradius-devel/unlang/function.h>
-
+#include <freeradius-devel/unlang/action.h>
+#include <freeradius-devel/unlang/module.h>
#include <ctype.h>
/*
* Otherwise, optionally populate a reply attribute with the value of `limit` - `counter` and return RLM_MODULE_UPDATED.
* If no reply attribute is set, return RLM_MODULE_OK.
*/
-static unlang_action_t mod_authorize_resume(unlang_result_t *p_result, request_t *request, void *uctx)
+static unlang_action_t mod_authorize_resume(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
{
- sqlcounter_rctx_t *rctx = talloc_get_type_abort(uctx, sqlcounter_rctx_t);
+ sqlcounter_rctx_t *rctx = talloc_get_type_abort(mctx->rctx, sqlcounter_rctx_t);
rlm_sqlcounter_t *inst = rctx->inst;
sqlcounter_call_env_t *env = rctx->env;
fr_value_box_t *sql_result = fr_value_box_list_pop_head(&rctx->result);
REDEBUG2("Rejecting user, %s value (%" PRIu64 ") is less than counter value (%" PRIu64 ")",
inst->limit_attr->name, limit->vp_uint64, counter);
- RETURN_UNLANG_REJECT;
+ RETURN_MODULE_REJECT;
}
res = limit->vp_uint64 - counter;
if (fr_value_box_cmp(&vb, &existing) == 1) {
RDEBUG2("Leaving existing %s value of %pV" , env->reply_attr->name,
&vp->data);
- RETURN_UNLANG_OK;
+ RETURN_MODULE_OK;
}
}
break;
case -1: /* alloc failed */
REDEBUG("Error allocating attribute %s", env->reply_attr->name);
- RETURN_UNLANG_FAIL;
+ RETURN_MODULE_FAIL;
default: /* request or list unavailable */
RDEBUG2("List or request context not available for %s, skipping...", env->reply_attr->name);
- RETURN_UNLANG_OK;
+ RETURN_MODULE_OK;
}
fr_value_box_cast(vp, &vp->data, vp->data.type, NULL, &vb);
RDEBUG2("%pP", vp);
- RETURN_UNLANG_UPDATED;
+ RETURN_MODULE_UPDATED;
}
- RETURN_UNLANG_OK;
+ RETURN_MODULE_OK;
}
/** Check the value of a `counter` retrieved from an SQL query with a `limit`
.limit = limit
};
- if (unlang_function_push(NULL, request, NULL, mod_authorize_resume, NULL, 0, UNLANG_SUB_FRAME, rctx) < 0) {
+ if (unlang_module_yield(request, mod_authorize_resume, NULL, 0, rctx) != UNLANG_ACTION_YIELD) {
error:
talloc_free(rctx);
RETURN_MODULE_FAIL;
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/radius/radius.h>
#include <freeradius-devel/unlang/function.h>
+#include <freeradius-devel/unlang/action.h>
+#include <freeradius-devel/unlang/module.h>
#include <ctype.h>
return 0;
}
-#define REPEAT_MOD_ALLOC_RESUME if (unlang_function_repeat_set(request, mod_alloc_resume) < 0) RETURN_UNLANG_FAIL
+#define REPEAT_MOD_ALLOC_RESUME if (unlang_module_yield(request, mod_alloc_resume, NULL, 0, mctx->rctx) < 0) RETURN_MODULE_FAIL
#define SUBMIT_QUERY(_query_str, _new_status, _type, _function) do { \
alloc_ctx->status = _new_status; \
REPEAT_MOD_ALLOC_RESUME; \
* Following the final (successful) query, the destination attribute is populated.
*
* @param p_result Result of IP allocation.
+ * @param mctx Current allocation context.
* @param request Current request.
- * @param uctx Current allocation context.
* @return One of the UNLANG_ACTION_* values.
*/
-static unlang_action_t mod_alloc_resume(unlang_result_t *p_result, request_t *request, void *uctx)
+static unlang_action_t mod_alloc_resume(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
{
- ippool_alloc_ctx_t *alloc_ctx = talloc_get_type_abort(uctx, ippool_alloc_ctx_t);
+ ippool_alloc_ctx_t *alloc_ctx = talloc_get_type_abort(mctx->rctx, ippool_alloc_ctx_t);
ippool_alloc_call_env_t *env = alloc_ctx->env;
int allocation_len = 0;
char allocation[FR_MAX_STRING_LEN];
/*
* If a previous async call returned one of the "failure" results just return.
*/
- switch (p_result->rcode) {
+ switch (*p_result) {
case RLM_MODULE_USER_SECTION_REJECT:
return UNLANG_ACTION_CALCULATE_RESULT;
if (unlang_tmpl_push(alloc_ctx, &alloc_ctx->values, request, env->existing, NULL) < 0) {
error:
talloc_free(alloc_ctx);
- RETURN_UNLANG_FAIL;
+ RETURN_MODULE_FAIL;
}
return UNLANG_ACTION_PUSHED_CHILD;
}
}
no_address:
RWDEBUG("IP address could not be allocated");
- RETURN_UNLANG_NOOP;
+ RETURN_MODULE_NOOP;
case IPPOOL_ALLOC_MAKE_PAIR:
{
* NOTFOUND
*/
RWDEBUG("Pool \"%pV\" appears to be full", &env->pool_name);
- RETURN_UNLANG_NOTFOUND;
+ RETURN_MODULE_NOTFOUND;
}
/*
*/
RWDEBUG("IP address could not be allocated as no pool exists with the name \"%pV\"",
&env->pool_name);
- RETURN_UNLANG_NOOP;
+ RETURN_MODULE_NOOP;
case IPPOOL_ALLOC_UPDATE:
if (query && query->vb_length) SUBMIT_QUERY(query->vb_strvalue, IPPOOL_ALLOC_UPDATE_RUN, SQL_QUERY_OTHER, query);
{
rlm_rcode_t rcode = alloc_ctx->rcode;
talloc_free(alloc_ctx);
- RETURN_UNLANG_RCODE(rcode);
+ RETURN_MODULE_RCODE(rcode);
}
}
* All return paths are handled within the switch statement.
*/
fr_assert(0);
- RETURN_UNLANG_FAIL;
+ RETURN_MODULE_FAIL;
}
/** Initiate the allocation of an IP address from the pool.
MEM(alloc_ctx->query_ctx = sql->query_alloc(alloc_ctx, sql, request, thread->trunk, "", SQL_QUERY_OTHER));
fr_value_box_list_init(&alloc_ctx->values);
- if (unlang_function_push(NULL, request, NULL, mod_alloc_resume, NULL, 0, UNLANG_SUB_FRAME, alloc_ctx) < 0 ) {
+ if (unlikely(unlang_module_yield(request, mod_alloc_resume, NULL, 0, alloc_ctx) != UNLANG_ACTION_YIELD)) {
talloc_free(alloc_ctx);
RETURN_MODULE_FAIL;
}
/** Resume function called after mod_common "update" query has completed
*/
-static unlang_action_t mod_common_update_resume(unlang_result_t *p_result, UNUSED request_t *request, void *uctx)
+static unlang_action_t mod_common_update_resume(rlm_rcode_t *p_result, module_ctx_t const *mctx, UNUSED request_t *request)
{
- ippool_common_ctx_t *common_ctx = talloc_get_type_abort(uctx, ippool_common_ctx_t);
+ ippool_common_ctx_t *common_ctx = talloc_get_type_abort(mctx->rctx, ippool_common_ctx_t);
fr_sql_query_t *query_ctx = common_ctx->query_ctx;
rlm_sql_t const *sql = common_ctx->sql;
int affected = 0;
- switch (p_result->rcode) {
+ switch (*p_result) {
case RLM_MODULE_USER_SECTION_REJECT:
return UNLANG_ACTION_CALCULATE_RESULT;
talloc_free(common_ctx);
- if (affected > 0) RETURN_UNLANG_UPDATED;
- RETURN_UNLANG_NOTFOUND;
+ if (affected > 0) RETURN_MODULE_UPDATED;
+ RETURN_MODULE_NOTFOUND;
}
/** Resume function called after mod_common "free" query has completed
*/
-static unlang_action_t mod_common_free_resume(unlang_result_t *p_result, request_t *request, void *uctx)
+static unlang_action_t mod_common_free_resume(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
{
- ippool_common_ctx_t *common_ctx = talloc_get_type_abort(uctx, ippool_common_ctx_t);
+ ippool_common_ctx_t *common_ctx = talloc_get_type_abort(mctx->rctx, ippool_common_ctx_t);
fr_sql_query_t *query_ctx = common_ctx->query_ctx;
rlm_sql_t const *sql = common_ctx->sql;
- switch (p_result->rcode) {
+ switch (*p_result) {
case RLM_MODULE_USER_SECTION_REJECT:
return UNLANG_ACTION_CALCULATE_RESULT;
default:
break;
}
- if (common_ctx->env->update.type != FR_TYPE_STRING) RETURN_UNLANG_NOOP;
+ if (common_ctx->env->update.type != FR_TYPE_STRING) RETURN_MODULE_NOOP;
sql->driver->sql_finish_query(query_ctx, &sql->config);
- if (unlang_function_push(NULL, request, NULL, mod_common_update_resume, NULL, 0, UNLANG_SUB_FRAME, common_ctx) < 0) {
+ if (unlikely(unlang_module_yield(request, mod_common_update_resume, NULL, 0, common_ctx) != UNLANG_ACTION_YIELD)) {
talloc_free(common_ctx);
- RETURN_UNLANG_FAIL;
+ RETURN_MODULE_FAIL;
}
common_ctx->query_ctx->query_str = common_ctx->env->update.vb_strvalue;
*/
if (env->free.type == FR_TYPE_STRING) {
common_ctx->query_ctx->query_str = env->free.vb_strvalue;
- if (unlang_function_push(NULL, request, NULL, mod_common_free_resume, NULL, 0, UNLANG_SUB_FRAME, common_ctx) < 0) {
+ if (unlikely(unlang_module_yield(request, mod_common_free_resume, NULL, 0, common_ctx) != UNLANG_ACTION_YIELD)) {
talloc_free(common_ctx);
RETURN_MODULE_FAIL;
}
}
common_ctx->query_ctx->query_str = env->update.vb_strvalue;
- if (unlang_function_push(NULL, request, NULL, mod_common_update_resume, NULL, 0, UNLANG_SUB_FRAME, common_ctx) < 0) {
+
+ if (unlikely(unlang_module_yield(request, mod_common_update_resume, NULL, 0, common_ctx) != UNLANG_ACTION_YIELD)) {
talloc_free(common_ctx);
RETURN_MODULE_FAIL;
}