From: Alan T. DeKok Date: Wed, 4 Sep 2019 19:15:40 +0000 (-0400) Subject: allow ${...} variable definitions in tmpl_preparse() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ce079f0cdffd1fba7686e7b3966064dbdafc8bc;p=thirdparty%2Ffreeradius-server.git allow ${...} variable definitions in tmpl_preparse() which is the simplest way of dealing with this issue. --- diff --git a/src/lib/server/tmpl.c b/src/lib/server/tmpl.c index 72a823420a9..a1457e686d0 100644 --- a/src/lib/server/tmpl.c +++ b/src/lib/server/tmpl.c @@ -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;