#include <freeradius-devel/server/packet.h>
#include <freeradius-devel/unlang/xlat.h>
+extern bool tmpl_require_enum_prefix;
+
/** Initialize src/lib/server/
*
* This is just so that the callers don't need to call a million functions.
*/
if (packet_global_init() < 0) return -1;
+ tmpl_require_enum_prefix = main_config_migrate_option_get("require_enum_prefix");
+
return 0;
}
static const conf_parser_t migrate_config[] = {
{ FR_CONF_OFFSET_FLAGS("rewrite_update", CONF_FLAG_HIDDEN, main_config_t, rewrite_update) },
{ FR_CONF_OFFSET_FLAGS("forbid_update", CONF_FLAG_HIDDEN, main_config_t, forbid_update) },
+ { FR_CONF_OFFSET_FLAGS("require_enum_prefix", CONF_FLAG_HIDDEN, main_config_t, require_enum_prefix) },
CONF_PARSER_TERMINATOR
};
static fr_table_num_ordered_t config_arg_table[] = {
{ L("rewrite_update"), offsetof(main_config_t, rewrite_update) },
{ L("forbid_update"), offsetof(main_config_t, forbid_update) },
+ { L("require_enum_prefix"), offsetof(main_config_t, require_enum_prefix) },
};
static size_t config_arg_table_len = NUM_ELEMENTS(config_arg_table);
*/
bool rewrite_update; //!< rewrite "update" to be new edit sections
bool forbid_update; //!< forbid "update" sections
+ bool require_enum_prefix; //!< require "::" for enum parsing. They're always printed with this
};
void main_config_name_set_default(main_config_t *config, char const *name, bool overwrite_config);
my_rhs_rules.enumv = NULL;
}
-
slen = tmpl_afrom_substr(map, &map->rhs,
&FR_SBUFF_IN(value, slen),
type,
#include <ctype.h>
+/*
+ * Migration flag for enum prefixes.
+ */
+extern bool tmpl_require_enum_prefix;
+
+bool tmpl_require_enum_prefix = false;
+
/** Define a global variable for specifying a default request reference
*
* @param[in] _name what the global variable should be called.
fr_sbuff_parse_error_t sberr;
fr_sbuff_t our_in = FR_SBUFF(in);
- if (fr_sbuff_is_str_literal(&our_in, "::")) {
- (void) fr_sbuff_advance(&our_in, 2);
+ /*
+ * If there isn't a "::" prefix, then check for migration flags, and enum.
+ *
+ * If we require an enum prefix, then the input can't be an enum, and we don't do any more
+ * parsing.
+ *
+ * Otherwise if there's no prefix and no enumv, we know this input can't be an enum name.
+ */
+ if (!fr_sbuff_adv_past_str_literal(&our_in, "::")) {
+ if (tmpl_require_enum_prefix) return 0;
- } else if (!t_rules->enumv) {
- return 0;
+ if (!t_rules->enumv) return 0;
}
vpt = tmpl_alloc_null(ctx);
FR_FAULT_LOG("\tenumv = %s", rules->enumv ? rules->enumv->name : "");
FR_FAULT_LOG("\tcast = %s", fr_type_to_str(rules->cast));
FR_FAULT_LOG("\tat_runtime = %u", rules->at_runtime);
+
}
+migrate {
+ require_enum_prefix = yes
+}
+
modules {
$INCLUDE ${raddb}/mods-enabled/always