fr_assert(tmpl_is_attr(map->lhs));
- /*
- * Special case for !*, we don't need to parse RHS as this is a unary operator.
- */
- if (map->op == T_OP_CMP_FALSE) return 0;
-
- /*
- * Hoist this early, too.
- */
- if (map->op == T_OP_CMP_TRUE) {
- MEM(n = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(map->lhs)));
- n->op = map->op;
- fr_pair_append(out, n);
- return 0;
- }
-
/*
* If there's no RHS, then it MUST be an attribute, and
* it MUST be structural. And it MAY have children.
fr_assert(map->lhs != NULL);
fr_assert(map->rhs != NULL);
+ /*
+ * This function is called only when creating attributes. It cannot be called for conditions.
+ */
+ if (fr_comparison_op[map->op]) {
+ REDEBUG("Invalid operator in %s %s ...", map->lhs->name, fr_tokens[map->op]);
+ return -1;
+ }
+
tmp_ctx = talloc_pool(request, 1024);
/*
fr_pair_list_init(&check_list);
while ((map = map_list_next(&pl->reply, map))) {
+ /*
+ * Special case for !*
+ */
+ if (map->op == T_OP_CMP_FALSE) {
+ RWDEBUG("Unsupported operator '!*'");
+ continue;
+ }
+
+ /*
+ * Create an empty attribute. This functionality is used by the attr_filter module.
+ */
+ if (map->op == T_OP_CMP_TRUE) {
+ fr_pair_t *vp;
+
+ MEM(vp = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(map->lhs)));
+ vp->op = T_OP_CMP_TRUE;
+ fr_pair_append(&check_list, vp);
+ continue;
+ }
+
+ /*
+ * @todo - this use of map_to_vp is completely wrong. Nothing else uses
+ * comparison operators for map_to_vp(). This module doesn't handle nested
+ * pairs, and dumps all pairs in one list no matter their depth. It requires
+ * that map_to_vp() appends the pair, rather than respecting the operator.
+ *
+ * i.e. it really only works for RADIUS. :(
+ */
if (map_to_vp(ctx, &tmp_list, request, map, NULL) < 0) {
RPWARN("Failed parsing map %s for check item, skipping it", map->lhs->name);
continue;
return -1;
}
+ if (!fr_assignment_op[map->op]) {
+ cf_log_err(map->ci, "Invalid operator '%s'", fr_tokens[map->op]);
+ return -1;
+ }
+
return 0;
}