]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
No need for p_result in async LDAP functions
authorNick Porter <nick@portercomputing.co.uk>
Fri, 8 Sep 2023 09:37:14 +0000 (10:37 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Fri, 8 Sep 2023 09:37:14 +0000 (10:37 +0100)
It was only set on failure, and that is handled by the
UNLANG_ACTION_FAIL return code

src/lib/ldap/base.c
src/lib/ldap/base.h
src/lib/ldap/edir.c
src/modules/rlm_ldap/groups.c
src/modules/rlm_ldap/profile.c
src/modules/rlm_ldap/rlm_ldap.c
src/modules/rlm_ldap/user.c

index 1fe1198306fea1a3a713258cfce735bc4a76126e..0531ad0dfd25a311c5368d4653960fab23bdb389 100644 (file)
@@ -636,9 +636,8 @@ do { \
        } \
 } while (0)
 
-/** Run an async or sync search LDAP query on a trunk connection
+/** Run an async search LDAP query on a trunk connection
  *
- * @param[out] p_result                from synchronous evaluation.
  * @param[in] ctx              to allocate the query in.
  * @param[out] out             that has been allocated.
  * @param[in] request          this query relates to.
@@ -653,8 +652,7 @@ do { \
  *     - UNLANG_ACTION_FAIL on error.
  *     - UNLANG_ACTION_PUSHED_CHILD on success.
  */
-unlang_action_t fr_ldap_trunk_search(rlm_rcode_t *p_result,
-                                    TALLOC_CTX *ctx,
+unlang_action_t fr_ldap_trunk_search(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)
@@ -671,7 +669,6 @@ unlang_action_t fr_ldap_trunk_search(rlm_rcode_t *p_result,
 
        default:
        error:
-               if (p_result) *p_result = RLM_MODULE_FAIL;
                *out = NULL;
                talloc_free(query);
                return UNLANG_ACTION_FAIL;
@@ -689,7 +686,6 @@ unlang_action_t fr_ldap_trunk_search(rlm_rcode_t *p_result,
 
 /** Run an async modification LDAP query on a trunk connection
  *
- * @param[out] p_result                from synchronous evaluation.
  * @param[in] ctx              to allocate the query in.
  * @param[out] out             that has been allocated.
  * @param[in] request          this query relates to.
@@ -702,8 +698,7 @@ unlang_action_t fr_ldap_trunk_search(rlm_rcode_t *p_result,
  *     - UNLANG_ACTION_FAIL on error.
  *     - UNLANG_ACTION_PUSHED_CHILD on success.
  */
-unlang_action_t fr_ldap_trunk_modify(rlm_rcode_t *p_result,
-                                    TALLOC_CTX *ctx,
+unlang_action_t fr_ldap_trunk_modify(TALLOC_CTX *ctx,
                                     fr_ldap_query_t **out, request_t *request, fr_ldap_thread_trunk_t *ttrunk,
                                     char const *dn, LDAPMod *mods[],
                                     LDAPControl **serverctrls, LDAPControl **clientctrls)
@@ -721,7 +716,6 @@ unlang_action_t fr_ldap_trunk_modify(rlm_rcode_t *p_result,
        default:
        error:
                *out = NULL;
-               *p_result = RLM_MODULE_FAIL;
                talloc_free(query);
                return UNLANG_ACTION_FAIL;
        }
@@ -779,7 +773,6 @@ fr_ldap_rcode_t fr_ldap_modify_async(int *msgid, request_t *request, fr_ldap_con
 
 /** Run an async LDAP "extended operation" query on a trunk connection
  *
- * @param[out] p_result                from synchronous evaluation.
  * @param[in] ctx              to allocate the query in.
  * @param[out] out             that has been allocated.
  * @param[in] request          this query relates to.
@@ -792,8 +785,7 @@ fr_ldap_rcode_t fr_ldap_modify_async(int *msgid, request_t *request, fr_ldap_con
  *     - UNLANG_ACTION_FAIL on error.
  *     - UNLANG_ACTION_PUSHED_CHILD on success.
  */
-unlang_action_t fr_ldap_trunk_extended(rlm_rcode_t *p_result,
-                                      TALLOC_CTX *ctx,
+unlang_action_t fr_ldap_trunk_extended(TALLOC_CTX *ctx,
                                       fr_ldap_query_t **out, request_t *request, fr_ldap_thread_trunk_t *ttrunk,
                                       char const *reqoid, struct berval *reqdata,
                                       LDAPControl **serverctrls, LDAPControl **clientctrls)
@@ -811,7 +803,6 @@ unlang_action_t fr_ldap_trunk_extended(rlm_rcode_t *p_result,
        default:
        error:
                *out = NULL;
-               *p_result = RLM_MODULE_FAIL;
                talloc_free(query);
                return UNLANG_ACTION_FAIL;
        }
index b63c8e5e752f3571b4fcdf7681cfa3fccf7f8edd..e8f8e3fd269efff58ae33c30ca6c55827134a761 100644 (file)
@@ -733,20 +733,17 @@ fr_ldap_query_t *fr_ldap_modify_alloc(TALLOC_CTX *ctx, char const *dn,
 fr_ldap_query_t *fr_ldap_extended_alloc(TALLOC_CTX *ctx, char const *reqiod, struct berval *reqdata,
                                        LDAPControl **serverctrls, LDAPControl **clientctrls);
 
-unlang_action_t fr_ldap_trunk_search(rlm_rcode_t *p_result,
-                                    TALLOC_CTX *ctx,
+unlang_action_t fr_ldap_trunk_search(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);
 
-unlang_action_t fr_ldap_trunk_modify(rlm_rcode_t *p_result,
-                                    TALLOC_CTX *ctx,
+unlang_action_t fr_ldap_trunk_modify(TALLOC_CTX *ctx,
                                     fr_ldap_query_t **out, request_t *request, fr_ldap_thread_trunk_t *ttrunk,
                                     char const *dn, LDAPMod *mods[],
                                     LDAPControl **serverctrls, LDAPControl **clientctrls);
 
-unlang_action_t fr_ldap_trunk_extended(rlm_rcode_t *p_result,
-                                      TALLOC_CTX *ctx,
+unlang_action_t fr_ldap_trunk_extended(TALLOC_CTX *ctx,
                                       fr_ldap_query_t **out, request_t *request, fr_ldap_thread_trunk_t *ttrunk,
                                       char const *reqoid, struct berval *reqdata,
                                       LDAPControl **serverctrls, LDAPControl **clientctrls);
index bb181263462d109c62fcc2dda9d046ca7595c202..4c024a6811b9ab86bc0cc8d577351576ed750f1b 100644 (file)
@@ -165,11 +165,11 @@ finish:
  * @param uctx         eDir lookup context.
  * @return One of the RLM_MODULE_* values.
  */
-static unlang_action_t ldap_edir_get_password_start(rlm_rcode_t *p_result, UNUSED int *priority, request_t *request,
+static unlang_action_t ldap_edir_get_password_start(UNUSED rlm_rcode_t *p_result, UNUSED int *priority, request_t *request,
                                                    void *uctx)
 {
        ldap_edir_ctx_t *edir_ctx = talloc_get_type_abort(uctx, ldap_edir_ctx_t);
-       return fr_ldap_trunk_extended(p_result, edir_ctx, &edir_ctx->query, request, edir_ctx->ttrunk,
+       return fr_ldap_trunk_extended(edir_ctx, &edir_ctx->query, request, edir_ctx->ttrunk,
                                      edir_ctx->reqoid, edir_ctx->dn, NULL, NULL);
 }
 
index 38e7ada693923b01634549e3f53fdfcb5e747aa3..e83235132bd8e50f2b35a957bcb4a6952d15b486 100644 (file)
@@ -146,7 +146,7 @@ static unlang_action_t ldap_group_name2dn_start(rlm_rcode_t *p_result, UNUSED in
                                               inst->groupobj_filter ? ")" : "",
                                               group_ctx->group_name[0] && group_ctx->group_name[1] ? ")" : "");
 
-       return fr_ldap_trunk_search(p_result, group_ctx, &group_ctx->query, request, group_ctx->ttrunk,
+       return fr_ldap_trunk_search(group_ctx, &group_ctx->query, request, group_ctx->ttrunk,
                                    group_ctx->base_dn->vb_strvalue, inst->groupobj_scope, filter,
                                    null_attrs, NULL, NULL);
 }
@@ -261,7 +261,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,
+       return fr_ldap_trunk_search(group_ctx, &group_ctx->query, request, group_ctx->ttrunk, *group_ctx->dn,
                                    LDAP_SCOPE_BASE, NULL, group_ctx->attrs, NULL, NULL);
 }
 
@@ -571,14 +571,14 @@ unlang_action_t rlm_ldap_cacheable_userobj(rlm_rcode_t *p_result, request_t *req
  * @param[in] uctx             Group lookup context.
  * @return One of the RLM_MODULE_* values.
  */
-static unlang_action_t ldap_cacheable_groupobj_start(rlm_rcode_t *p_result, UNUSED int *priority, request_t *request,
+static unlang_action_t ldap_cacheable_groupobj_start(UNUSED rlm_rcode_t *p_result, UNUSED int *priority, request_t *request,
                                                     void *uctx)
 {
        ldap_group_groupobj_ctx_t       *group_ctx = talloc_get_type_abort(uctx, ldap_group_groupobj_ctx_t);
        rlm_ldap_t const                *inst = group_ctx->inst;
 
        group_ctx->attrs[0] = inst->groupobj_name_attr;
-       return fr_ldap_trunk_search(p_result, group_ctx, &group_ctx->query, request, group_ctx->ttrunk,
+       return fr_ldap_trunk_search(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);
 }
@@ -858,7 +858,7 @@ static unlang_action_t ldap_dn2name_start (rlm_rcode_t *p_result, UNUSED int *pr
 
        RDEBUG2("Resolving group DN \"%pV\" to group name", fr_box_strvalue_buffer(group_ctx->lookup_dn));
 
-       return fr_ldap_trunk_search(p_result, group_ctx, &group_ctx->query, request, xlat_ctx->ttrunk,
+       return fr_ldap_trunk_search(group_ctx, &group_ctx->query, request, xlat_ctx->ttrunk,
                                    group_ctx->lookup_dn, LDAP_SCOPE_BASE, NULL, group_ctx->attrs,
                                    NULL, NULL);
 }
@@ -880,13 +880,13 @@ static void ldap_dn2name_cancel(UNUSED request_t *request, UNUSED fr_signal_t ac
  * Used when the user's DN is already known but cached group membership has not been stored
  *
  */
-static unlang_action_t ldap_check_userobj_start(rlm_rcode_t *p_result, UNUSED int *priority,
+static unlang_action_t ldap_check_userobj_start(UNUSED rlm_rcode_t *p_result, UNUSED int *priority,
                                                request_t *request, void *uctx)
 {
        ldap_group_userobj_dyn_ctx_t    *group_ctx = talloc_get_type_abort(uctx, ldap_group_userobj_dyn_ctx_t);
        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,
+       return fr_ldap_trunk_search(xlat_ctx, &xlat_ctx->query, request, xlat_ctx->ttrunk, xlat_ctx->dn,
                                    LDAP_SCOPE_BASE, NULL, xlat_ctx->attrs, NULL, NULL);
 }
 
index a567afafe150c135d12296345a5c32765de0354f..0983b06e514967a39863f1cdda1088dff5ea769f 100644 (file)
@@ -152,7 +152,7 @@ unlang_action_t rlm_ldap_map_profile(fr_ldap_result_code_t *ret,
                return UNLANG_ACTION_FAIL;
        }
 
-       return fr_ldap_trunk_search(NULL, profile_ctx, &profile_ctx->query, request, ttrunk, dn,
+       return fr_ldap_trunk_search(profile_ctx, &profile_ctx->query, request, ttrunk, dn,
                                    scope, filter,
                                    expanded->attrs, NULL, NULL);
 }
index a8e6280f8debbeec011ad71df21ab7931143e338..d2c594211e50d77f4fa007863a38ea34cdaac90d 100644 (file)
@@ -1198,7 +1198,6 @@ static int map_ctx_free(ldap_map_ctx_t *map_ctx)
 static unlang_action_t mod_map_proc(rlm_rcode_t *p_result, void *mod_inst, UNUSED void *proc_inst, request_t *request,
                                    fr_value_box_list_t *url, map_list_t const *maps)
 {
-       rlm_rcode_t             rcode = RLM_MODULE_UPDATED;
        rlm_ldap_t              *inst = talloc_get_type_abort(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);
 
@@ -1265,7 +1264,7 @@ static unlang_action_t mod_map_proc(rlm_rcode_t *p_result, void *mod_inst, UNUSE
        if (unlang_function_push(request, NULL, mod_map_resume, NULL, 0,
                                 UNLANG_SUB_FRAME, map_ctx) != UNLANG_ACTION_PUSHED_CHILD) goto fail;
 
-       return fr_ldap_trunk_search(&rcode, map_ctx, &map_ctx->query, request, ttrunk, ldap_url->lud_dn,
+       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,
                                    NULL, NULL);
 }
@@ -1821,7 +1820,7 @@ static unlang_action_t user_modify_resume(rlm_rcode_t *p_result, UNUSED int *pri
        if (unlang_function_push(request, NULL, user_modify_final, user_modify_cancel, ~FR_SIGNAL_CANCEL,
                                 UNLANG_SUB_FRAME, usermod_ctx) < 0) goto fail;
 
-       return fr_ldap_trunk_modify(p_result, usermod_ctx, &usermod_ctx->query, request, usermod_ctx->ttrunk,
+       return fr_ldap_trunk_modify(usermod_ctx, &usermod_ctx->query, request, usermod_ctx->ttrunk,
                                    usermod_ctx->dn, modify, NULL, NULL);
 }
 
index 7101ad646c2f330f60b3039cfda89901e0e27f1b..f763e3cf924b7847c0d3b4e2a23009606d78b874 100644 (file)
@@ -179,7 +179,7 @@ unlang_action_t rlm_ldap_find_user_async(TALLOC_CTX *ctx, rlm_ldap_t const *inst
                return UNLANG_ACTION_FAIL;
        }
 
-       return fr_ldap_trunk_search(NULL, user_ctx, &user_ctx->query, request, user_ctx->ttrunk,
+       return fr_ldap_trunk_search(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);
 }