static char proto_name_prev[128];
static dl_t *dl;
static dl_loader_t *dl_loader = NULL;
+static bool parse_new_conditions = true;
static fr_event_list_t *el = NULL;
static size_t command_condition_normalise(command_result_t *result, command_file_ctx_t *cc,
char *data, UNUSED size_t data_used, char *in, size_t inlen)
{
- ssize_t dec_len;
+ ssize_t slen;
fr_cond_t *cond;
CONF_SECTION *cs;
size_t len;
cf_filename_set(cs, cc->filename);
cf_lineno_set(cs, cc->lineno);
- dec_len = fr_cond_tokenize(cs, &cond, &cc->tmpl_rules, &FR_SBUFF_IN(in, inlen), false);
- if (dec_len <= 0) {
- fr_strerror_printf_push_head("ERROR offset %d", (int) -dec_len);
+ fr_skip_whitespace(in);
+
+ slen = fr_cond_tokenize(cs, &cond, &cc->tmpl_rules, &FR_SBUFF_IN(in, inlen), false);
+ if (slen <= 0) {
+ fr_strerror_printf_push_head("ERROR offset %d", (int) -slen);
return_error:
talloc_free(cs);
}
}
- in += dec_len;
- if (*in != '\0') {
- fr_strerror_printf_push_head("ERROR offset %d 'Too much text'", (int) dec_len);
+ if (in[slen] != '\0') {
+ fr_strerror_printf_push_head("ERROR offset %d 'Too much text'", (int) slen);
goto return_error;
}
+ /*
+ * Use the new condition parser. Except for !&foo==bar, because the
+ * new one requires that to be formatted as !(&foo==bar).
+ *
+ * Perhaps we should just change that?
+ */
+ if (parse_new_conditions && ((in[0] != '!') || (in[1] == '('))) {
+ xlat_exp_head_t *head = NULL;
+
+ slen = xlat_tokenize_condition(cc->tmp_ctx, &head, &FR_SBUFF_IN(in, inlen), NULL, &cc->tmpl_rules);
+ if (slen <= 0) {
+ fr_strerror_printf_push_head("ERROR in xlat_tokenize_cond offset %d", (int) -slen);
+ goto return_error;
+ }
+
+ talloc_free(head);
+ }
+
len = cond_print(&FR_SBUFF_OUT(data, COMMAND_OUTPUT_MAX), cond);
talloc_free(cs);
p += sizeof("pair_legacy_nested") - 1;
out = &fr_pair_legacy_nested;
+ } else if (strncmp(p, "parse_new_conditions", sizeof("parse_new_conditions") - 1) == 0) {
+ p += sizeof("parse_new_conditions") - 1;
+ out = &parse_new_conditions;
+
} else {
fr_strerror_const("Unknown migration flag");
RETURN_PARSE_ERROR(0);