]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Allow functions to be top_frames and remove garbage frame in child requests
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 21 Mar 2021 22:27:51 +0000 (22:27 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 31 Mar 2021 15:08:32 +0000 (16:08 +0100)
src/lib/unlang/function.c
src/lib/unlang/function.h
src/lib/unlang/parallel.c
src/modules/rlm_eap/types/rlm_eap_tls/rlm_eap_tls.c

index b0789f62b94e910e00b5f695410d9555e222f296..81c3bb9792148650c132d047a0fa0bd24a71f072 100644 (file)
@@ -118,7 +118,7 @@ static unlang_action_t unlang_function_call(rlm_rcode_t *p_result, request_t *re
  *     - -1 on failure.
  */
 int unlang_interpret_push_function(request_t *request, unlang_function_t func, unlang_function_t repeat,
-                                  unlang_function_signal_t signal, void *uctx)
+                                  unlang_function_signal_t signal, bool top_frame, void *uctx)
 {
        unlang_stack_t                  *stack = request->stack;
        unlang_stack_frame_t            *frame;
@@ -128,7 +128,7 @@ int unlang_interpret_push_function(request_t *request, unlang_function_t func, u
         *      Push module's function
         */
        if (unlang_interpret_push(request, &function_instruction,
-                                 RLM_MODULE_UNKNOWN, UNLANG_NEXT_STOP, UNLANG_SUB_FRAME) < 0) return -1;
+                                 RLM_MODULE_UNKNOWN, UNLANG_NEXT_STOP, top_frame) < 0) return -1;
 
        frame = &stack->frame[stack->depth];
 
index a4da0432c89e1756951605f0b6f4c4622a988cbf..a46e59970476fdf737e41b050f93ede8f670fa1b 100644 (file)
@@ -54,7 +54,7 @@ typedef void (*unlang_function_signal_t)(request_t *request, fr_state_signal_t a
 
 int            unlang_interpret_push_function(request_t *request,
                                               unlang_function_t func, unlang_function_t repeat,
-                                              unlang_function_signal_t signal, void *uctx)
+                                              unlang_function_signal_t signal, bool top_frame, void *uctx)
                                               CC_HINT(warn_unused_result);
 
 #ifdef __cplusplus
index 24666508ab54a22ee87f7c211ae88b1758227661..2aa6ba227ceb90e6c4711e0f1d62485ba59f5394 100644 (file)
@@ -336,15 +336,6 @@ static unlang_action_t unlang_parallel_process(rlm_rcode_t *p_result, request_t
                        }
                }
 
-               /*
-                *      Push a top frame, followed by a frame
-                *      which signals us that the child is
-                *      done, followed by the instruction to
-                *      run in the child.
-                */
-               if (unlang_interpret_push(child, NULL, RLM_MODULE_NOOP,
-                                         UNLANG_NEXT_STOP, UNLANG_TOP_FRAME) < 0) goto error;
-
                /*
                 *      Child starts detached, the parent knows
                 *      and can exit immediately once all
@@ -386,6 +377,7 @@ static unlang_action_t unlang_parallel_process(rlm_rcode_t *p_result, request_t
                                                           NULL,
                                                           unlang_parallel_child_done,
                                                           unlang_parallel_child_signal,
+                                                          UNLANG_TOP_FRAME,
                                                           &state->children[i]) < 0) goto error;
                        child_frame = unlang_current_frame(child);
                        return_point_set(child_frame);          /* Don't unwind this frame */
@@ -403,7 +395,8 @@ static unlang_action_t unlang_parallel_process(rlm_rcode_t *p_result, request_t
                 */
                if (unlang_interpret_push(child,
                                          state->children[i].instruction, RLM_MODULE_FAIL,
-                                         UNLANG_NEXT_STOP, UNLANG_SUB_FRAME) < 0) goto error;
+                                         UNLANG_NEXT_STOP,
+                                         state->detach ? UNLANG_TOP_FRAME : UNLANG_SUB_FRAME) < 0) goto error;
        }
 
        /*
index 82c981a20585a038cebb4271954a2bd57fc9b597..d3bde3ceb2f805c5ecaf21a24df4bee8eeb13b85 100644 (file)
@@ -176,7 +176,8 @@ static unlang_action_t eap_tls_virtual_server(rlm_rcode_t *p_result, rlm_eap_tls
        /*
         *      Catch the interpreter on the way back up the stack
         */
-       if (unlang_interpret_push_function(request, NULL, eap_tls_virtual_server_result, NULL, eap_session) < 0) {
+       if (unlang_interpret_push_function(request, NULL, eap_tls_virtual_server_result, NULL,
+                                          UNLANG_SUB_FRAME, eap_session) < 0) {
                RETURN_MODULE_FAIL;
        }