]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add skip_list option to pair_append_by_tmpl_parent
authorNick Porter <nick@portercomputing.co.uk>
Fri, 27 Jan 2023 08:54:45 +0000 (08:54 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 9 Feb 2023 18:40:36 +0000 (12:40 -0600)
With all attr tmpls having a list as the first ar, need to be able to
skip that when building into temporary lists rather than into
request->pair_root

src/lib/server/tmpl.h
src/lib/server/tmpl_eval.c
src/listen/ldap_sync/proto_ldap_sync_ldap.c

index 136b37db41ad2d84a7e25b03e3ee9cba0af95ef3..035415cb827cfed5e64eb439df29afc889ced352 100644 (file)
@@ -1304,7 +1304,7 @@ int                       tmpl_find_vp(fr_pair_t **out, request_t *request, tmpl_t const *vpt) CC_HI
 int                    tmpl_find_or_add_vp(fr_pair_t **out, request_t *request, tmpl_t const *vpt) CC_HINT(nonnull);
 
 int                    pair_append_by_tmpl_parent(TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t *list,
-                                                  tmpl_t const *vpt) CC_HINT(nonnull(1,3,4));
+                                                  tmpl_t const *vpt, bool skip_list) CC_HINT(nonnull(1,3,4));
 
 int                    tmpl_extents_find(TALLOC_CTX *ctx,
                                          fr_dlist_head_t *leaf, fr_dlist_head_t *interior,
index f88f6f32613640ac6080e931c4a3cfa0569c9fc1..5456b59383207eaffda3aa5e393788d384482a49 100644 (file)
@@ -989,11 +989,12 @@ int tmpl_find_or_add_vp(fr_pair_t **out, request_t *request, tmpl_t const *vpt)
  * @param[out] out     Leaf pair we allocated.
  * @param[in] list     to insert into.
  * @param[in] vpt      tmpl representing the attribute to add.
+ * @param[in] skip_list        skip list attr ref at the head of the tmpl.
  * @return
  *     - 0 on success.
  *     - -1 on failure.
  */
-int pair_append_by_tmpl_parent(TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t *list, tmpl_t const *vpt)
+int pair_append_by_tmpl_parent(TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t *list, tmpl_t const *vpt, bool skip_list)
 {
        fr_pair_t                       *vp = NULL;
        TALLOC_CTX                      *pair_ctx = ctx;
@@ -1008,6 +1009,8 @@ int pair_append_by_tmpl_parent(TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t
 
        leaf = tmpl_attr_list_tail(ar_list);
        ar = tmpl_attr_list_head(ar_list);
+       if (!ar) goto error;
+       if (skip_list && tmpl_attr_is_list_attr(ar)) ar = tmpl_attr_list_next(ar_list, ar);
 
        /*
         *      Walk down the tmpl ar stack looking for candidate parent
index e54a743ecf767d038406761ff8b995f2278d2621..00dda1ecc491eb9ea36054f2f98f225678a36c11 100644 (file)
@@ -478,7 +478,7 @@ int ldap_sync_entry_send(sync_state_t *sync, uint8_t const uuid[SYNC_UUID_LENGTH
                        for (i = 0; i < count; i++) {
                                if (values[i]->bv_len == 0) continue;
 
-                               if (pair_append_by_tmpl_parent(sync_packet_ctx, &vp, pairs, map->lhs) < 0) break;
+                               if (pair_append_by_tmpl_parent(sync_packet_ctx, &vp, pairs, map->lhs, true) < 0) break;
                                if (fr_value_box_from_str(vp, &vp->data, vp->da->type, NULL, values[i]->bv_val,
                                                          values[i]->bv_len, NULL, true) < 0) {
                                        fr_pair_remove(pairs, vp);