]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
remove tmpl_require_enum_prefix
authorAlan T. DeKok <aland@freeradius.org>
Wed, 26 Mar 2025 14:45:15 +0000 (10:45 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 26 Mar 2025 14:54:42 +0000 (10:54 -0400)
it's now the default, and can't be turned off

src/bin/unit_test_attribute.c
src/lib/server/cf_parse.c
src/lib/server/main_config.c
src/lib/server/map.c
src/lib/server/tmpl_tokenize.c
src/lib/unlang/compile.c
src/lib/unlang/xlat_expr.c
src/lib/unlang/xlat_tokenize.c

index 03dbfac453778ee156b8935ff40a2b17c3241868..8fad02861e9a0bce3649d05b3ef8bde87a2ff45b 100644 (file)
@@ -2394,7 +2394,6 @@ static size_t command_max_buffer_size(command_result_t *result, command_file_ctx
        RETURN_OK(snprintf(data, COMMAND_OUTPUT_MAX, "%ld", size));
 }
 
-extern bool tmpl_require_enum_prefix;
 extern bool xlat_func_bare_words;
 
 /** Set or clear migration flags.
@@ -2413,10 +2412,6 @@ static size_t command_migrate(command_result_t *result, command_file_ctx_t *cc,
                p += sizeof("xlat_new_functions") - 1;
                out = &cc->tmpl_rules.xlat.new_functions;
 
-       } else if (strncmp(p, "tmpl_require_enum_prefix", sizeof("tmpl_require_enum_prefix") - 1) == 0) {
-               p += sizeof("tmpl_require_enum_prefix") - 1;
-               out = &tmpl_require_enum_prefix;
-
        } else {
                fr_strerror_const("Unknown migration flag");
                RETURN_PARSE_ERROR(0);
@@ -3843,11 +3838,6 @@ int main(int argc, char *argv[])
                        break;
 
                case 'S':
-                       if (strcmp(optarg, "require_enum_prefix=yes") == 0) {
-                               tmpl_require_enum_prefix = true;
-                               break;
-                       }
-
                        fprintf(stderr, "Invalid option to -S\n");
                        EXIT_WITH_FAILURE;
 
index 89d5641545a5f501daaf496f288dd544021302c1..13d917df95f1982cfa7e57af6967f365394d633e 100644 (file)
@@ -47,11 +47,6 @@ static char const parse_spaces[] = "
 #define PAIR_SPACE(_cs) ((_cs->depth + 1) * 2)
 #define SECTION_SPACE(_cs) (_cs->depth * 2)
 
-/*
- *     For migration.
- */
-extern bool tmpl_require_enum_prefix;
-
 void cf_pair_debug_log(CONF_SECTION const *cs, CONF_PAIR *cp, conf_parser_t const *rule)
 {
        char const      *value;
@@ -1243,10 +1238,7 @@ static int cf_parse_tmpl_pass2(UNUSED CONF_SECTION *cs, tmpl_t **out, CONF_PAIR
                        cf_log_err(cp, "Please remove '&' from the attribute name");
                        return -1;
                }
-
-               if (tmpl_require_enum_prefix)  {
-                       cf_log_warn(cp, "Please remove '&' from the attribute name");
-               }
+               cf_log_warn(cp, "Please remove '&' from the attribute name");
                break;
 
        case TMPL_TYPE_DATA:
index 8fb8f5051f3a151e26d0c033c7f72cd05cc00116..28619cfaf2cb8399235731468dc958cb42cf295d 100644 (file)
@@ -187,21 +187,12 @@ static const conf_parser_t thread_config[] = {
 /*
  *     Migration configuration.
  */
-extern bool tmpl_require_enum_prefix;
 bool xlat_func_bare_words = false;
 
 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) },
 
-       /*
-        *      Do not add tmpl_require_enum_prefix here, as it is
-        *      parsed too late to affect anything.  It must be passed
-        *      as a command-line option via
-        *
-        *              -S v3_enum_names=yes
-        */
-
        CONF_PARSER_TERMINATOR
 };
 
@@ -1541,7 +1532,7 @@ int main_config_parse_option(char const *value)
                fr_exit(1);
        }
 
-       if (out == &main_config->require_enum_prefix) tmpl_require_enum_prefix = box.vb_bool;
+       if (out == &main_config->require_enum_prefix) {}
        if (out == &main_config->xlat_func_bare_words) xlat_func_bare_words = box.vb_bool;
 
        *out = box.vb_bool;
index 57f6dbd9543cc48eadc2e96d2f1cf671b20fc685..e8d6dedc7b4de40bbcf39fbcba22104a1d53f08e 100644 (file)
@@ -47,8 +47,6 @@ RCSID("$Id$")
 
 #include <ctype.h>
 
-extern bool tmpl_require_enum_prefix;
-
 static fr_table_num_sorted_t const cond_quote_table[] = {
        { L("\""),      T_DOUBLE_QUOTED_STRING  },      /* Don't re-order, backslash throws off ordering */
        { L("'"),       T_SINGLE_QUOTED_STRING  },
@@ -207,9 +205,6 @@ int map_afrom_cp(TALLOC_CTX *ctx, map_t **out, map_t *parent, CONF_PAIR *cp,
                        /*
                         *      If we parsed an attribute on the LHS, and the RHS looks like an enumerated
                         *      value, then set the enumv.
-                        *
-                        *      @todo tmpl_require_enum_prefix - maybe just _always_ set enumv, because the
-                        *      caller shouldn't have set it?
                         */
                        if (!rhs_rules->enumv && tmpl_is_attr(map->lhs) &&
                            (value[0] == ':') && value[1] == ':') {
@@ -2792,10 +2787,7 @@ int map_afrom_fields(TALLOC_CTX *ctx, map_t **out, map_t **parent_p, request_t *
                slen = tmpl_afrom_substr(map, &map->rhs, &FR_SBUFF_IN(rhs, strlen(rhs)),
                                         T_BARE_WORD, value_parse_rules_unquoted[T_BARE_WORD], &my_rules);
                if (slen <= 0) {
-                       if (tmpl_require_enum_prefix) goto parse_as_attr;
-
-                       REDEBUG3("Failed parsing right-hand side as generic data type.");
-                       goto fail_rhs;
+                       goto parse_as_attr;
                }
 
                /*
index 1a74ecb82e85f06e9e05f72365e2a68b8de66dc4..f1e5a8add54516a2a38661c0893f2f61856ddd92 100644 (file)
@@ -46,13 +46,6 @@ RCSID("$Id$")
 
 #include <ctype.h>
 
-/*
- *     Migration flag for enum prefixes.
- */
-extern bool tmpl_require_enum_prefix;
-
-bool tmpl_require_enum_prefix = true;
-
 /** Define a global variable for specifying a default request reference
  *
  * @param[in] _name    what the global variable should be called.
@@ -113,8 +106,8 @@ TMPL_REQUEST_REF_DEF(tmpl_request_def_parent, REQUEST_PARENT);
 #define CHECK_T_RULES do { \
        if (!t_rules) { \
                t_rules = &default_rules; \
-               if (tmpl_require_enum_prefix) default_rules.attr.prefix = TMPL_ATTR_REF_PREFIX_AUTO; \
-       } else if (tmpl_require_enum_prefix && (t_rules->attr.prefix == TMPL_ATTR_REF_PREFIX_YES)) { \
+               default_rules.attr.prefix = TMPL_ATTR_REF_PREFIX_AUTO; \
+       } else if (t_rules->attr.prefix == TMPL_ATTR_REF_PREFIX_YES) { \
                default_rules = *t_rules; \
                default_rules.attr.prefix = TMPL_ATTR_REF_PREFIX_AUTO; \
                t_rules = &default_rules; \
@@ -1791,7 +1784,7 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t
        fr_dict_attr_err_t      dict_err;
        fr_dict_attr_t const    *our_parent = parent;
 
-       fr_assert(!tmpl_require_enum_prefix || (at_rules->prefix != TMPL_ATTR_REF_PREFIX_YES));
+       fr_assert(at_rules->prefix != TMPL_ATTR_REF_PREFIX_YES);
 
        fr_sbuff_marker(&m_s, name);
 
@@ -2242,7 +2235,6 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t *err,
        fr_sbuff_t                      our_name = FR_SBUFF(name);      /* Take a local copy in case we need to back track */
        bool                            is_raw = false;
        tmpl_attr_rules_t const         *at_rules;
-       tmpl_attr_rules_t               our_at_rules;
        fr_sbuff_marker_t               m_l;
        fr_dict_attr_t const            *namespace;
        DEFAULT_RULES;
@@ -2251,7 +2243,7 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t *err,
 
        at_rules = &t_rules->attr;
 
-       fr_assert(!tmpl_require_enum_prefix || (at_rules->prefix != TMPL_ATTR_REF_PREFIX_YES));
+       fr_assert(at_rules->prefix != TMPL_ATTR_REF_PREFIX_YES);
 
        if (err) *err = TMPL_ATTR_ERROR_NONE;
 
@@ -2266,23 +2258,8 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t *err,
         */
        switch (at_rules->prefix) {
        case TMPL_ATTR_REF_PREFIX_YES:
-               if (!tmpl_require_enum_prefix) {
-                       if (!fr_sbuff_next_if_char(&our_name, '&')) {
-                               fr_strerror_const("Invalid attribute reference, missing '&' prefix");
-                               if (err) *err = TMPL_ATTR_ERROR_BAD_PREFIX;
-                               FR_SBUFF_ERROR_RETURN(&our_name);
-                       }
-                       break;
-               }
-
-               /*
-                *      Rewrite the prefix parsing to "auto", which affects the printing.
-                */
-               our_at_rules = *at_rules;
-               our_at_rules.prefix = TMPL_ATTR_REF_PREFIX_AUTO;
-               at_rules = &our_at_rules;
-
-               FALL_THROUGH;   /* if we do require enum prefixes, then the '&' is optional */
+               fr_assert(0);
+               break;
 
        case TMPL_ATTR_REF_PREFIX_AUTO:
                /*
@@ -2471,7 +2448,7 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t *err,
 
                if (tmpl_attr_is_list_attr(ar)) vpt->rules.attr.list_def = ar->ar_da;
 
-               fr_assert(!tmpl_require_enum_prefix || (vpt->rules.attr.prefix != TMPL_ATTR_REF_PREFIX_YES));
+               fr_assert(vpt->rules.attr.prefix != TMPL_ATTR_REF_PREFIX_YES);
 
        }
 
@@ -3118,9 +3095,7 @@ static ssize_t tmpl_afrom_enum(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t *in,
         *      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;
-
-               if (!t_rules->enumv) return 0;
+               return 0;
 
        } else if (t_rules->enumv &&
                   ((t_rules->enumv->type == FR_TYPE_IPV6_ADDR) ||
@@ -3379,7 +3354,7 @@ fr_slen_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out,
                if (slen > 0) goto done_bareword;
                fr_assert(!*out);
 
-               fr_assert(!tmpl_require_enum_prefix || (t_rules->attr.prefix != TMPL_ATTR_REF_PREFIX_YES));
+               fr_assert(t_rules->attr.prefix != TMPL_ATTR_REF_PREFIX_YES);
 
                /*
                 *      See if it's an attribute reference
@@ -3396,13 +3371,11 @@ fr_slen_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out,
                 *      attribute which is loaded later.  In which
                 *      case we allow parsing the enumeration.
                 */
-               if (tmpl_require_enum_prefix) {
-                       if (!fr_sbuff_is_str_literal(&our_in, "::")) {
-                               /*
-                                *      Return the error string from parsing the attribute!
-                                */
-                               FR_SBUFF_ERROR_RETURN(&our_in);
-                       }
+               if (!fr_sbuff_is_str_literal(&our_in, "::")) {
+                       /*
+                        *      Return the error string from parsing the attribute!
+                        */
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                /*
@@ -4336,9 +4309,6 @@ int tmpl_resolve(tmpl_t *vpt, tmpl_res_rules_t const *tr_rules)
                        if (enumv) {
                                dst_type = enumv->type;
 
-                       } else if (!tmpl_require_enum_prefix) {
-                               dst_type = FR_TYPE_STRING;      /* Default to strings */
-
                        } else if (vpt->quote != T_BARE_WORD) {
                                dst_type = FR_TYPE_STRING;      /* quoted strings are strings */
 
@@ -4724,7 +4694,7 @@ fr_slen_t tmpl_attr_print(fr_sbuff_t *out, tmpl_t const *vpt, tmpl_attr_prefix_t
        /*
         *      Suppress the prefix on new syntax.
         */
-       if (tmpl_require_enum_prefix && (ar_prefix == TMPL_ATTR_REF_PREFIX_YES)) {
+       if (ar_prefix == TMPL_ATTR_REF_PREFIX_YES) {
                ar_prefix = TMPL_ATTR_REF_PREFIX_AUTO;
        }
 
@@ -4924,7 +4894,7 @@ fr_slen_t tmpl_print(fr_sbuff_t *out, tmpl_t const *vpt,
        /*
         *      Suppress the prefix on new syntax.
         */
-       if (tmpl_require_enum_prefix && (ar_prefix == TMPL_ATTR_REF_PREFIX_YES)) {
+       if (ar_prefix == TMPL_ATTR_REF_PREFIX_YES) {
                ar_prefix = TMPL_ATTR_REF_PREFIX_AUTO;
        }
 
@@ -5084,7 +5054,7 @@ void tmpl_attr_verify(char const *file, int line, tmpl_t const *vpt)
 
        fr_assert(tmpl_is_attr_unresolved(vpt) || tmpl_is_attr(vpt));
 
-       fr_assert(!tmpl_require_enum_prefix || (vpt->rules.attr.prefix != TMPL_ATTR_REF_PREFIX_YES));
+       fr_assert(vpt->rules.attr.prefix != TMPL_ATTR_REF_PREFIX_YES);
 
        /*
         *      Loop detection
@@ -5651,12 +5621,7 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *in, size_t i
        default:
        bare_word:
                *out = p;
-
-               if (tmpl_require_enum_prefix) {
-                       quote = '['; /* foo[1] is OK */
-               } else {
-                       quote = '\0';
-               }
+               quote = '['; /* foo[1] is OK */
 
        skip_word:
                *type = T_BARE_WORD;
@@ -5874,7 +5839,7 @@ void tmpl_rules_child_init(TALLOC_CTX *ctx, tmpl_rules_t *out, tmpl_rules_t cons
 
        if (!tmpl_is_attr(vpt)) return;
 
-       fr_assert(!tmpl_require_enum_prefix || (vpt->rules.attr.prefix != TMPL_ATTR_REF_PREFIX_YES));
+       fr_assert(vpt->rules.attr.prefix != TMPL_ATTR_REF_PREFIX_YES);
 
        da = tmpl_attr_tail_da(vpt);
 
index a24d432bd4786627af61277b9dc0cca710fa7308..185d56a173f507da2d7be60c377468c0cccf7e53 100644 (file)
@@ -61,8 +61,6 @@ RCSID("$Id$")
 
 #define UNLANG_IGNORE ((unlang_t *) -1)
 
-extern bool tmpl_require_enum_prefix;
-
 static unsigned int unlang_number = 1;
 
 /*
@@ -405,23 +403,6 @@ static void unlang_dump(unlang_t *instruction, int depth)
  */
 static int unlang_fixup_map(map_t *map, UNUSED void *ctx)
 {
-       CONF_PAIR *cp = cf_item_to_pair(map->ci);
-
-       /*
-        *      Anal-retentive checks.
-        */
-       if (!tmpl_require_enum_prefix && DEBUG_ENABLED3) {
-               if (tmpl_is_attr(map->lhs) && (map->lhs->name[0] != '&')) {
-                       cf_log_warn(cp, "Please change attribute reference to '&%s %s ...'",
-                                   map->lhs->name, fr_table_str_by_value(fr_tokens_table, map->op, "<INVALID>"));
-               }
-
-               if (tmpl_is_attr(map->rhs) && (map->rhs->name[0] != '&')) {
-                       cf_log_warn(cp, "Please change attribute reference to '... %s &%s'",
-                                   fr_table_str_by_value(fr_tokens_table, map->op, "<INVALID>"), map->rhs->name);
-               }
-       }
-
        switch (map->lhs->type) {
        case TMPL_TYPE_ATTR:
        case TMPL_TYPE_XLAT_UNRESOLVED:
@@ -473,21 +454,6 @@ int unlang_fixup_update(map_t *map, void *ctx)
 {
        CONF_PAIR *cp = cf_item_to_pair(map->ci);
 
-       /*
-        *      Anal-retentive checks.
-        */
-       if (!tmpl_require_enum_prefix && DEBUG_ENABLED3) {
-               if (tmpl_is_attr(map->lhs) && (map->lhs->name[0] != '&')) {
-                       cf_log_warn(cp, "Please change attribute reference to '&%s %s ...'",
-                                   map->lhs->name, fr_table_str_by_value(fr_tokens_table, map->op, "<INVALID>"));
-               }
-
-               if (tmpl_is_attr(map->rhs) && (map->rhs->name[0] != '&')) {
-                       cf_log_warn(cp, "Please change attribute reference to '... %s &%s'",
-                                   fr_table_str_by_value(fr_tokens_table, map->op, "<INVALID>"), map->rhs->name);
-               }
-       }
-
        if (!ctx) {
                /*
                 *      Fixup RHS attribute references to change NUM_UNSPEC to NUM_ALL.
@@ -1303,21 +1269,6 @@ static int unlang_fixup_edit(map_t *map, void *ctx)
 
        parent = tmpl_attr_tail_da(parent_map->lhs);
 
-       /*
-        *      Anal-retentive checks.
-        */
-       if (!tmpl_require_enum_prefix && DEBUG_ENABLED3) {
-               if (tmpl_is_attr(map->lhs) && (map->lhs->name[0] != '&')) {
-                       cf_log_warn(cp, "Please change attribute reference to '&%s %s ...'",
-                                   map->lhs->name, fr_table_str_by_value(fr_tokens_table, map->op, "<INVALID>"));
-               }
-
-               if (tmpl_is_attr(map->rhs) && (map->rhs->name[0] != '&')) {
-                       cf_log_warn(cp, "Please change attribute reference to '... %s &%s'",
-                                   fr_table_str_by_value(fr_tokens_table, map->op, "<INVALID>"), map->rhs->name);
-               }
-       }
-
        switch (map->lhs->type) {
        case TMPL_TYPE_ATTR:
                da = tmpl_attr_tail_da(map->lhs);
@@ -2675,7 +2626,7 @@ static unlang_t *compile_switch(unlang_t *parent, unlang_compile_t *unlang_ctx,
         */
        token = cf_section_name2_quote(cs);
 
-       if ((token == T_BARE_WORD) && tmpl_require_enum_prefix) {
+       if (token == T_BARE_WORD) {
                slen = tmpl_afrom_attr_substr(gext, NULL, &gext->vpt,
                                              &FR_SBUFF_IN(name2, strlen(name2)),
                                              NULL,
@@ -2930,7 +2881,7 @@ static unlang_t *compile_case(unlang_t *parent, unlang_compile_t *unlang_ctx, CO
                }
 
                /*
-                *      Bare word strings are attribute references when tmpl_require_enum_prefix=yes
+                *      Bare word strings are attribute references
                 */
                if (tmpl_is_attr(vpt) || tmpl_is_attr_unresolved(vpt)) {
                fail_attr:
@@ -2946,10 +2897,10 @@ static unlang_t *compile_case(unlang_t *parent, unlang_compile_t *unlang_ctx, CO
                }
 
                /*
-                *      When tmpl_require_enum_prefix=yes, references to unresolved attributes
-                *      are instead compiled as "bare word" strings.  Which we now forbid.
+                *      References to unresolved attributes are forbidden.  They are no longer "bare word
+                *      strings".
                 */
-               if (tmpl_require_enum_prefix && (quote == T_BARE_WORD) && (tmpl_value_type(vpt) == FR_TYPE_STRING)) {
+               if ((quote == T_BARE_WORD) && (tmpl_value_type(vpt) == FR_TYPE_STRING)) {
                        goto fail_attr;
                }
 
@@ -3992,9 +3943,9 @@ static unlang_t *compile_subrequest(unlang_t *parent, unlang_compile_t *unlang_c
        fr_dict_attr_t const            *da = NULL;
        fr_dict_enum_value_t const      *type_enum = NULL;
 
+       ssize_t                         slen;
        char                            *namespace = NULL;
        char const                      *packet_name = NULL;
-       char                            *p = NULL;
 
        tmpl_t                          *vpt = NULL, *src_vpt = NULL, *dst_vpt = NULL;
 
@@ -4093,79 +4044,35 @@ static unlang_t *compile_subrequest(unlang_t *parent, unlang_compile_t *unlang_c
         *
         *      Or, bare word an require_enum_prefix means "attribute reference".
         */
-       if ((name2[0] == '&') || tmpl_require_enum_prefix) {
-               ssize_t slen;
-
-               slen = tmpl_afrom_attr_substr(parent, NULL, &vpt,
-                                             &FR_SBUFF_IN(name2, talloc_array_length(name2) - 1),
-                                             NULL, unlang_ctx->rules);
-               if (slen <= 0) {
-                       cf_log_perr(cs, "Invalid argument to 'subrequest', failed parsing packet-type");
-                       return NULL;
-               }
-
-               fr_assert(tmpl_is_attr(vpt));
-
-               /*
-                *      Anything resembling an integer or string is
-                *      OK.  Nothing else makes sense.
-                */
-               switch (tmpl_attr_tail_da(vpt)->type) {
-               case FR_TYPE_INTEGER_EXCEPT_BOOL:
-               case FR_TYPE_STRING:
-                       break;
-
-               default:
-                       cf_log_err(cs, "Invalid data type for attribute %s.  "
-                                  "Must be an integer type or string", name2 + 1);
-                       talloc_free(vpt);
-                       return NULL;
-               }
-
-               dict = unlang_ctx->rules->attr.dict_def;
-               packet_name = NULL;
-               goto get_packet_type;
+       slen = tmpl_afrom_attr_substr(parent, NULL, &vpt,
+                                     &FR_SBUFF_IN(name2, talloc_array_length(name2) - 1),
+                                     NULL, unlang_ctx->rules);
+       if (slen <= 0) {
+               cf_log_perr(cs, "Invalid argument to 'subrequest', failed parsing packet-type");
+               return NULL;
        }
 
+       fr_assert(tmpl_is_attr(vpt));
+
        /*
-        *      foo.bar without '&' and NOT require_enum_prefix is fugly, we should disallow it.
+        *      Anything resembling an integer or string is
+        *      OK.  Nothing else makes sense.
         */
-       p = strchr(name2, '.');
-       if (!p) {
-               cf_log_warn(cs, "Please upgrade configuration to use '::%s' when changing packet types",
-                           name2);
-
-               dict = unlang_ctx->rules->attr.dict_def;
-               packet_name = name2;
-
-       } else {
-               cf_log_warn(cs, "Please upgrade configuration to use '@' when changing dictionaries");
-
-               /*
-                *      subrequest foo.bar { ... }
-                *
-                *      Change to dictionary "foo", packet type "bar".
-                */
-               MEM(namespace = talloc_strdup(parent, name2)); /* get a modifiable copy */
-
-               p = namespace + (p - name2);
-               *(p++) = '\0';
-               packet_name = p;
-
-               dict = fr_dict_by_protocol_name(namespace);
-               if (!dict) {
-                       dict_ref = fr_dict_autoload_talloc(NULL, &dict, namespace);
-                       if (!dict_ref) {
-                               cf_log_err(cs, "Unknown namespace '%s'", namespace);
-                               talloc_free(namespace);
-                               return NULL;
-                       }
-               }
+       switch (tmpl_attr_tail_da(vpt)->type) {
+       case FR_TYPE_INTEGER_EXCEPT_BOOL:
+       case FR_TYPE_STRING:
+               break;
 
-               WARN("Deprecated syntax 'subrequest %s ...'", name2);
-               WARN(" please switch to 'subrequest %s::%s ...", namespace, packet_name);
+       default:
+               cf_log_err(cs, "Invalid data type for attribute %s.  "
+                          "Must be an integer type or string", name2 + 1);
+               talloc_free(vpt);
+               return NULL;
        }
 
+       dict = unlang_ctx->rules->attr.dict_def;
+       packet_name = NULL;
+
        /*
         *      Use dict name instead of "namespace", because "namespace" can be omitted.
         */
index 5c18acfc33dc114fd77c34123609a5da0cc38762..a90ac5131fe86927327f482c121e8d205311bbca 100644 (file)
@@ -39,8 +39,6 @@ RCSID("$Id$")
 #  define XLAT_DEBUG(...)
 #endif
 
-extern bool tmpl_require_enum_prefix;
-
 /*
  *     The new tokenizer accepts most things which are accepted by the old one.  Many of the errors will be
  *     different, though.
@@ -2668,7 +2666,7 @@ static fr_slen_t tokenize_field(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuf
        /*
         *      A bare word which is NOT a known attribute.  That's an error.
         */
-       if (tmpl_require_enum_prefix && tmpl_is_data_unresolved(vpt)) {
+       if (tmpl_is_data_unresolved(vpt)) {
                fr_assert(quote == T_BARE_WORD);
                fr_strerror_const("Failed parsing input");
                fr_sbuff_set(&our_in, &opand_m);
@@ -2752,7 +2750,7 @@ static fr_slen_t tokenize_field(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuf
                        fr_assert(t_rules->attr.allow_unresolved);
 
                } else if (tmpl_is_data_unresolved(vpt)) {
-                       fr_assert(!tmpl_require_enum_prefix);
+                       fr_assert(0);
 
                        fr_assert(quote == T_BARE_WORD);
                        fr_strerror_const("Failed parsing input");
@@ -2810,8 +2808,8 @@ static fr_slen_t tokenize_field(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuf
 #ifndef NDEBUG
                if (vpt->name[0] == '%') {
                        fr_assert(vpt->rules.attr.prefix == TMPL_ATTR_REF_PREFIX_NO);
-               } else if (!tmpl_require_enum_prefix) {
-                       fr_assert(vpt->rules.attr.prefix == TMPL_ATTR_REF_PREFIX_YES);
+               } else {
+                       fr_assert(vpt->rules.attr.prefix != TMPL_ATTR_REF_PREFIX_YES);
                }
 #endif
 
@@ -3100,15 +3098,13 @@ redo:
                tmpl_rules_t our_t_rules = *t_rules;
 
                /*
-                *      The terminal rules for expressions includes "-" and "+", both of which are allowed in
-                *      enum names.  If we pass the enumv down to the next function, it will see
-                *      "Access-Accept", and then only parse "Access".  Which is wrong.
+                *      Pass the enumv down ONLY if the RHS name begins with "::".
                 *
-                *      For now, if we _don't_ have tmpl_require_enum_prefix, then we don't pass the enumv,
-                *      and we somehow skip the entire enum name.  The name is then resolved later by
-                *      something...
+                *      Otherwise, the terminal rules for expressions includes "-" and "+", both of which are
+                *      allowed in enum names.  If we pass the enumv down to the next function, it will see
+                *      "Access-Accept", and then only parse "Access".  Which is wrong.
                 */
-               if (tmpl_require_enum_prefix && (lhs->type == XLAT_TMPL) && tmpl_is_attr(lhs->vpt) &&
+               if ((lhs->type == XLAT_TMPL) && tmpl_is_attr(lhs->vpt) &&
                    fr_sbuff_is_str_literal(&our_in, "::")) {
                        our_t_rules.enumv = tmpl_attr_tail_da(lhs->vpt);
                }
@@ -3291,12 +3287,8 @@ static fr_slen_t xlat_tokenize_expression_internal(TALLOC_CTX *ctx, xlat_exp_hea
         */
        if (node->type == XLAT_TMPL) {
                if (tmpl_is_data_unresolved(node->vpt)) {
-                               if (!tmpl_require_enum_prefix) {
-                                       fr_strerror_const("Unexpected text - attribute names must be prefixed with '&'");
-                               } else {
-                                       fr_strerror_const("Unknown attribute");
-                               }
-                               return -1;
+                       fr_strerror_const("Unknown attribute");
+                       return -1;
                }
 
                /*
index da8d34ba30e50af1e4e0b0012b3318dedd6f65a1..0a50ef09aa280fcc3164e21a4c944139c5497a5d 100644 (file)
@@ -45,7 +45,6 @@ RCSID("$Id$")
 #  define XLAT_HEXDUMP(...)
 #endif
 
-extern const bool tmpl_require_enum_prefix;
 extern const bool xlat_func_bare_words;
 
 /** These rules apply to literal values and function arguments inside of an expansion
@@ -460,7 +459,7 @@ error:
  *
  */
 static CC_HINT(nonnull(1,2,4)) ssize_t xlat_tokenize_attribute(xlat_exp_head_t *head, fr_sbuff_t *in,
-                                                              fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules, tmpl_attr_prefix_t attr_prefix)
+                                                              fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules)
 {
        tmpl_attr_error_t       err;
        tmpl_t                  *vpt = NULL;
@@ -473,25 +472,11 @@ static CC_HINT(nonnull(1,2,4)) ssize_t xlat_tokenize_attribute(xlat_exp_head_t *
        XLAT_DEBUG("ATTRIBUTE <-- %.*s", (int) fr_sbuff_remaining(in), fr_sbuff_current(in));
 
        /*
-        *      Suppress the prefix on new syntax.
-        */
-       if (tmpl_require_enum_prefix && (attr_prefix == TMPL_ATTR_REF_PREFIX_YES)) {
-               attr_prefix = TMPL_ATTR_REF_PREFIX_AUTO;
-       }
-
-       /*
-        *      attr_prefix is NO for %{User-Name}
-        *
-        *      attr_prefix is YES for %foo(&User-Name)
-        *
-        *      attr_prefix is YES for (&User-Name == "foo")
-        *
-        *      We also allow wildcards in the tmpls, ad we're being
-        *      called from within a %{...} block.
+        *      We are called from %{foo}.  So we don't use attribute prefixes.
         */
        our_t_rules = *t_rules;
        our_t_rules.attr.allow_wildcard = true;
-       our_t_rules.attr.prefix = attr_prefix;
+       our_t_rules.attr.prefix = TMPL_ATTR_REF_PREFIX_NO;
 
        fr_sbuff_marker(&m_s, in);
 
@@ -719,7 +704,7 @@ check_for_attr:
                fr_sbuff_set(in, &m_s);         /* backtrack */
                fr_sbuff_marker_release(&m_s);
 
-               if (xlat_tokenize_attribute(head, in, &attr_p_rules, t_rules, TMPL_ATTR_REF_PREFIX_NO) < 0) return -1;
+               if (xlat_tokenize_attribute(head, in, &attr_p_rules, t_rules) < 0) return -1;
 
                if (!fr_sbuff_next_if_char(in, '}')) {
                        fr_strerror_const("Missing closing brace");
@@ -1070,7 +1055,7 @@ ssize_t xlat_print_node(fr_sbuff_t *out, xlat_exp_head_t const *head, xlat_exp_t
                 *      @todo - respect node->quote here, too.  Which also means updating the parser.
                 */
                if (node->quote == T_BARE_WORD) {
-                       if (tmpl_require_enum_prefix && node->data.enumv &&
+                       if (node->data.enumv &&
                            (strncmp(node->fmt, "::", 2) == 0)) {
                                FR_SBUFF_IN_STRCPY_LITERAL_RETURN(out, "::");
                        }
@@ -1101,7 +1086,7 @@ ssize_t xlat_print_node(fr_sbuff_t *out, xlat_exp_head_t const *head, xlat_exp_t
                         *      OR when the value-box functions are
                         *      updated.
                         */
-                       if (tmpl_require_enum_prefix && node->vpt->data.literal.enumv &&
+                       if (node->vpt->data.literal.enumv &&
                            (strncmp(node->fmt, "::", 2) == 0)) {
                                FR_SBUFF_IN_STRCPY_LITERAL_RETURN(out, "::");
                        }
@@ -1149,25 +1134,12 @@ ssize_t xlat_print_node(fr_sbuff_t *out, xlat_exp_head_t const *head, xlat_exp_t
                 *      Can't have prefix YES if we're using the new flag.  The parser / tmpl alloc routines
                 *      MUST have set this to prefix AUTO.
                 */
-               fr_assert(!tmpl_require_enum_prefix || (node->vpt->rules.attr.prefix != TMPL_ATTR_REF_PREFIX_YES));
-
-               /*
-                *      Parsing &User-Name or User-Name gets printed as &User-Name.
-                *
-                *      Parsing %{User-Name} gets printed as %{User-Name}
-                */
-               if (node->vpt->rules.attr.prefix == TMPL_ATTR_REF_PREFIX_YES) {
-                       fr_assert(!tmpl_require_enum_prefix);
-
-                       if (node->vpt->name[0] != '&') FR_SBUFF_IN_CHAR_RETURN(out, '&');
-                       FR_SBUFF_IN_STRCPY_RETURN(out, node->fmt);
-                       goto done;
-               }
+               fr_assert(node->vpt->rules.attr.prefix != TMPL_ATTR_REF_PREFIX_YES);
 
                /*
                 *      No '&', print the name, BUT without any attribute prefix.
                 */
-               if (tmpl_require_enum_prefix && !node->vpt->rules.attr.xlat) {
+               if (!node->vpt->rules.attr.xlat) {
                        char const *p = node->fmt;
 
                        if (*p == '&') p++;
@@ -1440,10 +1412,7 @@ fr_slen_t xlat_tokenize_argv(TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbuff_t
                         *      tmpl.  And update the function arguments to say "we want a tmpl, not a
                         *      string".
                         */
-                       if (spaces && !tmpl_require_enum_prefix && fr_sbuff_is_char(&our_in, '&')) {
-                               slen = xlat_tokenize_attribute(node->group, &our_in, our_p_rules, t_rules, TMPL_ATTR_REF_PREFIX_YES);
-
-                       } else if (spaces || xlat_func_bare_words) {
+                       if (spaces || xlat_func_bare_words) {
                                /*
                                 *      Spaces - each argument is a bare word all by itself, OR an xlat thing all by itself.
                                 *