@@ -2383,6 +2383,50 @@ static xlat_action_t unlang_interpret_lb_child_xlat(TALLOC_CTX *ctx, fr_dcursor_
23832383}
23842384
23852385
2386+ static xlat_arg_parser_t const unlang_interpret_module_force_args [] = {
2387+ { .required = true, .single = true, .type = FR_TYPE_STRING },
2388+ { .required = false, .single = true, .type = FR_TYPE_STRING },
2389+ XLAT_ARG_PARSER_TERMINATOR
2390+ };
2391+
2392+
2393+ /** Enable a module
2394+ *
2395+ * @ingroup xlat_functions
2396+ */
2397+ static xlat_action_t unlang_interpret_module_force (UNUSED TALLOC_CTX * ctx , UNUSED fr_dcursor_t * out ,
2398+ UNUSED xlat_ctx_t const * xctx ,
2399+ request_t * request , fr_value_box_list_t * in )
2400+ {
2401+ fr_value_box_t * arg = fr_value_box_list_head (in );
2402+ char const * name = arg -> vb_strvalue ;
2403+ rlm_rcode_t rcode ;
2404+ module_instance_t * mi ;
2405+
2406+ mi = module_rlm_static_by_name (NULL , name );
2407+ if (!mi ) {
2408+ RDEBUG ("Unknown module '%s'" , name );
2409+ return XLAT_ACTION_FAIL ;
2410+ }
2411+
2412+
2413+ arg = fr_value_box_list_next (in , arg );
2414+ if (arg ) {
2415+ rcode = fr_table_value_by_str (rcode_table , arg -> vb_strvalue , RLM_MODULE_NOT_SET );
2416+ if (rcode == RLM_MODULE_NOT_SET ) {
2417+ RDEBUG ("Unknown rcode '%s'" , arg -> vb_strvalue );
2418+ return XLAT_ACTION_FAIL ;
2419+ }
2420+ } else {
2421+ rcode = RLM_MODULE_NOT_SET ;
2422+ }
2423+
2424+ module_thread_force (module_thread (mi ), rcode );
2425+ return XLAT_ACTION_DONE ;
2426+ }
2427+
2428+
2429+
23862430/** Return the current virtual server for this request
23872431 *
23882432 * @param[in] request To return virtual server for.
@@ -2531,9 +2575,12 @@ int unlang_interpret_init_global(TALLOC_CTX *ctx)
25312575 if (unlikely ((xlat = xlat_func_register (ctx , "interpreter" , unlang_interpret_xlat , FR_TYPE_VOID )) == NULL )) return -1 ;
25322576 xlat_func_args_set (xlat , unlang_interpret_xlat_args );
25332577
2534- if (unlikely ((xlat = xlat_func_register (ctx , "interpreter.load-balance.persist" , unlang_interpret_lb_persist_xlat , FR_TYPE_VOID )) == NULL )) return -1 ;
2578+ if (unlikely ((xlat = xlat_func_register (ctx , "interpreter.load-balance.persist" , unlang_interpret_lb_persist_xlat , FR_TYPE_NULL )) == NULL )) return -1 ;
25352579 if (unlikely ((xlat = xlat_func_register (ctx , "interpreter.load-balance.child" , unlang_interpret_lb_child_xlat , FR_TYPE_UINT8 )) == NULL )) return -1 ;
25362580
2581+ if (unlikely ((xlat = xlat_func_register (ctx , "interpreter.module.force" , unlang_interpret_module_force , FR_TYPE_NULL )) == NULL )) return -1 ;
2582+ xlat_func_args_set (xlat , unlang_interpret_module_force_args );
2583+
25372584 if (unlikely ((xlat = xlat_func_register (ctx , "cancel" , unlang_cancel_xlat , FR_TYPE_VOID )) == NULL )) return -1 ;
25382585 xlat_func_args_set (xlat , unlang_cancel_xlat_args );
25392586
0 commit comments