]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
hacks to allow operators inside of grouped sections
authorAlan T. DeKok <aland@freeradius.org>
Mon, 22 Jul 2019 17:11:04 +0000 (13:11 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 22 Jul 2019 17:11:04 +0000 (13:11 -0400)
we should really switch the parser to using a local parse struct
like templates

src/lib/server/cf_file.c
src/tests/keywords/update-group

index 3f514844e1431508e1f9ba80374b9a869ebd5cf5..78699c7a332f928fcf2dfb5da6f8cf009df8b772 100644 (file)
@@ -780,6 +780,7 @@ static int cf_section_read(char const *filename, int *lineno, FILE *fp,
        FR_TOKEN        t1 = T_INVALID, t2, t3;
        bool            has_spaces = false;
        bool            pass2;
+       bool            update_or_map = false;
        char            *cbuff;
        size_t          len;
 
@@ -1402,7 +1403,7 @@ static int cf_section_read(char const *filename, int *lineno, FILE *fp,
                case T_OP_LT:
                case T_OP_CMP_EQ:
                case T_OP_CMP_FALSE:
-                       if (!this || ((strcmp(this->name1, "update") != 0) && (strcmp(this->name1, "map") != 0))) {
+                       if (!this || !update_or_map) {
                                ERROR("%s[%d]: Invalid operator in assignment",
                                      filename, *lineno);
                                goto error;
@@ -1620,6 +1621,15 @@ static int cf_section_read(char const *filename, int *lineno, FILE *fp,
                         *      The current section is now the child section.
                         */
                        this = css;
+
+                       /*
+                        *      Hack for better error messages in
+                        *      nested sections.  This information
+                        *      should really be put into a parser
+                        *      struct, as with tmpls.
+                        */
+                       if (!update_or_map) update_or_map = (strcmp(css->name1, "update") == 0);
+                       if (!update_or_map) update_or_map = (strcmp(css->name1, "map") == 0);
                        break;
 
                case T_INVALID:
index d8d145067ccc88bc5d30acd420cc1e9e882ed863..f071765cb83f4c924fe55c73497437532014a3fa 100644 (file)
@@ -2,15 +2,24 @@
 #  PRE: update
 #
 update reply {
-       #
-       #  This is a TLV, so it's allowed.
-       #
-       #  For now, the grouped attributes are skipped, so they don't
-       #  change the test results.
-       #
-       &WiMAX-Capability := {
-                        &WiMAX-Release := "1.0"
-       }
+       #
+       #  This is a TLV, so it's allowed.
+       #
+       #  For now, the grouped attributes are skipped, so they don't
+       #  change the test results.
+       #
+       &WiMAX-Capability := {
+               &WiMAX-Release := "1.0"
+       }
+}
+
+update reply {
+       &WiMAX-Capability += {
+               #
+               #  Operators are allowed here.
+               #
+               &WiMAX-Release += "1.0"
+       }
 }
 
 success