]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
just move everything to xlat_bootstrap()
authorAlan T. DeKok <aland@freeradius.org>
Sun, 8 Oct 2023 00:32:42 +0000 (20:32 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 8 Oct 2023 00:32:42 +0000 (20:32 -0400)
src/lib/server/tmpl_tokenize.c
src/lib/server/trigger.c
src/lib/unlang/xlat.h
src/lib/unlang/xlat_expr.c
src/lib/unlang/xlat_inst.c
src/lib/unlang/xlat_redundant.c
src/lib/unlang/xlat_tokenize.c

index df05f6d954f8df5fa311b50b5b69eff532167a1e..1c6c33aebe6d2d136dc09b269d4037fd9fa0d9e6 100644 (file)
@@ -3278,7 +3278,7 @@ fr_slen_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out,
                 *      so that their instance data will be created.
                 */
                if (head) {
-                       if (xlat_finalize(head, t_rules) < 0) {
+                       if (xlat_bootstrap(head, t_rules) < 0) {
                                fr_strerror_const("Failed to bootstrap xlat");
                                FR_SBUFF_ERROR_RETURN(&our_in);
                        }
index 67d2bc06a5d065fb839c50a9ddfff24449b0820d..eb600b3e85796d968dbb02e5335e55b2f459a77c 100644 (file)
@@ -460,8 +460,12 @@ int trigger_exec(unlang_interpret_t *intp,
                }
        }
 
-       if (xlat_instantiate_ephemeral(trigger->xlat,
-                                      (intp ? unlang_interpret_event_list(request) : main_loop_event_list())) < 0) {
+       if (xlat_bootstrap(trigger->xlat, &(tmpl_rules_t ) {
+                                       .xlat = {
+                                               .runtime_el = intp ? unlang_interpret_event_list(request) : main_loop_event_list(),
+                                       },
+                                       .at_runtime = true
+                       }) < 0) {
                fr_strerror_const("Failed performing ephemeral instantiation for xlat");
                talloc_free(request);
                return -1;
index d9a39a3cf581402ba108d5f3dd3506c4182eef58..b7775963f6a7157432056330f50361bba00a613e 100644 (file)
@@ -450,8 +450,6 @@ void                xlat_exp_head_verify(xlat_exp_head_t const *head);
 /*
  *     xlat_inst.c
  */
-int            xlat_instantiate_ephemeral(xlat_exp_head_t *head, fr_event_list_t *el) CC_HINT(nonnull(1));
-
 xlat_thread_inst_t *xlat_thread_instance_find(xlat_exp_t const *node);
 
 int            xlat_thread_instantiate(TALLOC_CTX *ctx, fr_event_list_t *el);
@@ -462,12 +460,10 @@ void              xlat_thread_detach(void);
 
 int            xlat_bootstrap_func(xlat_exp_t *node);
 
-int            xlat_bootstrap(xlat_exp_head_t *root);
+int            xlat_bootstrap(xlat_exp_head_t *root, tmpl_rules_t const *t_rules);
 
 void           xlat_instances_free(void);
 
-int            xlat_finalize(xlat_exp_head_t *head, tmpl_rules_t const *t_rules); /* xlat_bootstrap() or xlat_instantiate_ephemeral() */
-
 /*
  *     xlat_purify.c
  */
index 0bbdadc6434e3df8aa976712ef05373dd3169cc8..3e57b0972444b3ec7f2e58cfbe3282cecc8f9ceb 100644 (file)
@@ -2907,7 +2907,7 @@ static fr_slen_t xlat_tokenize_expression_internal(TALLOC_CTX *ctx, xlat_exp_hea
         *      Add nodes that need to be bootstrapped to
         *      the registry.
         */
-       if (xlat_finalize(head, t_rules) < 0) {
+       if (xlat_bootstrap(head, t_rules) < 0) {
                talloc_free(head);
                return -1;
        }
index 4f687ec3909461c8a8ebd180e04c431aaa21ce9c..7270ce1671cf62313a7b53ff245b3053322cd178 100644 (file)
@@ -31,6 +31,8 @@ RCSID("$Id$")
 #include <freeradius-devel/util/debug.h>
 #include <freeradius-devel/util/heap.h>
 
+static int xlat_instantiate_ephemeral(xlat_exp_head_t *head, fr_event_list_t *el);
+
 /** Holds instance data created by xlat_instantiate
  */
 static fr_heap_t *xlat_inst_tree;
@@ -349,26 +351,6 @@ static int _xlat_instantiate_ephemeral_walker(xlat_exp_t *node, void *uctx)
 }
 
 
-/** Bootstrap static xlats, or instantiate ephemeral ones.
- *
- *  @note - this function should be called when we have a
- *  #tmpl_rules_t.  i.e. instead of calling xlat_bootstrap() or
- *  xlat_instantiate_ephemeral()
- *
- * @param[in] head of xlat tree to create instance data for.
- * @param[in] t_rules parsing rules with #fr_event_list_t
- */
-int xlat_finalize(xlat_exp_head_t *head, tmpl_rules_t const *t_rules)
-{
-       if (!t_rules || !t_rules->xlat.runtime_el) {
-               fr_assert(!t_rules || !t_rules->at_runtime);
-               return xlat_bootstrap(head);
-       }
-
-       fr_assert(t_rules && t_rules->at_runtime);
-       return xlat_instantiate_ephemeral(head, t_rules->xlat.runtime_el);
-}
-
 /** Create instance data for "ephemeral" xlats
  *
  * @note This function should only be called from routines which get
@@ -377,7 +359,7 @@ int xlat_finalize(xlat_exp_head_t *head, tmpl_rules_t const *t_rules)
  * @param[in] head of xlat tree to create instance data for.
  * @param[in] el event list used to run any instantiate data
  */
-int xlat_instantiate_ephemeral(xlat_exp_head_t *head, fr_event_list_t *el)
+static int xlat_instantiate_ephemeral(xlat_exp_head_t *head, fr_event_list_t *el)
 {
        int ret;
 
@@ -614,11 +596,17 @@ static int _xlat_bootstrap_walker(xlat_exp_t *node, UNUSED void *uctx)
  *      If the caller has a #tmpl_rules_t, it should call xlat_finalize() instead.
  *
  * @param[in] head of xlat tree to create instance data for.
+ * @param[in] t_rules parsing rules with #fr_event_list_t
  */
-int xlat_bootstrap(xlat_exp_head_t *head)
+int xlat_bootstrap(xlat_exp_head_t *head, tmpl_rules_t const *t_rules)
 {
        int ret;
 
+       /*
+        *      Runtime xlats get ephemeral instantiation
+        */
+       if (t_rules && t_rules->xlat.runtime_el) return xlat_instantiate_ephemeral(head, t_rules->xlat.runtime_el);
+
        /*
         *      If thread instantiate has been called, it's too late to
         *      bootstrap new xlats.
index de270b03e2047f925cdd203f7f365f8c7c3f9327..6168caf9532197b1e711401ba6e9e0d8496e9113 100644 (file)
@@ -321,7 +321,7 @@ static int xlat_redundant_instantiate(xlat_inst_ctx_t const *xctx)
                 *      we return.
                 */
                head->flags = node->flags;
-               xlat_bootstrap(head);
+               xlat_bootstrap(head, NULL);
                xri->ex[num++] = head;
        }
 
index 945dcba9e59f05ca064c0a82b8fe0c210eb25035..8963bcefc940b27773e261a293dad3494821e54f 100644 (file)
@@ -1880,7 +1880,7 @@ fr_slen_t xlat_tokenize(TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbuff_t *in,
         *      Add nodes that need to be bootstrapped to
         *      the registry.
         */
-       if (xlat_finalize(head, t_rules) < 0) {
+       if (xlat_bootstrap(head, t_rules) < 0) {
                talloc_free(head);
                return 0;
        }