]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Set priority of the process_reply function high enough to bubble up
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 1 Jun 2025 01:38:01 +0000 (19:38 -0600)
committerNick Porter <nick@portercomputing.co.uk>
Wed, 18 Jun 2025 12:53:05 +0000 (13:53 +0100)
src/modules/rlm_eap/types/rlm_eap_peap/peap.c

index c8ba8dac95fc6b6218b208c83cffff2378d3e51f..23d33d766eed32e98da3ec1bedfcbbd9a8200620 100644 (file)
@@ -275,7 +275,7 @@ static int eap_peap_check_tlv(request_t *request, uint8_t const *data, size_t da
  */
 static unlang_action_t process_reply(unlang_result_t *p_result, request_t *request, UNUSED void *uctx)
 {
-       eap_session_t           *eap_session = eap_session_get(request->parent);
+       eap_session_t           *eap_session = talloc_get_type_abort(uctx, eap_session_t);
        eap_tls_session_t       *eap_tls_session = talloc_get_type_abort(eap_session->opaque, eap_tls_session_t);
        fr_tls_session_t        *tls_session = eap_tls_session->tls_session;
        fr_pair_list_t          vps;
@@ -283,6 +283,11 @@ static unlang_action_t process_reply(unlang_result_t *p_result, request_t *reque
        request_t               *parent = request->parent;
        fr_packet_t             *reply = request->reply;
 
+       /*
+        *      Bubble this rcode up to become the result of the subrequest
+        */
+       p_result->priority = MOD_PRIORITY_MAX;
+
        if (RDEBUG_ENABLED2) {
 
                /*
@@ -578,17 +583,31 @@ unlang_action_t eap_peap_process(unlang_result_t *p_result, request_t *request,
                RDEBUG2("No tunnel username (SSL resumption?)");
        }
 
-       if (unlang_subrequest_child_push(child, &eap_session->submodule_result,
+       if (unlang_subrequest_child_push(&eap_session->submodule_result, child,
                                         child,
                                         false, UNLANG_SUB_FRAME) < 0) goto finish;
+
+       /*
+        *      Setup a function in thie child to process the
+        *      result of the subrequest.
+        */
        if (unlang_function_push(NULL, child, NULL, process_reply, NULL, 0,
                                 UNLANG_SUB_FRAME, eap_session) != UNLANG_ACTION_PUSHED_CHILD) goto finish;
 
        /*
-        *      Call authentication recursively, which will
-        *      do PAP, CHAP, MS-CHAP, etc.
+        *      Run inner tunnel in the context of the child
+        */
+       if (eap_virtual_server(child, eap_session, t->server_cs) == UNLANG_ACTION_FAIL) {
+               rcode = RLM_MODULE_FAIL;
+               goto finish;
+       }
+
+       /*
+        *      We now yield to the subrequest.  unlang_subrequest_child_push
+        *      pushed a new frame in the context of the parent which'll start
+        *      the subrequest.
         */
-       return eap_virtual_server(child, eap_session, t->server_cs);
+       return UNLANG_ACTION_PUSHED_CHILD;
 
 finish:
        if (child) request_detach(child);