]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
At least _try_ to resolve unresolved attributes in xlats
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 20 Jan 2021 12:05:59 +0000 (12:05 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 20 Jan 2021 12:06:08 +0000 (12:06 +0000)
src/lib/unlang/xlat_tokenize.c

index 4267c8c01f9c500909fcc2ef087b1c925a08c1b3..97e994a85bd8213eaadfdea923c9b82981580448 100644 (file)
@@ -1616,8 +1616,9 @@ int xlat_resolve(xlat_exp_t **head, xlat_flags_t *flags, bool allow_unresolved)
                }
                        break;
                /*
-                *      This covers unresolved attributes as well as
-                *      unresolved functions.
+                *      Virtual unresolved attributes get
+                *      resolved to functions, and failing
+                *      that to a dictionary attribute.
                 */
                case XLAT_VIRTUAL_UNRESOLVED:
                {
@@ -1643,16 +1644,20 @@ int xlat_resolve(xlat_exp_t **head, xlat_flags_t *flags, bool allow_unresolved)
                                node->flags = (xlat_flags_t){ .needs_async = func->needs_async };
                                break;
                        }
+                       FALL_THROUGH;
 
+               /*
+                *      An unresolved attribute
+                */
+               case XLAT_ATTRIBUTE:
                        /*
                         *      Try and resolve (in-place) as an attribute
                         */
-                       if ((tmpl_resolve(node->attr) < 0) || (node->attr->type != TMPL_TYPE_ATTR)) {
+                       if ((tmpl_resolve(node->attr) < 0) || (!tmpl_is_attr(node->attr))) {
                                /*
                                 *      FIXME - Produce proper error with marker
                                 */
                                if (!allow_unresolved) {
-                               error_unresolved:
                                        fr_strerror_printf_push("Failed resolving attribute in expansion %%{%s}",
                                                                node->fmt);
                                        return -1;
@@ -1674,10 +1679,6 @@ int xlat_resolve(xlat_exp_t **head, xlat_flags_t *flags, bool allow_unresolved)
                }
                        break;
 
-               case XLAT_ATTRIBUTE:
-                       if (!allow_unresolved) goto error_unresolved;
-                       break;
-
                default:
                        fr_assert(0);   /* Should not have been marked as unresolved */
                        return -1;