]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix unbound timeouts
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 25 Aug 2021 16:57:48 +0000 (11:57 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 25 Aug 2021 17:19:04 +0000 (12:19 -0500)
src/modules/rlm_unbound/rlm_unbound.c
src/tests/modules/unbound/dns.unlang

index 290b1c2840b635943d5ece43b6d327f2d1aebb1a..48d2bd4213a2d99d81677fadf7e2bfd4d9b997fd 100644 (file)
@@ -61,6 +61,7 @@ typedef struct {
        rlm_unbound_thread_t    *t;             //!< Thread running this request
        int                     done;           //!< Indicator that the callback has been called
                                                ///< Negative values indicate errors.
+       bool                    timedout;       //!< Request timedout.
        fr_type_t               return_type;    //!< Data type to parse results into
        bool                    has_priority;   //!< Does the returned data start with a priority field
        uint16_t                count;          //!< Number of results to return
@@ -263,9 +264,10 @@ static void xlat_unbound_timeout(UNUSED fr_event_list_t *el, UNUSED fr_time_t no
        unbound_request_t       *ur = talloc_get_type_abort(uctx, unbound_request_t);
        request_t               *request = ur->request;
 
-       REDEBUG("Timeout waiting for DNS resolution");
-       talloc_free(ur);
+       REDEBUG("Timeout waiting for DNS resolution");;
        unlang_interpret_mark_runnable(request);
+
+       ur->timedout = true;
 }
 
 /*
@@ -281,7 +283,6 @@ static void xlat_unbound_signal(request_t *request, UNUSED void *instance, UNUSE
        if (ur->ev) (void)fr_event_timer_delete(&ur->ev);
 
        RDEBUG2("Forcefully cancelling pending unbound request");
-       talloc_free(ur);
 }
 
 /*
@@ -295,6 +296,11 @@ static xlat_action_t xlat_unbound_resume(UNUSED TALLOC_CTX *ctx, fr_dcursor_t *o
        fr_value_box_t          *vb;
        unbound_request_t       *ur = talloc_get_type_abort(rctx, unbound_request_t);
 
+       /*
+        *      Request timed out
+        */
+       if (ur->timedout) return XLAT_ACTION_FAIL;
+
 #define RCODEERROR(_code, _message) case _code: \
        REDEBUG(_message, ur->t->inst->name); \
        goto error
index b13a0208e7a1ae324e51423becb083b587610563..b4302126ca6403128ffae12e5dace0d891d74e8f 100644 (file)
@@ -108,7 +108,8 @@ if (&Tmp-String-1 != "") {
        test_fail
 }
 
-if (&Module-Failure-Message != "dns - Nonexistent domain name") {
+# Running this on macOS produces a timeout due to the nonexistent TLD
+if ((&Module-Failure-Message != "dns - Nonexistent domain name") && (&Module-Failure-Message != "Timeout waiting for DNS resolution")) {
        test_fail
 }