]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
give warning on 'foreach' not using [*]
authorAlan T. DeKok <aland@freeradius.org>
Sat, 31 Aug 2024 13:56:08 +0000 (09:56 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 31 Aug 2024 13:56:08 +0000 (09:56 -0400)
src/lib/unlang/compile.c

index b673e00e4ee6a95657d26719c3568268b6866dc9..e30bbf6b80ef80020607c17e2068ee6eeb06feb4 100644 (file)
@@ -3295,18 +3295,16 @@ static unlang_t *compile_foreach(unlang_t *parent, unlang_compile_t *unlang_ctx,
                goto fail;
        }
 
-       if ((tmpl_attr_tail_num(vpt) != NUM_ALL) && (tmpl_attr_tail_num(vpt) != NUM_UNSPEC)) {
+       if (tmpl_attr_tail_num(vpt) == NUM_UNSPEC) {
+               cf_log_warn(cs, "Attribute reference should be updated to use %s[*]", vpt->name);
+               tmpl_attr_rewrite_leaf_num(vpt, NUM_UNSPEC, NUM_ALL);
+       }
+
+       if (tmpl_attr_tail_num(vpt) != NUM_ALL) {
                cf_log_err(cs, "MUST NOT use instance selectors in 'foreach'");
                goto fail;
        }
 
-       /*
-        *      Fix up the template to iterate over all instances of
-        *      the attribute. In a perfect consistent world, users would do
-        *      foreach &attr[*], but that's taking the consistency thing a bit far.
-        */
-       tmpl_attr_rewrite_leaf_num(vpt, NUM_UNSPEC, NUM_ALL);
-
        gext = unlang_group_to_foreach(g);
        gext->vpt = vpt;