]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
cache xlat can succeed if it returns no data.
authorAlan T. DeKok <aland@freeradius.org>
Mon, 16 Mar 2026 18:16:39 +0000 (14:16 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 16 Mar 2026 18:38:08 +0000 (14:38 -0400)
i.e. "no data in cache" isn't an xlat failure, it's an xlat
success with no data.

src/modules/rlm_cache/rlm_cache.c
src/tests/modules/cache_rbtree/cache-xlat.unlang

index c8b00e8d2745dac659ff3076b26b612a0972acab..d5089cc293e862eea9c8fad558556540166f9bdb 100644 (file)
@@ -937,6 +937,11 @@ xlat_action_t cache_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
        case RLM_MODULE_OK:             /* found */
                break;
 
+       case RLM_MODULE_NOTFOUND:       /* !found is "no data" */
+               talloc_free(target);
+               cache_release(inst, request, &handle);
+               return XLAT_ACTION_DONE;
+
        default:
                talloc_free(target);
                cache_release(inst, request, &handle);
@@ -966,9 +971,9 @@ xlat_action_t cache_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
        cache_release(inst, request, &handle);
 
        /*
-        *      Check if we found a matching map
+        *      If we found a value, then the output has been updated.
+        *      Otherwise, there is no output.  Either way, the xlat succeeded.
         */
-       if (!map) return XLAT_ACTION_FAIL;
 
        return XLAT_ACTION_DONE;
 }
index 6787f7c5d5276cdbe8cb3fc24b3921061786e946..e711989e36d3a3877bdc9e24454b275be98e314f 100644 (file)
@@ -29,9 +29,31 @@ if (Login-LAT-Node) {
 # Regression test for deadlock on notfound
 Filter-Id := 'testkey0'
 
+#
+#  There is no request.Login-LAT-Port, so the input is empty.
+#
 Login-LAT-Node := %cache(request.Login-LAT-Port)
 
 # Would previously deadlock
 Login-LAT-Port := %cache(request.Login-LAT-Port)
 
+#
+#  Get the value for a key which doesn't exist.  The xlat should succeed, but return no data.
+#
+Filter-Id := 'nosuchkey'
+request.Login-LAT-Service := %cache('request.Callback-Id')
+if request.Login-LAT-Service {
+       test_fail
+}
+
+#
+#  And then verify that the previous cache entry hasn't been deleted
+#
+Filter-Id := 'testkey'
+request.Login-LAT-Service := %cache('request.Callback-Id')
+
+if (Login-LAT-Service != control.Callback-Id) {
+        test_fail
+}
+
 test_pass