return XLAT_ACTION_DONE;
}
+static xlat_action_t xlat_func_untaint(UNUSED TALLOC_CTX *ctx, fr_dcursor_t *out,
+ UNUSED xlat_ctx_t const *xctx,
+ UNUSED request_t *request, fr_value_box_list_t *in)
+{
+ fr_dcursor_t cursor_in;
+
+ fr_dcursor_init(&cursor_in, in);
+ fr_value_box_list_untaint(in);
+ fr_dcursor_merge(out, &cursor_in);
+
+ return XLAT_ACTION_DONE;
+}
+
+static xlat_action_t xlat_func_taint(UNUSED TALLOC_CTX *ctx, fr_dcursor_t *out,
+ UNUSED xlat_ctx_t const *xctx,
+ UNUSED request_t *request, fr_value_box_list_t *in)
+{
+ fr_dcursor_t cursor_in;
+
+ fr_dcursor_init(&cursor_in, in);
+ fr_value_box_list_taint(in);
+ fr_dcursor_merge(out, &cursor_in);
+
+ return XLAT_ACTION_DONE;
+}
+
static xlat_arg_parser_t const xlat_func_explode_args[] = {
{ .required = true, .type = FR_TYPE_STRING },
{ .required = true, .concat = true, .type = FR_TYPE_STRING },
XLAT_REGISTER_ARGS("sub", xlat_func_sub, xlat_func_sub_args);
XLAT_REGISTER_ARGS("trigger", trigger_xlat, trigger_xlat_args);
+ xlat_register(NULL, "untaint", xlat_func_untaint, NULL);
+ xlat_register(NULL, "taint", xlat_func_taint, NULL);
+
/*
* All of these functions are pure.
*/
return 0;
}
-/** Check to see if any list members are tainted
+/** Check to see if any list members (or their children) are tainted
*
* @param[in] head of list to check.
* @return
{
fr_value_box_t *vb = NULL;
- if (fr_dlist_empty(head)) return false;
-
while ((vb = fr_dlist_next(head, vb))) {
+ if (fr_type_is_group(vb->type) && fr_value_box_list_tainted(&vb->vb_group)) return true;
if (vb->tainted) return true;
}
return false;
}
+/** Taint every list member (and their children)
+ *
+ * @param[in] head of list.
+ */
+void fr_value_box_list_taint(fr_value_box_list_t *head)
+{
+ fr_value_box_t *vb = NULL;
+
+ while ((vb = fr_dlist_next(head, vb))) {
+ if (fr_type_is_group(vb->type)) fr_value_box_list_taint(&vb->vb_group);
+ vb->tainted = true;
+ }
+}
+
+/** Untaint every list member (and their children)
+ *
+ * @param[in] head of list.
+ */
+void fr_value_box_list_untaint(fr_value_box_list_t *head)
+{
+ fr_value_box_t *vb = NULL;
+
+ while ((vb = fr_dlist_next(head, vb))) {
+ if (fr_type_is_group(vb->type)) fr_value_box_list_untaint(&vb->vb_group);
+ vb->tainted = false;
+ }
+}
+
/** Validation function to check that a fr_value_box_t is correctly initialised
*
*/
int fr_value_box_list_acopy(TALLOC_CTX *ctx, fr_value_box_list_t *out, fr_value_box_list_t const *in);
bool fr_value_box_list_tainted(fr_value_box_list_t const *head);
+
+void fr_value_box_list_taint(fr_value_box_list_t *head);
+
+void fr_value_box_list_untaint(fr_value_box_list_t *head);
/** @} */
/** @name Print the value of a value box as a string