]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
allow ${...} variable definitions in tmpl_preparse()
authorAlan T. DeKok <aland@freeradius.org>
Wed, 4 Sep 2019 19:15:40 +0000 (15:15 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 4 Sep 2019 19:53:33 +0000 (15:53 -0400)
which is the simplest way of dealing with this issue.

src/lib/server/tmpl.c

index 72a823420a9a577b55eff49c07031374afae9fa9..a1457e686d0091e26986c252b9f31c6584da95cd 100644 (file)
@@ -2998,6 +2998,37 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *start,
        }
 
        switch (*p) {
+               /*
+                *      Magic handling for variable expansions in the
+                *      configuration files.
+                *
+                *      @todo - make this configurable
+                */
+       case '$':
+               if (p[1] != '{') {
+                       return_P("Unexpected '$'");
+               }
+
+               *out = p;
+               *type = T_BARE_WORD;
+
+               p += 2;
+               while (*p && (*p != '}')) {
+                       if (isspace((int) *p)) {
+                               return_P("Unexpected space in variable expansion");
+                       }
+
+                       p++;
+               }
+
+               if (!*p) {
+                       return_P("Unexpected end of variable expansion");
+               }
+               p++;
+               *outlen = p - (*out);
+               break;
+
+
        case '/':
                quote = *(p++);
                *type = T_OP_REG_EQ;