From: Arran Cudbard-Bell Date: Sat, 31 May 2025 21:08:59 +0000 (-0600) Subject: Use unlang_map_yield for LDAP maps X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04426d5895ced0d89e7531e12ce34471bb97a464;p=thirdparty%2Ffreeradius-server.git Use unlang_map_yield for LDAP maps --- diff --git a/src/modules/rlm_ldap/rlm_ldap.c b/src/modules/rlm_ldap/rlm_ldap.c index 4f6df9fe73b..de54e370cb7 100644 --- a/src/modules/rlm_ldap/rlm_ldap.c +++ b/src/modules/rlm_ldap/rlm_ldap.c @@ -45,6 +45,7 @@ USES_APPLE_DEPRECATED_API #include #include +#include #include #include "rlm_ldap.h" @@ -1305,14 +1306,20 @@ static int ldap_map_verify(CONF_SECTION *cs, UNUSED void const *mod_inst, UNUSED /** Process the results of an LDAP map query * - * @param[out] p_result Result of applying the map. - * @param[in] request Current request. - * @param[in] uctx Map context. + * @param[out] p_result Result of map expansion: + * - #RLM_MODULE_NOOP no rows were returned. + * - #RLM_MODULE_UPDATED if one or more #fr_pair_t were added to the #request_t. + * - #RLM_MODULE_FAIL if an error occurred. + * @param[in] mpctx module map ctx. + * @param[in,out] request The current request. + * @param[in] url LDAP url specifying base DN and filter. + * @param[in] maps Head of the map list. * @return One of UNLANG_ACTION_* */ -static unlang_action_t mod_map_resume(unlang_result_t *p_result, request_t *request, void *uctx) +static unlang_action_t mod_map_resume(unlang_result_t *p_result, map_ctx_t const *mpctx, request_t *request, + UNUSED fr_value_box_list_t *url, UNUSED map_list_t const *maps) { - ldap_map_ctx_t *map_ctx = talloc_get_type_abort(uctx, ldap_map_ctx_t); + ldap_map_ctx_t *map_ctx = talloc_get_type_abort(mpctx->rctx, ldap_map_ctx_t); fr_ldap_query_t *query = map_ctx->query; fr_ldap_map_exp_t *expanded = &map_ctx->expanded; rlm_rcode_t rcode = RLM_MODULE_NOTFOUND; @@ -1512,8 +1519,7 @@ static unlang_action_t mod_map_proc(unlang_result_t *p_result, map_ctx_t const * if (host) ldap_memfree(host); if (!ttrunk) goto fail; - if (unlang_function_push(NULL, request, NULL, mod_map_resume, NULL, 0, - UNLANG_SUB_FRAME, map_ctx) != UNLANG_ACTION_PUSHED_CHILD) goto fail; + if (unlikely(unlang_map_yield(request, mod_map_resume, NULL, 0, map_ctx) != UNLANG_ACTION_YIELD)) goto fail; return fr_ldap_trunk_search(map_ctx, &map_ctx->query, request, ttrunk, ldap_url->lud_dn, ldap_url->lud_scope, ldap_url->lud_filter, map_ctx->expanded.attrs,