]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move password.c hack to main pair function
authorAlan T. DeKok <aland@freeradius.org>
Thu, 6 Jul 2023 15:40:20 +0000 (11:40 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 6 Jul 2023 15:40:20 +0000 (11:40 -0400)
and add note that the function should be removed when the nested
pairs are done

src/lib/server/password.c
src/lib/util/pair.c

index cb0347ea8ed72091a37850649c8cd6136029ad14..e282b0eb9a351b0776ee6445a84e0c468f89ac32 100644 (file)
@@ -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;
index 6f0d6e81f2d8abf8721fba8827f78f75aad19b32..9bd877a9a2fc65df1603457c49bf9ee054cc39a7 100644 (file)
@@ -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);