From: Alan T. DeKok Date: Thu, 6 Jul 2023 15:40:20 +0000 (-0400) Subject: move password.c hack to main pair function X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a15e67dd663acd5395fcfae98654b36f11d049c;p=thirdparty%2Ffreeradius-server.git move password.c hack to main pair function and add note that the function should be removed when the nested pairs are done --- diff --git a/src/lib/server/password.c b/src/lib/server/password.c index cb0347ea8ed..e282b0eb9a3 100644 --- a/src/lib/server/password.c +++ b/src/lib/server/password.c @@ -965,7 +965,6 @@ fr_pair_t *password_find(bool *ephemeral, TALLOC_CTX *ctx, request_t *request, { fr_dcursor_t cursor; fr_pair_t *known_good; - fr_pair_t *password_tlv; if (fr_pair_find_by_da(&request->control_pairs, NULL, attr_user) != NULL) { RWDEBUG("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); @@ -976,17 +975,7 @@ fr_pair_t *password_find(bool *ephemeral, TALLOC_CTX *ctx, request_t *request, RWDEBUG("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); } - /* - * Allow nested (or not); - */ - password_tlv = fr_pair_find_by_da(&request->control_pairs, NULL, attr_root); - if (!password_tlv) { - known_good = fr_pair_dcursor_by_ancestor_init(&cursor, &request->control_pairs, attr_root); - } else { - known_good = fr_pair_dcursor_init(&cursor, &password_tlv->vp_group); - } - - for ( /* nothing */; + for (known_good = fr_pair_dcursor_by_ancestor_init(&cursor, &request->control_pairs, attr_root); known_good; known_good = fr_dcursor_next(&cursor)) { password_info_t *info; diff --git a/src/lib/util/pair.c b/src/lib/util/pair.c index 6f0d6e81f2d..9bd877a9a2f 100644 --- a/src/lib/util/pair.c +++ b/src/lib/util/pair.c @@ -1111,6 +1111,25 @@ fr_pair_t *_fr_pair_dcursor_by_ancestor_init(fr_dcursor_t *cursor, fr_pair_list_t const *list, fr_dict_attr_t const *da, bool is_const) { + fr_pair_t *vp; + + fr_assert(fr_type_is_structural(da->type)); + + /* + * This function is only used by snmp.c and password.c. Once we've fully moved to + * nested attributes, it should be removed. + */ + fr_assert(da->parent->flags.is_root); + + vp = fr_pair_find_by_da(list, NULL, da); + if (vp) { + list = &vp->vp_group; + + return _fr_dcursor_init(cursor, fr_pair_order_list_dlist_head(&list->order), + NULL, NULL, NULL, + _pair_list_dcursor_insert, _pair_list_dcursor_remove, list, is_const); + } + return _fr_dcursor_init(cursor, fr_pair_order_list_dlist_head(&list->order), fr_pair_iter_next_by_ancestor, NULL, da, _pair_list_dcursor_insert, _pair_list_dcursor_remove, list, is_const);