]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
remove old-style functions %(foo:bar)
authorAlan T. DeKok <aland@freeradius.org>
Tue, 26 Mar 2024 11:15:24 +0000 (07:15 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 26 Mar 2024 11:17:34 +0000 (07:17 -0400)
doc/antora/modules/installation/pages/upgrade.adoc
doc/antora/modules/raddb/pages/mods-available/client.adoc
raddb/mods-available/client
src/lib/unlang/xlat_priv.h
src/lib/unlang/xlat_tokenize.c

index 41b136cb8daa7d0fc2b1184521241f540fd160b8..e334b182f86f44a0727f863301b88d29b12c2c69 100644 (file)
@@ -1020,7 +1020,7 @@ will no longer work.
 
 === rlm_winbind
 
-The `winbind` module uses an expansion `%(winbind.group(<name>)` instead of
+The `winbind` module uses an expansion `%winbind.group(<name>)` instead of
 `Winbind-Group == <name>`.
 
 == Deleted Modules
index 3335590c3b0b3cab91fd01208d69adc3fb3f8eae..7eb2ea629d12cce07df1dd1ebf38b4fd6b3ddb5b 100644 (file)
@@ -73,8 +73,8 @@ map client [<ipaddr>] {      // <1>
 [options="header,autowidth"]
 |===
 | XLAT                           | Description
-| `%client(<field>)`             | Expands to a field in the client definition.
-| `%(client(<field>, <ipaddr>)`  | Expands to a field in the client definition specified by `<ipaddr>`.
+| `%client(<field>)`             | Expands to the named _field_ in the current client definition.
+| `%client(<field>, <ipaddr>)`   | Expands to the named _field_ in the client specified by _ipaddr_.
 |===
 
 
index 96f8e7b2c6d2a2fac247f8859a3991450d3411c9..dbe743d230947174f7503401c0c4c620445dbb6d 100644 (file)
@@ -76,8 +76,8 @@
 #  [options="header,autowidth"]
 #  |===
 #  | XLAT                           | Description
-#  | `%client(<field>)`             | Expands to a field in the client definition.
-#  | `%(client(<field>, <ipaddr>)`  | Expands to a field in the client definition specified by `<ipaddr>`.
+#  | `%client(<field>)`             | Expands to the named _field_ in the current client definition.
+#  | `%client(<field>, <ipaddr>)`   | Expands to the named _field_ in the client specified by _ipaddr_.
 #  |===
 #
 
index 7a656094602c13d0f493f2ab50f5f3fa1e8bc44e..bdf7ab068ec85e73d93f5828e9eaec0a6a36260b 100644 (file)
@@ -336,9 +336,6 @@ int         xlat_register_expressions(void);
 int            xlat_tokenize_expansion(xlat_exp_head_t *head, fr_sbuff_t *in,
                                        tmpl_rules_t const *t_rules);
 
-int            xlat_tokenize_function_args(xlat_exp_head_t *head, fr_sbuff_t *in,
-                                           tmpl_rules_t const *t_rules);
-
 ssize_t                xlat_print_node(fr_sbuff_t *out, xlat_exp_head_t const *head, xlat_exp_t const *node,
                                fr_sbuff_escape_rules_t const *e_rules, char c);
 
index c6747504bc92b014ed84345f275b2422de38b4f8..202e8acfb8c5d50d27dc113ef39e91455cd87e16 100644 (file)
@@ -99,12 +99,7 @@ static fr_sbuff_escape_rules_t const xlat_escape = {
  * The caller sets the literal parse rules for outside of expansions when they
  * call xlat_tokenize.
  */
-static fr_sbuff_parse_rules_t const xlat_multi_arg_rules = {
-       .escapes = &xlat_unescape,
-       .terminals = &FR_SBUFF_TERM(")")        /* These get merged with other literal terminals */
-};
-
-static fr_sbuff_parse_rules_t const xlat_new_arg_rules = {
+static fr_sbuff_parse_rules_t const xlat_function_arg_rules = {
        .escapes = &xlat_unescape,
        .terminals = &FR_SBUFF_TERMS( /* These get merged with other literal terminals */
                                L(")"),
@@ -278,107 +273,6 @@ int xlat_validate_function_args(xlat_exp_t *node)
        return 0;
 }
 
-/** Parse an xlat function and its child arguments
- *
- * Parses a function call string in the format
- * @verbatim %(<func>:<arguments>) @endverbatim
- *
- * @return
- *     - 0 if the string was parsed into a function.
- *     - <0 on parse error.
- */
-int xlat_tokenize_function_args(xlat_exp_head_t *head, fr_sbuff_t *in, tmpl_rules_t const *t_rules)
-{
-       xlat_exp_t              *node;
-       xlat_t                  *func;
-       fr_sbuff_marker_t       m_s;
-
-       /*
-        *      Special characters, spaces, etc. cannot be
-        *      module names.
-        */
-       XLAT_DEBUG("FUNC-ARGS <-- %.*s", (int) fr_sbuff_remaining(in), fr_sbuff_current(in));
-
-       /*
-        *      %(function:args)
-        */
-       fr_sbuff_marker(&m_s, in);
-       fr_sbuff_adv_past_allowed(in, SIZE_MAX, xlat_func_chars, NULL);
-
-       if (!fr_sbuff_is_char(in, ':')) {
-               fr_strerror_const("Can't find function/argument separator");
-       bad_function:
-               fr_sbuff_set(in, &m_s);         /* backtrack */
-               fr_sbuff_marker_release(&m_s);
-               return -1;
-       }
-
-       func = xlat_func_find(fr_sbuff_current(&m_s), fr_sbuff_behind(&m_s));
-
-       /*
-        *      Allocate a node to hold the function
-        */
-       node = xlat_exp_alloc(head, XLAT_FUNC, fr_sbuff_current(&m_s), fr_sbuff_behind(&m_s));
-       if (!func) {
-               if (!t_rules || !t_rules->attr.allow_unresolved || t_rules->at_runtime) {
-                       fr_strerror_const("Unresolved expansion functions are not allowed here");
-                       goto bad_function;
-               }
-               xlat_exp_set_type(node, XLAT_FUNC_UNRESOLVED);
-               node->flags.needs_resolving = true;     /* Needs resolution during pass2 */
-       } else {
-               if (func->input_type != XLAT_INPUT_ARGS) {
-                       fr_strerror_const("Function should be called using %{func:arg} syntax");
-               error:
-                       talloc_free(node);
-                       return -1;
-               }
-               node->call.func = func;
-               if (t_rules) node->call.dict = t_rules->attr.dict_def;
-               node->flags = func->flags;
-       }
-
-       /*
-        *      Record the calling style, this is useful
-        *      for checking later with unresolved
-        *      functions, for printing accurate debug
-        *      info, and for weird xlats like the
-        *      redundant xlat
-        */
-       node->call.input_type = XLAT_INPUT_ARGS;
-
-       fr_sbuff_next(in);                      /* Skip the ':' */
-       XLAT_DEBUG("FUNC-ARGS <-- %s ... %.*s", node->fmt, (int) fr_sbuff_remaining(in), fr_sbuff_current(in));
-
-       fr_sbuff_marker_release(&m_s);
-
-       /*
-        *      Now parse the child nodes that form the
-        *      function's arguments.
-        */
-       if (xlat_tokenize_argv(node, &node->call.args, in, func, &xlat_multi_arg_rules, t_rules, false, false) < 0) {
-               goto error;
-       }
-       xlat_flags_merge(&node->flags, &node->call.args->flags);
-
-       /*
-        *      Check we have all the required arguments
-        */
-       if (node->type == XLAT_FUNC) {
-               if (xlat_validate_function_args(node) < 0) goto error;
-
-               node->flags.can_purify = (node->call.func->flags.pure && node->call.args->flags.pure) | node->call.args->flags.can_purify;
-       }
-
-       if (!fr_sbuff_next_if_char(in, ')')) {
-               fr_strerror_const("Missing closing brace");
-               goto error;
-       }
-
-       xlat_exp_insert_tail(head, node);
-       return 0;
-}
-
 /** Parse an xlat function and its child argument
  *
  * Parses a function call string in the format
@@ -388,7 +282,7 @@ int xlat_tokenize_function_args(xlat_exp_head_t *head, fr_sbuff_t *in, tmpl_rule
  *     - 0 if the string was parsed into a function.
  *     - <0 on parse error.
  */
-static int xlat_tokenize_function_new(xlat_exp_head_t *head, fr_sbuff_t *in, tmpl_rules_t const *t_rules)
+static int xlat_tokenize_function_args(xlat_exp_head_t *head, fr_sbuff_t *in, tmpl_rules_t const *t_rules)
 {
        char c;
        xlat_exp_t *node;
@@ -502,7 +396,7 @@ static int xlat_tokenize_function_new(xlat_exp_head_t *head, fr_sbuff_t *in, tmp
         *      function's arguments.
         */
        if (xlat_tokenize_argv(node, &node->call.args, in, func,
-                              &xlat_new_arg_rules, t_rules, true, (node->call.input_type == XLAT_INPUT_MONO)) < 0) {
+                              &xlat_function_arg_rules, t_rules, true, (node->call.input_type == XLAT_INPUT_MONO)) < 0) {
 error:
                talloc_free(node);
                return -1;
@@ -988,15 +882,6 @@ static int xlat_tokenize_input(xlat_exp_head_t *head, fr_sbuff_t *in,
                        continue;
                }
 
-               /*
-                *      xlat function call with discrete arguments
-                */
-               if (fr_sbuff_adv_past_str_literal(in, "%(")) {
-                       TALLOC_FREE(node); /* nope, couldn't use it */
-                       if (xlat_tokenize_function_args(head, in, t_rules) < 0) goto error;
-                       goto next;
-               }
-
                /*
                 *      More migration hacks: allow %foo(...)
                 */
@@ -1016,7 +901,7 @@ static int xlat_tokenize_input(xlat_exp_head_t *head, fr_sbuff_t *in,
                        /*
                         *      Tokenize the function arguments using the new method.
                         */
-                       if (xlat_tokenize_function_new(head, in, t_rules) < 0) goto error;
+                       if (xlat_tokenize_function_args(head, in, t_rules) < 0) goto error;
                        goto next;
                }