From: Arran Cudbard-Bell Date: Thu, 9 Feb 2023 18:35:45 +0000 (-0600) Subject: Remove TMPL_TYPE_LIST X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfc347717f683202b60b56015f25fdad5cf96360;p=thirdparty%2Ffreeradius-server.git Remove TMPL_TYPE_LIST --- diff --git a/src/lib/ldap/map.c b/src/lib/ldap/map.c index 75318545921..2cc358ba93e 100644 --- a/src/lib/ldap/map.c +++ b/src/lib/ldap/map.c @@ -47,7 +47,8 @@ int fr_ldap_map_getvalue(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *reques fr_pair_list_init(&head); fr_pair_list_init(&tmp_list); - switch (map->lhs->type) { + fr_assert(map->lhs->type == TMPL_TYPE_ATTR); + /* * This is a mapping in the form of: * . += @@ -59,10 +60,10 @@ int fr_ldap_map_getvalue(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *reques * RADIUS control and reply attributes in separate LDAP * attributes. */ - case TMPL_TYPE_LIST: + if (tmpl_is_list(map->lhs)) { for (i = 0; i < self->count; i++) { map_t *attr = NULL; - char *attr_str; + char *attr_str; tmpl_rules_t lhs_rules = { .attr = { @@ -154,42 +155,38 @@ int fr_ldap_map_getvalue(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *reques */ if (map->op != T_OP_ADD_EQ) break; } - break; + goto finish; + } /* * Iterate over all the retrieved values, * don't try and be clever about changing operators * just use whatever was set in the attribute map. */ - case TMPL_TYPE_ATTR: - for (i = 0; i < self->count; i++) { - if (!self->values[i]->bv_len) continue; - - MEM(vp = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(map->lhs))); - - if (fr_pair_value_from_str(vp, self->values[i]->bv_val, - self->values[i]->bv_len, NULL, true) < 0) { - RPWDEBUG("Failed parsing value \"%pV\" for attribute %s", - fr_box_strvalue_len(self->values[i]->bv_val, self->values[i]->bv_len), - tmpl_attr_tail_da(map->lhs)->name); + for (i = 0; i < self->count; i++) { + if (!self->values[i]->bv_len) continue; - talloc_free(vp); /* also frees escaped */ - continue; - } + MEM(vp = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(map->lhs))); - fr_pair_append(&head, vp); + if (fr_pair_value_from_str(vp, self->values[i]->bv_val, + self->values[i]->bv_len, NULL, true) < 0) { + RPWDEBUG("Failed parsing value \"%pV\" for attribute %s", + fr_box_strvalue_len(self->values[i]->bv_val, self->values[i]->bv_len), + tmpl_attr_tail_da(map->lhs)->name); - /* - * Only process the first value, unless the operator is += - */ - if (map->op != T_OP_ADD_EQ) break; + talloc_free(vp); /* also frees escaped */ + continue; } - break; - default: - fr_assert(0); + fr_pair_append(&head, vp); + + /* + * Only process the first value, unless the operator is += + */ + if (map->op != T_OP_ADD_EQ) break; } +finish: fr_pair_list_append(out, &head); return 0; @@ -202,7 +199,6 @@ int fr_ldap_map_verify(map_t *map, UNUSED void *instance) * create using LDAP values. */ switch (map->lhs->type) { - case TMPL_TYPE_LIST: case TMPL_TYPE_ATTR: break; diff --git a/src/lib/server/cf_parse.c b/src/lib/server/cf_parse.c index 750448e225d..f4a9f0597ca 100644 --- a/src/lib/server/cf_parse.c +++ b/src/lib/server/cf_parse.c @@ -1069,7 +1069,6 @@ static int cf_parse_tmpl_pass2(UNUSED CONF_SECTION *cs, tmpl_t **out, CONF_PAIR break; case TMPL_TYPE_ATTR: - case TMPL_TYPE_LIST: case TMPL_TYPE_DATA: case TMPL_TYPE_EXEC: case TMPL_TYPE_EXEC_UNRESOLVED: diff --git a/src/lib/server/cond_eval.c b/src/lib/server/cond_eval.c index 82883fc50f8..c7879f293a3 100644 --- a/src/lib/server/cond_eval.c +++ b/src/lib/server/cond_eval.c @@ -140,7 +140,6 @@ static bool cond_eval_tmpl(request_t *request, tmpl_t const *in, fr_value_box_t switch (vpt->type) { case TMPL_TYPE_ATTR: - case TMPL_TYPE_LIST: /* * No cast means that it's an existence check. */ @@ -361,12 +360,11 @@ static int cond_realize_tmpl(request_t *request, /* * These are handled elsewhere. */ - case TMPL_TYPE_LIST: #ifdef HAVE_REGEX case TMPL_TYPE_REGEX: -#endif fr_assert(!async); return 0; +#endif case TMPL_TYPE_ATTR: /* @@ -735,7 +733,6 @@ check_attrs: /* * LHS is an attribute or list */ - case TMPL_TYPE_LIST: case TMPL_TYPE_ATTR: { fr_pair_t *vp; diff --git a/src/lib/server/cond_tokenize.c b/src/lib/server/cond_tokenize.c index 9e558a40850..9ba70e685e4 100644 --- a/src/lib/server/cond_tokenize.c +++ b/src/lib/server/cond_tokenize.c @@ -652,7 +652,6 @@ static int cond_normalise(TALLOC_CTX *ctx, fr_token_t lhs_type, fr_cond_t **c_ou case TMPL_TYPE_XLAT_UNRESOLVED: case TMPL_TYPE_ATTR: case TMPL_TYPE_ATTR_UNRESOLVED: - case TMPL_TYPE_LIST: case TMPL_TYPE_EXEC: break; diff --git a/src/lib/server/map.c b/src/lib/server/map.c index 007d3b4cf48..b748ba8828b 100644 --- a/src/lib/server/map.c +++ b/src/lib/server/map.c @@ -1341,7 +1341,7 @@ int map_afrom_vp(TALLOC_CTX *ctx, map_t **out, fr_pair_t *vp, tmpl_rules_t const * @param[in,out] ctx to allocate new #fr_pair_t (s) in. * @param[out] out Where to write the #fr_pair_t (s). * @param[in] request structure (used only for talloc). - * @param[in] map the map. The LHS (dst) must be #TMPL_TYPE_ATTR or #TMPL_TYPE_LIST. + * @param[in] map the map. The LHS (dst) must be #TMPL_TYPE_ATTR. * The RHS (src) must be #TMPL_TYPE_EXEC. * @return * - 0 on success. @@ -1386,14 +1386,6 @@ static int map_exec_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *reque } switch (map->lhs->type) { - case TMPL_TYPE_LIST: - if (fr_pair_list_empty(&output_pairs)) { - REDEBUG("No valid attributes received from program"); - return -2; - } - fr_pair_list_append(out, &output_pairs); - return 0; - case TMPL_TYPE_ATTR: { fr_pair_t *vp; @@ -1421,7 +1413,7 @@ static int map_exec_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *reque * @param[in,out] ctx to allocate #fr_pair_t (s) in. * @param[out] out Where to write the #fr_pair_t (s), which may be NULL if not found * @param[in] request The current request. - * @param[in] map the map. The LHS (dst) has to be #TMPL_TYPE_ATTR or #TMPL_TYPE_LIST. + * @param[in] map the map. The LHS (dst) has to be #TMPL_TYPE_ATTR. * @param[in] uctx unused. * @return * - 0 on success. @@ -1752,7 +1744,6 @@ int map_to_request(request_t *request, map_t const *map, radius_map_getvalue_t f /* * Already in the correct form. */ - case TMPL_TYPE_LIST: case TMPL_TYPE_ATTR: break; @@ -2321,49 +2312,6 @@ void map_debug_log(request_t *request, map_t const *map, fr_pair_t const *vp) fr_pair_aprint_value_quoted(request, &rhs, vp, map->rhs->quote); break; - /* - * For the lists, we can't use the original name, and have to - * rebuild it using tmpl_print, for each attribute we're - * copying. - */ - case TMPL_TYPE_LIST: - { - tmpl_t *vpt; - fr_token_t quote; - - switch (vp->vp_type) { - case FR_TYPE_QUOTED: - quote = T_DOUBLE_QUOTED_STRING; - break; - default: - quote = T_BARE_WORD; - break; - } - - vpt = tmpl_alloc(request, TMPL_TYPE_ATTR, quote, map->rhs->name, strlen(map->rhs->name)); - - /* - * Fudge a temporary tmpl that describes the attribute we're copying - * this is a combination of the original list tmpl, and values from - * the fr_pair_t. - */ - tmpl_attr_copy(vpt, map->rhs); - tmpl_attr_set_leaf_da(vpt, vp->da); - tmpl_attr_set_leaf_num(vpt, NUM_UNSPEC); - - /* - * Not appropriate to use map->rhs->quote here, as that's the quoting - * around the list ref. The attribute value has no quoting, so we choose - * the quoting based on the data type. - */ - fr_pair_aprint_value_quoted(request, &value, vp, quote); - tmpl_print(&FR_SBUFF_OUT(buffer, sizeof(buffer)), vpt, TMPL_ATTR_REF_PREFIX_YES, NULL); - rhs = talloc_typed_asprintf(request, "%s -> %s", buffer, value); - - talloc_free(vpt); - } - break; - case TMPL_TYPE_ATTR: { fr_token_t quote; @@ -2394,19 +2342,6 @@ void map_debug_log(request_t *request, map_t const *map, fr_pair_t const *vp) } switch (map->lhs->type) { - case TMPL_TYPE_LIST: - /* - * The MAP may have said "list", but if there's a - * VP, it has it's own name, which isn't in the - * map name. - */ - if (vp) { - tmpl_print(&FR_SBUFF_OUT(buffer, sizeof(buffer)), map->lhs, TMPL_ATTR_REF_PREFIX_YES, NULL); /* Fixme - bad escaping */ - RDEBUG2("%s%s %s %s", buffer, vp->da->name, fr_table_str_by_value(fr_tokens_table, vp->op, ""), rhs); - break; - } - FALL_THROUGH; - case TMPL_TYPE_ATTR: tmpl_print(&FR_SBUFF_OUT(buffer, sizeof(buffer)), map->lhs, TMPL_ATTR_REF_PREFIX_YES, NULL); RDEBUG2("%s %s %s", buffer, fr_table_str_by_value(fr_tokens_table, vp ? vp->op : map->op, ""), rhs); diff --git a/src/lib/server/map_async.c b/src/lib/server/map_async.c index 54b8ae5d085..78e026c8d01 100644 --- a/src/lib/server/map_async.c +++ b/src/lib/server/map_async.c @@ -233,7 +233,7 @@ static inline fr_pair_list_t *map_check_src_or_dst(request_t *request, map_t con * @param[in,out] ctx to allocate modification maps in. * @param[out] out Where to write the #fr_pair_t (s), which may be NULL if not found * @param[in] request The current request. - * @param[in] original the map. The LHS (dst) has to be #TMPL_TYPE_ATTR or #TMPL_TYPE_LIST. + * @param[in] original the map. The LHS (dst) has to be #TMPL_TYPE_ATTR. * @param[in] lhs_result of previous stack based rhs evaluation. * Must be provided for rhs types: * - TMPL_TYPE_XLAT @@ -278,7 +278,6 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out, /* * Already in the correct form. */ - case TMPL_TYPE_LIST: case TMPL_TYPE_ATTR: break; @@ -891,20 +890,6 @@ static inline void map_list_mod_debug(request_t *request, rhs = fr_asprintf(request, "%s%pV%s", quote, vb, quote); break; - /* - * For the lists, we can't use the original name, and have to - * rebuild it using tmpl_print, for each attribute we're - * copying. - */ - case TMPL_TYPE_LIST: - { - char buffer[256]; - - tmpl_print(&FR_SBUFF_OUT(buffer, sizeof(buffer)), map->rhs, TMPL_ATTR_REF_PREFIX_YES, NULL); - rhs = fr_asprintf(request, "%s -> %s%pV%s", buffer, quote, vb, quote); - } - break; - case TMPL_TYPE_ATTR: rhs = fr_asprintf(request, "%s -> %s%pV%s", map->rhs->name, quote, vb, quote); break; @@ -916,7 +901,6 @@ static inline void map_list_mod_debug(request_t *request, switch (map->lhs->type) { case TMPL_TYPE_ATTR: - case TMPL_TYPE_LIST: RDEBUG2("%s %s %s", map->lhs->name, fr_table_str_by_value(fr_tokens_table, mod->op, ""), rhs); break; diff --git a/src/lib/server/tmpl.h b/src/lib/server/tmpl.h index 3d636ce15f3..607ec2893dd 100644 --- a/src/lib/server/tmpl.h +++ b/src/lib/server/tmpl.h @@ -26,7 +26,7 @@ * #tmpl_t (VPTs) specify either a data source, or a data sink. * * Examples of sources are #TMPL_TYPE_XLAT_UNRESOLVED, #TMPL_TYPE_EXEC and #TMPL_TYPE_ATTR. - * Examples of sinks are #TMPL_TYPE_ATTR, #TMPL_TYPE_LIST. + * Examples of sinks are #TMPL_TYPE_ATTR. * * VPTs are used to gather values or attributes for evaluation, or copying, and to specify * where values or #fr_pair_t should be copied to. @@ -41,7 +41,7 @@ * @see tmpl_afrom_substr * @see tmpl_afrom_attr_str * - * In the case of #TMPL_TYPE_ATTR and #TMPL_TYPE_LIST, there are special cursor overlay + * In the case of #TMPL_TYPE_ATTR, there are special cursor overlay * functions which can be used to iterate over only the #fr_pair_t that match a * tmpl_t in a given list. * @@ -144,10 +144,6 @@ typedef enum tmpl_type_e { */ TMPL_TYPE_DATA = 0x0002, - /** Reference to an attribute list - */ - TMPL_TYPE_LIST = 0x0004 | TMPL_FLAG_ATTR, - /** Reference to one or more attributes */ TMPL_TYPE_ATTR = 0x0008 | TMPL_FLAG_ATTR, @@ -325,7 +321,7 @@ struct tmpl_attr_rules_s { uint8_t disallow_filters:1; //!< disallow filters. - uint8_t list_as_attr:1; //!< return #TMPL_TYPE_ATTR for lists, and not #TMPL_TYPE_LIST + uint8_t list_as_attr:1; //!< return #TMPL_TYPE_ATTR for lists }; struct tmpl_xlat_rules_s { @@ -541,14 +537,12 @@ static inline bool ar_is_raw(tmpl_attr_t const *ar) * @section update_maps Use in update map_t * When used on the LHS it describes an attribute to create and should be one of these types: * - #TMPL_TYPE_ATTR - * - #TMPL_TYPE_LIST * * When used on the RHS it describes the value to assign to the attribute being created and * should be one of these types: * - #TMPL_TYPE_UNRESOLVED * - #TMPL_TYPE_XLAT_UNRESOLVED * - #TMPL_TYPE_ATTR - * - #TMPL_TYPE_LIST * - #TMPL_TYPE_EXEC * - #TMPL_TYPE_DATA * - #TMPL_TYPE_XLAT (pre-parsed xlat) @@ -669,7 +663,7 @@ static inline tmpl_type_t tmpl_type_from_str(char const *type) } /** @} */ -/** @name Field accessors for #TMPL_TYPE_ATTR, #TMPL_TYPE_ATTR_UNRESOLVED, #TMPL_TYPE_LIST +/** @name Field accessors for #TMPL_TYPE_ATTR, #TMPL_TYPE_ATTR_UNRESOLVED * * @{ */ @@ -969,43 +963,6 @@ void tmpl_attr_verify(char const *file, int line, tmpl_t const *vpt); void tmpl_verify(char const *file, int line, tmpl_t const *vpt); #endif -/** Produces an initialiser for static #TMPL_TYPE_LIST type #tmpl_t - * - * Example: - @code{.c} - static tmpl_t list = tmpl_init_initialiser_list(CURRENT_REQUEST, PAIR_LIST_REQUEST); - fr_dcursor_t cursor; - tmpl_dcursor_ctx_t cc, - fr_pair_t *vp; - - // Iterate over all pairs in the request list - for (vp = tmpl_dcursor_init(NULL, &cursor, request, &list); - vp; - vp = tmpl_cursor_next(&cursor, &list)) { - // Do something - } - tmpl_dcursor_clear(&cc); - @endcode - * - * @param _request to locate the list in. - * @param _list to set as the target for the template. - * @see tmpl_dcursor_init - * @see tmpl_cursor_next - */ -#define tmpl_init_initialiser_list(_request, _list)\ -{ \ - .name = "static", \ - .len = sizeof("static") - 1, \ - .type = TMPL_TYPE_LIST, \ - .quote = T_SINGLE_QUOTED_STRING, \ - .data = { \ - .attribute = { \ - .request = _request, \ - .list = _list \ - } \ - } \ -} - /** Determine the correct context and list head * * Used in conjunction with the fr_dcursor functions to determine the correct list diff --git a/src/lib/server/tmpl_dcursor.c b/src/lib/server/tmpl_dcursor.c index 602aabe7100..624af181abb 100644 --- a/src/lib/server/tmpl_dcursor.c +++ b/src/lib/server/tmpl_dcursor.c @@ -57,11 +57,6 @@ static void *_tmpl_cursor_child_next(fr_dlist_head_t *list, void *curr, void *uc tmpl_dcursor_nested_t *ns = uctx; fr_pair_t *vp = curr; - /* - * Only applies to TMPL_TYPE_LIST - remove when that is gone. - */ - if ((!ns->ar) || (!ns->ar->ar_da)) return fr_dlist_next(list, curr); - while ((vp = fr_dlist_next(list, vp))) { if (fr_dict_attr_cmp(ns->ar->ar_da, vp->da) == 0) break; } @@ -239,22 +234,9 @@ static void *_tmpl_cursor_next(UNUSED fr_dlist_head_t *list, void *curr, void *u return vp; } - null_result: return NULL; } - /* - * Hacks for evaluating lists - * Hopefully this tmpl type goes away soon... - */ - case TMPL_TYPE_LIST: - if (!fr_dlist_tail(&cc->nested)) goto null_result; /* end of list */ - - vp = _tmpl_cursor_eval(curr, cc); - if (!vp) goto null_result; - - return vp; - default: fr_assert(0); } @@ -347,7 +329,6 @@ fr_pair_t *tmpl_dcursor_init_relative(int *err, TALLOC_CTX *ctx, tmpl_dcursor_ct */ switch (vpt->type) { case TMPL_TYPE_ATTR: - case TMPL_TYPE_LIST: _tmpl_cursor_pair_init(list, cc->list, tmpl_attr_list_head(&vpt->data.attribute.ar), cc); break; @@ -559,15 +540,6 @@ int tmpl_extents_find(TALLOC_CTX *ctx, list_ctx = request->pair_root; } - /* - * If it's a list, just return the list head - */ - if (vpt->type == TMPL_TYPE_LIST) { - do_list: - if (existing) EXTENT_ADD(existing, NULL, list_ctx, list_head); - return 0; - } - /* * If it's a leaf skip all the expensive * initialisation and just return the list @@ -583,7 +555,8 @@ int tmpl_extents_find(TALLOC_CTX *ctx, break; default: - goto do_list; + if (existing) EXTENT_ADD(existing, NULL, list_ctx, list_head); + return 0; } /* diff --git a/src/lib/server/tmpl_eval.c b/src/lib/server/tmpl_eval.c index b2eb7b0e2f2..7b5a93289d6 100644 --- a/src/lib/server/tmpl_eval.c +++ b/src/lib/server/tmpl_eval.c @@ -442,7 +442,6 @@ ssize_t _tmpl_to_type(void *out, */ case TMPL_TYPE_UNINITIALISED: case TMPL_TYPE_NULL: - case TMPL_TYPE_LIST: case TMPL_TYPE_EXEC_UNRESOLVED: case TMPL_TYPE_ATTR_UNRESOLVED: case TMPL_TYPE_XLAT_UNRESOLVED: @@ -774,7 +773,6 @@ ssize_t _tmpl_to_atype(TALLOC_CTX *ctx, void *out, */ case TMPL_TYPE_UNINITIALISED: case TMPL_TYPE_NULL: - case TMPL_TYPE_LIST: case TMPL_TYPE_EXEC_UNRESOLVED: case TMPL_TYPE_REGEX: case TMPL_TYPE_REGEX_UNCOMPILED: @@ -850,7 +848,6 @@ ssize_t _tmpl_to_atype(TALLOC_CTX *ctx, void *out, * @param request The current #request_t. * @param vpt specifying the #fr_pair_t type or list to copy. * Must be one of the following types: - * - #TMPL_TYPE_LIST * - #TMPL_TYPE_ATTR * @return * - -1 if no matching #fr_pair_t could be found. @@ -894,7 +891,6 @@ int tmpl_copy_pairs(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, tm * @param request The current #request_t. * @param vpt specifying the #fr_pair_t type or list to copy. * Must be one of the following types: - * - #TMPL_TYPE_LIST * - #TMPL_TYPE_ATTR * @return * - -1 if no matching #fr_pair_t could be found. @@ -943,7 +939,6 @@ done: * @param[in] request The current #request_t. * @param[in] vpt specifying the #fr_pair_t type to find. * Must be one of the following types: - * - #TMPL_TYPE_LIST * - #TMPL_TYPE_ATTR * @return * - 0 on success (found matching #fr_pair_t). diff --git a/src/lib/server/tmpl_tokenize.c b/src/lib/server/tmpl_tokenize.c index 4df7820c7b6..de3b7ac53aa 100644 --- a/src/lib/server/tmpl_tokenize.c +++ b/src/lib/server/tmpl_tokenize.c @@ -108,7 +108,6 @@ fr_table_num_ordered_t const tmpl_type_table[] = { { L("data"), TMPL_TYPE_DATA }, { L("attr"), TMPL_TYPE_ATTR }, - { L("list"), TMPL_TYPE_LIST }, { L("exec"), TMPL_TYPE_EXEC }, { L("xlat"), TMPL_TYPE_XLAT }, @@ -271,7 +270,6 @@ void tmpl_attr_debug(tmpl_t const *vpt) switch (vpt->type) { case TMPL_TYPE_ATTR: case TMPL_TYPE_ATTR_UNRESOLVED: - case TMPL_TYPE_LIST: break; default: @@ -307,7 +305,6 @@ void tmpl_debug(tmpl_t const *vpt) { switch (vpt->type) { case TMPL_TYPE_ATTR: - case TMPL_TYPE_LIST: case TMPL_TYPE_ATTR_UNRESOLVED: tmpl_attr_debug(vpt); return; @@ -765,7 +762,6 @@ static inline CC_HINT(always_inline) void tmpl_type_init(tmpl_t *vpt, tmpl_type_ case TMPL_TYPE_ATTR: case TMPL_TYPE_ATTR_UNRESOLVED: - case TMPL_TYPE_LIST: tmpl_attr_list_talloc_init(tmpl_attr(vpt)); tmpl_request_list_talloc_init(&vpt->data.attribute.rr); break; @@ -1997,15 +1993,13 @@ do_suffix: return 0; } -/** Parse a string into a TMPL_TYPE_ATTR_* or #TMPL_TYPE_LIST type #tmpl_t +/** Parse a string into a TMPL_TYPE_ATTR_* type #tmpl_t * * @param[in,out] ctx to allocate #tmpl_t in. * @param[out] err May be NULL. Provides the exact error that the parser hit * when processing the attribute ref. * @param[out] out Where to write pointer to new #tmpl_t. * @param[in] name of attribute including #tmpl_request_ref_t and #pair_list_t qualifiers. - * If only #tmpl_request_ref_t #pair_list_t qualifiers are found, - * a #TMPL_TYPE_LIST #tmpl_t will be produced. * @param[in] p_rules Formatting rules used to check for trailing garbage. * @param[in] t_rules Rules which control parsing: * - dict_def The default dictionary to use if attributes @@ -2222,28 +2216,6 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t *err, } } - /* - * If there's no attribute references - * treat this as a list reference. - * - * Eventually we'll remove TMPL_TYPE_LIST - */ - if (!at_rules->list_as_attr && (tmpl_attr_list_num_elements(tmpl_attr(vpt)) == 0)) { - tmpl_attr_t *ar; - fr_slen_t slen; - - MEM(ar = talloc_zero(vpt, tmpl_attr_t)); - slen = tmpl_attr_parse_filter(err, ar, &our_name, at_rules); - if (slen == 0) { /* No filter */ - talloc_free(ar); - } else if (slen > 0) { /* Found a filter */ - tmpl_attr_list_insert_tail(&vpt->data.attribute.ar, ar); - } else if (slen < 0) { /* Filter error */ - goto error; - } - vpt->type = TMPL_TYPE_LIST; - } - tmpl_set_name(vpt, T_BARE_WORD, fr_sbuff_start(&our_name), fr_sbuff_used(&our_name)); vpt->rules = *t_rules; /* Record the rules */ @@ -2319,15 +2291,13 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t *err, FR_SBUFF_SET_RETURN(name, &our_name); } -/** Parse a string into a TMPL_TYPE_ATTR_* or #TMPL_TYPE_LIST type #tmpl_t +/** Parse a string into a TMPL_TYPE_ATTR_* type #tmpl_t * * @param[in,out] ctx to allocate #tmpl_t in. * @param[out] err May be NULL. Provides the exact error that the parser hit * when processing the attribute ref. * @param[out] out Where to write pointer to new #tmpl_t. * @param[in] name of attribute including #tmpl_request_ref_t and #pair_list_t qualifiers. - * If only #tmpl_request_ref_t #pair_list_t qualifiers are found, - * a #TMPL_TYPE_LIST #tmpl_t will be produced. * @param[in] t_rules Rules which control parsing. See tmpl_afrom_attr_substr() for details. * * @note Unlike #tmpl_afrom_attr_substr this function will error out if the entire @@ -4023,7 +3993,6 @@ void tmpl_unresolve(tmpl_t *vpt) * These types contain dynamically allocated * attribute and request references. */ - case TMPL_TYPE_LIST: case TMPL_TYPE_ATTR: case TMPL_TYPE_ATTR_UNRESOLVED: tmpl_attr_list_talloc_free(tmpl_attr(vpt)); @@ -4354,7 +4323,6 @@ fr_slen_t tmpl_attr_print(fr_sbuff_t *out, tmpl_t const *vpt, tmpl_attr_prefix_t * Only print things we can print... */ switch (vpt->type) { - case TMPL_TYPE_LIST: case TMPL_TYPE_ATTR_UNRESOLVED: case TMPL_TYPE_ATTR: break; @@ -4566,7 +4534,6 @@ fr_slen_t tmpl_print(fr_sbuff_t *out, tmpl_t const *vpt, TMPL_VERIFY(vpt); switch (vpt->type) { - case TMPL_TYPE_LIST: case TMPL_TYPE_ATTR_UNRESOLVED: case TMPL_TYPE_ATTR: FR_SBUFF_RETURN(tmpl_attr_print, &our_out, vpt, ar_prefix); @@ -4992,24 +4959,6 @@ void tmpl_verify(char const *file, int line, tmpl_t const *vpt) } break; - case TMPL_TYPE_LIST: - if ((nz = CHECK_ZEROED(vpt, attribute))) { - PRINT_NON_ZEROED(vpt, attribute, nz); - fr_fatal_assert_fail("CONSISTENCY CHECK FAILED %s[%u]: TMPL_TYPE_LIST" - "has non-zero bytes after the data.attribute struct in the union", - file, line); - } - - if ((tmpl_attr_list_num_elements(tmpl_attr(vpt)) > 0) && - ((tmpl_attr_t *)tmpl_attr_list_tail(tmpl_attr(vpt)))->da) { -#ifndef NDEBUG - tmpl_attr_debug(vpt); -#endif - fr_fatal_assert_fail("CONSISTENCY CHECK FAILED %s[%u]: TMPL_TYPE_LIST contains %u " - "references", file, line, tmpl_attr_list_num_elements(tmpl_attr(vpt))); - } - break; - case TMPL_TYPE_DATA: if ((nz = CHECK_ZEROED(vpt, literal))) { PRINT_NON_ZEROED(vpt, literal, nz); diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index 3c1977f15b9..277c36d4151 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -852,7 +852,6 @@ int unlang_fixup_update(map_t *map, void *ctx) if (!ctx) { switch (map->lhs->type) { case TMPL_TYPE_ATTR: - case TMPL_TYPE_LIST: tmpl_attr_rewrite_leaf_num(map->lhs, NUM_UNSPEC, NUM_ALL); break; @@ -865,7 +864,6 @@ int unlang_fixup_update(map_t *map, void *ctx) */ switch (map->rhs->type) { case TMPL_TYPE_ATTR: - case TMPL_TYPE_LIST: tmpl_attr_rewrite_leaf_num(map->rhs, NUM_UNSPEC, NUM_ALL); break; diff --git a/src/lib/unlang/xlat_builtin.c b/src/lib/unlang/xlat_builtin.c index d4d6d89b9d8..9db0b3fd0ed 100644 --- a/src/lib/unlang/xlat_builtin.c +++ b/src/lib/unlang/xlat_builtin.c @@ -1560,7 +1560,6 @@ static xlat_action_t xlat_func_map(TALLOC_CTX *ctx, fr_dcursor_t *out, switch (map->lhs->type) { case TMPL_TYPE_ATTR: - case TMPL_TYPE_LIST: case TMPL_TYPE_XLAT: break; @@ -1574,7 +1573,6 @@ static xlat_action_t xlat_func_map(TALLOC_CTX *ctx, fr_dcursor_t *out, case TMPL_TYPE_ATTR: case TMPL_TYPE_EXEC: case TMPL_TYPE_DATA: - case TMPL_TYPE_LIST: case TMPL_TYPE_REGEX_XLAT_UNRESOLVED: case TMPL_TYPE_UNRESOLVED: case TMPL_TYPE_XLAT: diff --git a/src/modules/rlm_cache/rlm_cache.c b/src/modules/rlm_cache/rlm_cache.c index 3b8e7878109..8eb0d04dedb 100644 --- a/src/modules/rlm_cache/rlm_cache.c +++ b/src/modules/rlm_cache/rlm_cache.c @@ -400,7 +400,7 @@ static unlang_action_t cache_insert(rlm_rcode_t *p_result, } else { c_map->lhs = map->lhs; /* lhs shouldn't be touched, so this is ok */ } - do_rhs: + if (vp->vp_type == FR_TYPE_STRING) { quote = is_printable(vp->vp_strvalue, vp->vp_length) ? T_SINGLE_QUOTED_STRING : T_DOUBLE_QUOTED_STRING; @@ -412,7 +412,6 @@ static unlang_action_t cache_insert(rlm_rcode_t *p_result, TMPL_TYPE_DATA, quote, map->rhs->name, map->rhs->len)); if (fr_value_box_copy(c_map->rhs, tmpl_value(c_map->rhs), &vp->data) < 0) { REDEBUG("Failed copying attribute value"); - error: talloc_free(pool); talloc_free(c); RETURN_MODULE_FAIL; @@ -420,17 +419,6 @@ static unlang_action_t cache_insert(rlm_rcode_t *p_result, } break; - /* - * Lists are weird... We need to fudge a new LHS template, - * which is a combination of the LHS list and the attribute. - */ - case TMPL_TYPE_LIST: - if (tmpl_attr_afrom_list(c_map, &c_map->lhs, map->lhs, vp->da) < 0) { - RPERROR("Failed attribute -> list copy"); - goto error; - } - goto do_rhs; - default: fr_assert(0); } diff --git a/src/modules/rlm_csv/rlm_csv.c b/src/modules/rlm_csv/rlm_csv.c index 260c3f26fcf..0fd54f03c02 100644 --- a/src/modules/rlm_csv/rlm_csv.c +++ b/src/modules/rlm_csv/rlm_csv.c @@ -403,9 +403,6 @@ static int csv_map_verify(map_t *map, void *instance) type = tmpl_attr_tail_da(map->lhs)->type; break; - case TMPL_TYPE_LIST: - break; - case TMPL_TYPE_ATTR_UNRESOLVED: cf_log_err(map->ci, "Unknown attribute %s", tmpl_attr_tail_unresolved(map->lhs)); return -1; diff --git a/src/modules/rlm_linelog/rlm_linelog.c b/src/modules/rlm_linelog/rlm_linelog.c index f33db0ff84f..be499a662ab 100644 --- a/src/modules/rlm_linelog/rlm_linelog.c +++ b/src/modules/rlm_linelog/rlm_linelog.c @@ -564,7 +564,6 @@ build_vector: */ switch (vpt_p->type) { case TMPL_TYPE_ATTR: - case TMPL_TYPE_LIST: { #define VECTOR_INCREMENT 20 fr_dcursor_t cursor;