]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
call xlat_init() manually, before registering any xlats
authorAlan T. DeKok <aland@freeradius.org>
Thu, 7 Jul 2022 14:59:56 +0000 (10:59 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 7 Jul 2022 15:05:24 +0000 (11:05 -0400)
so that we don't need to check xlat_root every time we try to
register an xlat

src/lib/server/main_config.c
src/lib/unlang/xlat_builtin.c
src/tests/unit/xlat/cond_base.txt

index 84912ca2f0a1b456ecb54441492c6b486922e5fe..36b4b77bb7f05af5a3cb1755094fadc691034414 100644 (file)
@@ -983,6 +983,11 @@ int main_config_init(main_config_t *config)
        char            buffer[1024];
        xlat_t          *xlat;
 
+       /*
+        *      Initialize the xlats before we load the configuration files, so that we can later call xlat_register().
+        */
+       xlat_init();
+
        if (stat(config->raddb_dir, &statbuf) < 0) {
                ERROR("Error checking raddb_dir \"%s\": %s", config->raddb_dir, fr_syserror(errno));
                return -1;
index 45efd54a276acd41f158ca477eda20312fb4e69a..ade0c843a978095a730bb9adef7ca45af958c226 100644 (file)
@@ -173,7 +173,7 @@ xlat_t *xlat_register_module(TALLOC_CTX *ctx, module_inst_ctx_t const *mctx,
        xlat_t  *c;
        module_inst_ctx_t *our_mctx = NULL;
 
-       if (!xlat_root) xlat_init();
+       fr_assert(xlat_root);
 
        if (!*name) {
                ERROR("%s: Invalid xlat name", __FUNCTION__);
index 97b20c00157776a6dd452bb1a325543ce0c88d7c..3c50b3a98eaf8afccea4ed24360b79ee714a2909 100644 (file)
@@ -572,10 +572,13 @@ xlat_purify &User-Name[-1] == 'bob'
 match ERROR offset 11: Invalid array index '-1' (should be between 0-1000)
 
 #
-#  The attribute/xlat_purify parser does not fall back to bare words
+#  attributes MUST be prefixed with '&'.
 #
 xlat_purify request.Foo == 'request.Foo'
-match ERROR offset 0: Failed resolving attribute in expansion: request.Foo
+match true
+
+xlat_purify &request.Foo == 'request.Foo'
+match ERROR offset 9: Attribute 'Foo' not found in namespace 'internal': Unresolved attributes are not allowed here
 
 xlat_purify &not-a-list.User-Name == &not-a-list.User-Name
 match ERROR offset 1: Attribute 'not' not found.  Searched in: RADIUS, internal: Unresolved attributes are not allowed here
@@ -761,4 +764,4 @@ match %{rcode:'handled'}
 
 
 count
-match 314
+match 316