]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
allow ::name for enum names
authorAlan T. DeKok <aland@freeradius.org>
Sun, 3 Sep 2023 12:59:36 +0000 (08:59 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 3 Sep 2023 12:59:36 +0000 (08:59 -0400)
src/lib/server/tmpl_tokenize.c
src/tests/keywords/enum-name [new file with mode: 0644]

index 6b8414d50490e95561f8814678b74441239e66e2..b75726cda850a5f543c014f9f4430d7a0c0aa342 100644 (file)
@@ -2878,6 +2878,20 @@ fr_slen_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out,
                if (fr_sbuff_is_char(&our_in, '&')) return tmpl_afrom_attr_substr(ctx, NULL, out, in,
                                                                                  p_rules, t_rules);
 
+               /*
+                *      ::value
+                *
+                *      Treated as enum name.
+                *
+                *      @todo - move the enum parsing here, and then unresolved tmpls _always_ become xlat references.
+                *      and when we fix that, change the enum name to include the ::
+                */
+               if (fr_sbuff_is_str_literal(&our_in, "::")) {
+                       (void) fr_sbuff_advance(&our_in, 2);
+                       goto do_enum;
+               }
+
+
                /*
                 *      Allow bareword xlats if we
                 *      find a '%' prefix.
@@ -2995,6 +3009,7 @@ fr_slen_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out,
                /*
                 *      Attempt to resolve enumeration values
                 */
+       do_enum:
                vpt = tmpl_alloc_null(ctx);
 
                /*
diff --git a/src/tests/keywords/enum-name b/src/tests/keywords/enum-name
new file mode 100644 (file)
index 0000000..1220606
--- /dev/null
@@ -0,0 +1,7 @@
+&Service-Type := ::Framed-User
+
+if !(&Service-Type == ::Framed-User) {
+       test_fail
+}
+
+success