]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add callback for failed ldap auth binds
authorNick Porter <nick@portercomputing.co.uk>
Thu, 7 Sep 2023 13:20:10 +0000 (14:20 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Fri, 8 Sep 2023 07:01:21 +0000 (08:01 +0100)
src/lib/ldap/connection.c

index c8bcf1bc343ba6e052b1c1b9f9d6d6c472d09b1d..742a452861163409d5a89cd5502aee0479c9080c 100644 (file)
@@ -1333,6 +1333,28 @@ static void ldap_bind_auth_cancel_mux(UNUSED fr_event_list_t *el, fr_trunk_conne
        }
 }
 
+/** Callback to tidy up when a bind auth trunk request fails
+ *
+ */
+static void ldap_trunk_bind_auth_fail(request_t *request, void *preq, UNUSED void *rctx,
+                               UNUSED fr_trunk_request_state_t state, UNUSED void *uctx)
+{
+       fr_ldap_bind_auth_ctx_t *bind = talloc_get_type_abort(preq, fr_ldap_bind_auth_ctx_t);
+
+       /*
+        *      Failed trunk requests get freed - so remove association in bind structure,
+        *      and change talloc parentage so resume function still has something to work with.
+        */
+       bind->treq = NULL;
+       bind->ret = LDAP_PROC_ERROR;
+       talloc_steal(NULL, bind);
+
+       /*
+        *      Ensure request is runnable.
+        */
+       if (request) unlang_interpret_mark_runnable(request);
+}
+
 /** Find the thread specific trunk to use for LDAP bind auths
  *
  * If there is no current trunk then a new one is created.
@@ -1361,6 +1383,7 @@ fr_ldap_thread_trunk_t *fr_thread_ldap_bind_trunk_get(fr_ldap_thread_t *thread)
                                              .request_mux = ldap_trunk_bind_auth_mux,
                                              .request_demux = ldap_trunk_bind_auth_demux,
                                              .request_cancel_mux = ldap_bind_auth_cancel_mux,
+                                             .request_fail = ldap_trunk_bind_auth_fail,
                                        },
                                       thread->bind_trunk_conf,
                                       "rlm_ldap bind auth", ttrunk, false);