]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
xlat_instantiate_ephemeral() will now call xlat_resolve()
authorAlan T. DeKok <aland@freeradius.org>
Thu, 26 May 2022 18:37:50 +0000 (14:37 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 3 Jun 2022 11:15:42 +0000 (07:15 -0400)
if needed

src/lib/unlang/xlat_expr.c
src/lib/unlang/xlat_inst.c
src/tests/unit/xlat/cond_base.txt

index c18a454e6611fa30eec9f9b7d68a79b350847595..bb6f269095447b64d6e56089801eb167fbe07017 100644 (file)
@@ -1581,21 +1581,10 @@ ssize_t xlat_tokenize_ephemeral_expression(TALLOC_CTX *ctx, xlat_exp_head_t **ou
                return slen;
        }
 
-       /*
-        *      Ensure that everything is resolved otherwise we have
-        *      no idea what to do.
-        */
-       if (head->flags.needs_resolving &&
-           (xlat_resolve(head, &(xlat_res_rules_t){ .allow_unresolved = false }) < 0)) {
-               talloc_free(head);
-               return -1;
-       }
-
        /*
         *      Create ephemeral instance data for the xlat
         */
        if (xlat_instantiate_ephemeral(head, el) < 0) {
-               fr_strerror_const("Failed performing ephemeral instantiation for xlat");
                talloc_free(head);
                return 0;
        }
index 816a2724f27664ce6b736749c38dff6c49d0eb1c..730db55082202552880d4b46985a04dade122ddc 100644 (file)
@@ -331,6 +331,15 @@ int xlat_instantiate_ephemeral(xlat_exp_head_t *head, fr_event_list_t *el)
 {
        int ret;
 
+       /*
+        *      The caller MAY resolve it, or may not.  If the caller
+        *      hasn't resolved it, then we can't allow any unresolved
+        *      functions or attributes.
+        */
+       if (head->flags.needs_resolving) {
+               if (xlat_resolve(head, &(xlat_res_rules_t){ .allow_unresolved = false }) < 0) return -1;
+       }
+
        if (head->instantiated) return 0;
 
        ret = xlat_eval_walk(head, _xlat_instantiate_ephemeral_walker, XLAT_INVALID, el);
index b796c8b78f0b21c21e8c39a82000c894976d961c..dc0c2f39653ab490596667ec7f0157f4ea88e4c4 100644 (file)
@@ -34,7 +34,7 @@ match ERROR offset 4: Unexpected text after enum value.  Expected operator
 #  @todo - this is an error somehow?
 #
 xlat_purify (Service-Type == 000-111)
-match ERROR offset 1: No IPv6 component separator: Failed resolving attribute in expansion: Service-Type
+match ERROR offset 0: No IPv6 component separator: Failed resolving attribute in expansion: Service-Type
 #match (&Service-Type == (0 - 111))
 
 xlat_purify (ok FOO handled)
@@ -230,7 +230,7 @@ match (&Event-Timestamp == "January 1, 2012 %{Request[0].User-Name}")
 #  @todo - can't parse years?
 #
 xlat_purify &Event-Timestamp == 'January 1, 2012'
-match ERROR offset 1: Invalid year string
+match ERROR offset 0: Invalid year string
 #match (&Event-Timestamp == 'Jan  1 2012 00:00:00 EST')
 
 # literals are parsed when the conditions are parsed
@@ -242,7 +242,7 @@ match ERROR offset 10: Failed parsing string as type 'uint32'
 #  string the RHS is. 
 #
 xlat_purify &NAS-Port == X
-match ERROR offset 1: Failed parsing string as type 'uint32'
+match ERROR offset 0: Failed parsing string as type 'uint32'
 #match ERROR offset 13: Failed parsing string as type 'uint32'
 
 #
@@ -582,12 +582,12 @@ match ERROR offset 11: Invalid array index '-1' (should be between 0-1000)
 #  The attribute/xlat_purify parser does not fall back to bare words
 #
 xlat_purify request.Foo == 'request.Foo'
-match ERROR offset 1: Invalid attribute reference, missing '&' prefix: Failed resolving attribute in expansion: request.Foo
+match ERROR offset 0: Invalid attribute reference, missing '&' prefix: Failed resolving attribute in expansion: request.Foo
 
 xlat_purify &not-a-list.User-Name == &not-a-list.User-Name
 match ERROR offset 1: Attribute 'not' not found.  Searched in: RADIUS, internal: Unresolved attributes are not allowed here
 
-# . is a valid dictionarxy name attribute, so we can't error out in pass1
+# . is a valid dictionary name attribute, so we can't error out in pass1
 xlat_purify &not-a-packet.User-Name == &not-a-packet.User-Name
 match ERROR offset 1: Attribute 'not' not found.  Searched in: RADIUS, internal: Unresolved attributes are not allowed here