expose server version to xlat
authorAlan Buxey <alan.buxey@gmail.com>
Wed, 26 Mar 2014 20:19:07 +0000 (20:19 +0000)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 26 Mar 2014 22:54:48 +0000 (18:54 -0400)
expose server version to slat (so we can print it out in e.g. line log
with %v).

I note that a few expansions are present but are in variables.rst -
e.g.  %C, %V and %Z

src/main/xlat.c

index 9f94190..47c5672 100644 (file)
@@ -104,6 +104,7 @@ static char const * const xlat_foreach_names[] = {"Foreach-Variable-0",
 #endif
 static int xlat_inst[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };        /* up to 8 for regex */
 
+char const *radiusd_short_version = RADIUSD_VERSION_STRING;
 
 #ifdef WITH_UNLANG
 /** Convert the value on a VALUE_PAIR to string
@@ -1238,7 +1239,7 @@ static ssize_t xlat_tokenize_literal(TALLOC_CTX *ctx, char *fmt, xlat_exp_t **he
                        ssize_t slen;
                        xlat_exp_t *next;
 
-                       if (!p[1] || !strchr("%dlmtDGHISTY", p[1])) {
+                       if (!p[1] || !strchr("%dlmtDGHISTYv", p[1])) {
                                        talloc_free(node);
                                        *error = "Invalid variable expansion";
                                        p++;
@@ -1965,6 +1966,10 @@ static char *xlat_aprint(TALLOC_CTX *ctx, REQUEST *request, xlat_exp_t const * c
                        strftime(str, freespace, "%Y", &ts);
                        break;
 
+               case 'v': /* Version of code */
+                       snprintf(str, freespace, "%s", radiusd_short_version);
+                       break;
+
                default:
                        rad_assert(0 == 1);
                        break;