]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add %test.null() which always returns a value box of FR_TYPE_NULL
authorAlan T. DeKok <aland@freeradius.org>
Fri, 18 Jul 2025 14:11:14 +0000 (10:11 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 18 Jul 2025 14:30:02 +0000 (10:30 -0400)
src/modules/rlm_test/rlm_test.c

index b479a5d3cf35d011fd3425fb6cf7ac37ca5335a5..a94a3d9d95464ab55fca00889cf68bccae596306 100644 (file)
@@ -416,6 +416,20 @@ static xlat_action_t test_xlat_fail(UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t
 }
 
 
+/** Always return a NULL value-box
+ */
+static xlat_action_t test_xlat_null(TALLOC_CTX *ctx, fr_dcursor_t *out,
+                                   UNUSED xlat_ctx_t const *xctx, UNUSED request_t *request,
+                                   UNUSED fr_value_box_list_t *in)
+{
+       fr_value_box_t  *vb;
+
+       MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_NULL, NULL));
+       fr_dcursor_append(out, vb);
+
+       return XLAT_ACTION_DONE;
+}
+
 static int mod_thread_instantiate(module_thread_inst_ctx_t const *mctx)
 {
        rlm_test_t *inst = talloc_get_type_abort(mctx->mi->data, rlm_test_t);
@@ -486,6 +500,8 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        if (!(xlat = module_rlm_xlat_register(mctx->mi->boot, mctx, "fail", test_xlat_fail, FR_TYPE_VOID))) return -1;
        xlat_func_args_set(xlat, test_xlat_fail_args);
 
+       if (!module_rlm_xlat_register(mctx->mi->boot, mctx, "null", test_xlat_null, FR_TYPE_VOID)) return -1;
+
        return 0;
 }