]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Remove sychnronous path from fr_ldap_trunk_search()
authorNick Porter <nick@portercomputing.co.uk>
Tue, 9 May 2023 17:04:33 +0000 (18:04 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Sat, 20 May 2023 20:52:49 +0000 (21:52 +0100)
src/lib/ldap/base.c
src/lib/ldap/base.h
src/modules/rlm_ldap/groups.c
src/modules/rlm_ldap/rlm_ldap.c
src/modules/rlm_ldap/user.c

index 294989f1094d805c7647f051ff983c1edbe18bbe..43a244cc359ef6e4004535bf4a0787de14859074 100644 (file)
@@ -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;
 }
 
index 7d102cc0da8b88b65cec95c2f6843e712cc2d80a..a5f56957d369634f96fc59b4cd40cd4092c4162f 100644 (file)
@@ -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,
index 42a3c955e9ab967bd001ee5587bc7c11138efe6d..d7753d6308551b374b9afe9e875296cb9a318d37 100644 (file)
@@ -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
index 79bf085ede7f515566071ea0444ec9805aeafd27..145a21f8a1b512ac66a245d474260cef20426dc6 100644 (file)
@@ -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
index ad00ee406890ab5b58830c3139efbd0386dc2358..7ae36a8784e2f354179b31790114d8e226b144aa 100644 (file)
@@ -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