From: Nick Porter Date: Tue, 9 May 2023 17:04:33 +0000 (+0100) Subject: Remove sychnronous path from fr_ldap_trunk_search() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8330907da16c1658e12af01c46eab9059d917c09;p=thirdparty%2Ffreeradius-server.git Remove sychnronous path from fr_ldap_trunk_search() --- diff --git a/src/lib/ldap/base.c b/src/lib/ldap/base.c index 294989f1094..43a244cc359 100644 --- a/src/lib/ldap/base.c +++ b/src/lib/ldap/base.c @@ -647,25 +647,6 @@ do { \ } \ } while (0) - -/** Hack to make code work with synchronous interpreter - * - */ -static unlang_action_t ldap_trunk_query_start(UNUSED rlm_rcode_t *p_result, UNUSED int *priority, - UNUSED request_t *request, UNUSED void *uctx) -{ - return UNLANG_ACTION_YIELD; -} - -/** Hack to add timeouts - * - * Here we send a cancellation signal to the trunk if the request hits the timeout limit. - */ -static void _ldap_search_sync_timeout(UNUSED fr_event_list_t *el, UNUSED fr_time_t now, void *uctx) -{ - ldap_trunk_query_cancel(NULL, FR_SIGNAL_CANCEL, uctx); -} - /** Run an async or sync search LDAP query on a trunk connection * * @param[out] p_result from synchronous evaluation. @@ -679,22 +660,15 @@ static void _ldap_search_sync_timeout(UNUSED fr_event_list_t *el, UNUSED fr_time * @param[in] attrs to be returned. * @param[in] serverctrls specific to this query. * @param[in] clientctrls specific to this query. - * @param[in] is_async If true, will return UNLANG_ACTION_YIELD - * and push a search onto the unlang stack - * for the current request. - * If false, will perform a synchronous search - * and provide the result in p_result. * @return * - UNLANG_ACTION_FAIL on error. * - UNLANG_ACTION_PUSHED_CHILD on success. - * - UNLANG_ACTION_CALCULATE_RESULT if the query was run synchronously. */ unlang_action_t fr_ldap_trunk_search(rlm_rcode_t *p_result, TALLOC_CTX *ctx, fr_ldap_query_t **out, request_t *request, fr_ldap_thread_trunk_t *ttrunk, char const *base_dn, int scope, char const *filter, char const * const *attrs, - LDAPControl **serverctrls, LDAPControl **clientctrls, - bool is_async) + LDAPControl **serverctrls, LDAPControl **clientctrls) { unlang_action_t action; fr_ldap_query_t *query; @@ -714,37 +688,13 @@ unlang_action_t fr_ldap_trunk_search(rlm_rcode_t *p_result, return UNLANG_ACTION_FAIL; } - action = unlang_function_push(request, is_async ? NULL : ldap_trunk_query_start, ldap_trunk_query_results, - ldap_trunk_query_cancel, ~FR_SIGNAL_CANCEL, is_async ? UNLANG_SUB_FRAME : UNLANG_TOP_FRAME, query); + action = unlang_function_push(request, NULL, ldap_trunk_query_results, + ldap_trunk_query_cancel, ~FR_SIGNAL_CANCEL, UNLANG_SUB_FRAME, query); if (action == UNLANG_ACTION_FAIL) goto error; *out = query; - /* - * Hack until everything is async - */ - if (!is_async) { - fr_event_timer_t const *ev = NULL; - - fr_time_delta_t timeout = ttrunk->config.res_timeout; - - /* - * Add an event that'll send a cancellation request - * to the request. - */ - if (fr_time_delta_ispos(timeout)) { - if (fr_event_timer_in(ctx, unlang_interpret_event_list(request), &ev, timeout, - _ldap_search_sync_timeout, query) < 0) goto error; - } - - *p_result = unlang_interpret_synchronous(unlang_interpret_event_list(request), request); - - talloc_const_free(ev); /* If the timer fired this should be NULL */ - - return UNLANG_ACTION_CALCULATE_RESULT; - } - return UNLANG_ACTION_PUSHED_CHILD; } diff --git a/src/lib/ldap/base.h b/src/lib/ldap/base.h index 7d102cc0da8..a5f56957d36 100644 --- a/src/lib/ldap/base.h +++ b/src/lib/ldap/base.h @@ -737,8 +737,7 @@ unlang_action_t fr_ldap_trunk_search(rlm_rcode_t *p_result, TALLOC_CTX *ctx, fr_ldap_query_t **out, request_t *request, fr_ldap_thread_trunk_t *ttrunk, char const *base_dn, int scope, char const *filter, char const * const *attrs, - LDAPControl **serverctrls, LDAPControl **clientctrls, - bool is_async); + LDAPControl **serverctrls, LDAPControl **clientctrls); unlang_action_t fr_ldap_trunk_modify(rlm_rcode_t *p_result, TALLOC_CTX *ctx, diff --git a/src/modules/rlm_ldap/groups.c b/src/modules/rlm_ldap/groups.c index 42a3c955e9a..d7753d63085 100644 --- a/src/modules/rlm_ldap/groups.c +++ b/src/modules/rlm_ldap/groups.c @@ -148,7 +148,7 @@ static unlang_action_t ldap_group_name2dn_start(rlm_rcode_t *p_result, UNUSED in return fr_ldap_trunk_search(p_result, group_ctx, &group_ctx->query, request, group_ctx->ttrunk, group_ctx->base_dn->vb_strvalue, inst->groupobj_scope, filter, - null_attrs, NULL, NULL, true); + null_attrs, NULL, NULL); } /** Process the results of looking up group DNs from names @@ -262,7 +262,7 @@ static unlang_action_t ldap_group_dn2name_start(rlm_rcode_t *p_result, UNUSED in RDEBUG2("Resolving group DN \"%s\" to group name", *group_ctx->dn); return fr_ldap_trunk_search(p_result, group_ctx, &group_ctx->query, request, group_ctx->ttrunk, *group_ctx->dn, - LDAP_SCOPE_BASE, NULL, group_ctx->attrs, NULL, NULL, true); + LDAP_SCOPE_BASE, NULL, group_ctx->attrs, NULL, NULL); } /** Process the results of a group DN -> name lookup. @@ -569,8 +569,7 @@ static unlang_action_t ldap_cacheable_groupobj_start(rlm_rcode_t *p_result, UNUS group_ctx->attrs[0] = inst->groupobj_name_attr; return fr_ldap_trunk_search(p_result, group_ctx, &group_ctx->query, request, group_ctx->ttrunk, group_ctx->base_dn->vb_strvalue, inst->groupobj_scope, - group_ctx->filter, group_ctx->attrs, NULL, NULL, true); - + group_ctx->filter, group_ctx->attrs, NULL, NULL); } /** Cancel a pending group object lookup. @@ -850,7 +849,7 @@ static unlang_action_t ldap_dn2name_start (rlm_rcode_t *p_result, UNUSED int *pr return fr_ldap_trunk_search(p_result, group_ctx, &group_ctx->query, request, xlat_ctx->ttrunk, group_ctx->lookup_dn, LDAP_SCOPE_BASE, NULL, group_ctx->attrs, - NULL, NULL, true); + NULL, NULL); } /** Cancel an in-progress DN to name lookup. @@ -877,7 +876,7 @@ static unlang_action_t ldap_check_userobj_start(UNUSED rlm_rcode_t *p_result, UN ldap_memberof_xlat_ctx_t *xlat_ctx = talloc_get_type_abort(group_ctx->xlat_ctx, ldap_memberof_xlat_ctx_t); return fr_ldap_trunk_search(p_result, xlat_ctx, &xlat_ctx->query, request, xlat_ctx->ttrunk, xlat_ctx->dn, - LDAP_SCOPE_BASE, NULL, xlat_ctx->attrs, NULL, NULL, true); + LDAP_SCOPE_BASE, NULL, xlat_ctx->attrs, NULL, NULL); } /** Process the results of evaluating a user object when checking group membership diff --git a/src/modules/rlm_ldap/rlm_ldap.c b/src/modules/rlm_ldap/rlm_ldap.c index 79bf085ede7..145a21f8a1b 100644 --- a/src/modules/rlm_ldap/rlm_ldap.c +++ b/src/modules/rlm_ldap/rlm_ldap.c @@ -1056,7 +1056,7 @@ static unlang_action_t mod_map_proc(rlm_rcode_t *p_result, void *mod_inst, UNUSE return fr_ldap_trunk_search(&rcode, map_ctx, &map_ctx->query, request, ttrunk, ldap_url->lud_dn, ldap_url->lud_scope, ldap_url->lud_filter, map_ctx->expanded.attrs, - NULL, NULL, true); + NULL, NULL); } /** Perform async lookup of user DN if required for authentication @@ -1290,7 +1290,7 @@ static unlang_action_t rlm_ldap_map_profile(request_t *request, ldap_autz_ctx_t return fr_ldap_trunk_search(&ret, profile_ctx, &profile_ctx->query, request, ttrunk, dn, LDAP_SCOPE_BASE, autz_ctx->call_env->profile_filter.vb_strvalue, - expanded->attrs, NULL, NULL, true); + expanded->attrs, NULL, NULL); } /** Start LDAP authorization with async lookup of user DN diff --git a/src/modules/rlm_ldap/user.c b/src/modules/rlm_ldap/user.c index ad00ee40689..7ae36a8784e 100644 --- a/src/modules/rlm_ldap/user.c +++ b/src/modules/rlm_ldap/user.c @@ -171,7 +171,7 @@ unlang_action_t rlm_ldap_find_user_async(TALLOC_CTX *ctx, rlm_ldap_t const *inst return fr_ldap_trunk_search(NULL, user_ctx, &user_ctx->query, request, user_ctx->ttrunk, user_ctx->base_dn, user_ctx->inst->userobj_scope, user_ctx->filter, - user_ctx->attrs, serverctrls, NULL, true); + user_ctx->attrs, serverctrls, NULL); } /** Check for presence of access attribute in result