The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
map.c
Go to the documentation of this file.
1/*
2 * This program is is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or (at
5 * your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17/**
18 * $Id: a00fade6649731a05920c07d638977d893320820 $
19 * @file src/lib/ldap/map.c
20 * @brief Functions for mapping between LDAP and FreeRADIUS attributes.
21 *
22 * @author Arran Cudbard-Bell (a.cudbardb@freeradius.org)
23 * @copyright 2013 Network RADIUS SAS (legal@networkradius.com)
24 * @copyright 2013 The FreeRADIUS Server Project.
25 */
26RCSID("$Id: a00fade6649731a05920c07d638977d893320820 $")
27
29
30#include <freeradius-devel/util/debug.h>
31#include <freeradius-devel/ldap/base.h>
32
33/** Callback for map_to_request
34 *
35 * Performs exactly the same job as map_to_vp, but pulls attribute values from LDAP entries
36 *
37 * @see map_to_vp
38 */
39int fr_ldap_map_getvalue(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t const *map, void *uctx)
40{
41 fr_ldap_result_t *self = uctx;
44 int i;
45
47
48 fr_assert(map->lhs->type == TMPL_TYPE_ATTR);
49
50 /*
51 * This is a mapping in the form of:
52 * <list>. += <ldap attr>
53 *
54 * Where <ldap attr> is:
55 * <list>.<attr> <op> <value>
56 *
57 * It is to allow for legacy installations which stored
58 * RADIUS control and reply attributes in separate LDAP
59 * attributes.
60 */
61 if (tmpl_is_list(map->lhs)) {
62 for (i = 0; i < self->count; i++) {
63 map_t *attr = NULL;
64 char *attr_str;
65
66 tmpl_rules_t lhs_rules = {
67 .attr = {
68 .dict_def = request->local_dict,
69 .request_def = tmpl_request(map->lhs),
70 .list_def = tmpl_list(map->lhs),
71 },
72 .xlat = {
73 .runtime_el = unlang_interpret_event_list(request),
74 },
75 .at_runtime = true,
76 };
77
78 tmpl_rules_t rhs_rules = {
79 .attr = {
80 .dict_def = request->local_dict
81 },
82 .xlat = {
83 .runtime_el = lhs_rules.xlat.runtime_el,
84 },
85 .at_runtime = true,
86 };
87
88 RDEBUG3("Parsing valuepair string \"%pV\"",
89 fr_box_strvalue_len(self->values[i]->bv_val, self->values[i]->bv_len));
90
91 /*
92 * bv_val is NOT \0 terminated, so we need to make it
93 * safe (\0 terminate it) before passing it to any
94 * functions which take C strings and no lengths.
95 */
96 attr_str = talloc_bstrndup(NULL, self->values[i]->bv_val, self->values[i]->bv_len);
97 if (!attr_str) {
98 RWDEBUG("Failed making attribute string safe");
99 continue;
100 }
101
102 if (map_afrom_attr_str(ctx, &attr,
103 attr_str,
104 &lhs_rules, &rhs_rules) < 0) {
105 RPWDEBUG("Failed parsing \"%pV\" as valuepair, skipping...",
106 fr_box_strvalue_len(self->values[i]->bv_val, self->values[i]->bv_len));
107 talloc_free(attr_str);
108 continue;
109 }
110
111 talloc_free(attr_str);
112
113 if (tmpl_is_data_unresolved(attr->lhs)) {
114 RWDEBUG("Failed parsing left side of \"%pV\", skipping...",
115 fr_box_strvalue_len(self->values[i]->bv_val, self->values[i]->bv_len));
116 talloc_free(attr);
117 continue;
118 }
119
120 if (tmpl_request_ref_list_cmp(tmpl_request(attr->lhs), tmpl_request(map->lhs)) != 0) {
121 char *attr_request;
122 char *map_request;
123
124 tmpl_request_ref_list_aprint(NULL, &attr_request, tmpl_request(attr->lhs));
125 tmpl_request_ref_list_aprint(NULL, &map_request, tmpl_request(map->lhs));
126
127 RWDEBUG("valuepair \"%pV\" has conflicting request qualifier (%s vs %s), skipping...",
128 fr_box_strvalue_len(self->values[i]->bv_val, self->values[i]->bv_len),
129 attr_request, map_request);
130
131 talloc_free(attr_request);
132 talloc_free(map_request);
133
134 next_pair:
135 talloc_free(attr);
136 continue;
137 }
138
139 if ((tmpl_list(attr->lhs) != tmpl_list(map->lhs))) {
140 RWDEBUG("valuepair \"%pV\" has conflicting list qualifier (%s vs %s), skipping...",
141 fr_box_strvalue_len(self->values[i]->bv_val, self->values[i]->bv_len),
142 tmpl_list_name(tmpl_list(attr->lhs), "<INVALID>"),
143 tmpl_list_name(tmpl_list(map->lhs), "<INVALID>"));
144 goto next_pair;
145 }
146
147 if (map_to_request(request, attr, map_to_vp, NULL) < 0) {
148 RWDEBUG("Failed creating attribute for valuepair \"%pV\", skipping...",
149 fr_box_strvalue_len(self->values[i]->bv_val, self->values[i]->bv_len));
150 goto next_pair;
151 }
152
153 talloc_free(attr);
154
155 /*
156 * Only process the first value, unless the operator is +=
157 */
158 if (map->op != T_OP_ADD_EQ) break;
159 }
160 goto finish;
161 }
162
163 /*
164 * Iterate over all the retrieved values,
165 * don't try and be clever about changing operators
166 * just use whatever was set in the attribute map.
167 */
168 for (i = 0; i < self->count; i++) {
169 if (!self->values[i]->bv_len) continue;
170
172
173 if (fr_pair_value_from_str(vp, self->values[i]->bv_val,
174 self->values[i]->bv_len, NULL, true) < 0) {
175 RPWDEBUG("Failed parsing value \"%pV\" for attribute %s",
176 fr_box_strvalue_len(self->values[i]->bv_val, self->values[i]->bv_len),
177 tmpl_attr_tail_da(map->lhs)->name);
178
180 continue;
181 }
182
184
185 /*
186 * Only process the first value, unless the operator is +=
187 */
188 if (map->op != T_OP_ADD_EQ) break;
189 }
190
191finish:
193
194 return 0;
195}
196
197/** Callback for map_to_request
198 *
199 * Performs exactly the same job as map_to_vp, but pulls value from the entry DN.
200 *
201 * @see map_to_vp
202 */
203static int fr_ldap_map_getdn(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t const *map, void *uctx)
204{
205 char const *dn = uctx;
206 fr_pair_t *vp;
207
208 fr_assert(map->lhs->type == TMPL_TYPE_ATTR);
209 switch (tmpl_attr_tail_da(map->lhs)->type) {
210 case FR_TYPE_STRING:
211 case FR_TYPE_OCTETS:
212 break;
213
214 default:
215 RERROR("Cannot store DN in %s",
216 fr_table_str_by_value(fr_type_table, tmpl_attr_tail_da(map->lhs)->type, "<INVALID>"));
217 return -1;
218 }
219
221
222 if (fr_pair_value_from_str(vp, dn, strlen(dn), NULL, true) < 0) {
223 RPWDEBUG("Failed parsing value \"%pV\" for attribute %s", dn,
224 tmpl_attr_tail_da(map->lhs)->name);
226 }
227
229
230 return 0;
231}
232
233int fr_ldap_map_verify(map_t *map, UNUSED void *instance)
234{
235 /*
236 * Destinations where we can put the fr_pair_ts we
237 * create using LDAP values.
238 */
239 switch (map->lhs->type) {
240 case TMPL_TYPE_ATTR:
241 break;
242
244 cf_log_err(map->ci, "Unknown attribute %s", tmpl_attr_tail_unresolved(map->lhs));
245 return -1;
246
247 default:
248 cf_log_err(map->ci, "Left hand side of map must be an attribute or list, not a %s",
249 tmpl_type_to_str(map->lhs->type));
250 return -1;
251 }
252
253 /*
254 * Sources we can use to get the name of the attribute
255 * we're retrieving from LDAP.
256 */
257 switch (map->rhs->type) {
259 case TMPL_TYPE_ATTR:
260 case TMPL_TYPE_EXEC:
261 case TMPL_TYPE_DATA:
262 break;
263
265 cf_log_err(map->ci, "Unknown attribute %s", tmpl_attr_tail_unresolved(map->rhs));
266 return -1;
267
269 if (tmpl_resolve(map->rhs, NULL) < 0) {
270 cf_log_err(map->ci, "Invalid data %s", map->rhs->name);
271 return -1;
272 }
273 break;
274
275 default:
276 cf_log_err(map->ci, "Right hand side of map must be an xlat, attribute, exec, or literal, not a %s",
277 tmpl_type_to_str(map->rhs->type));
278 return -1;
279 }
280
281 /*
282 * Only =, :=, += and -= operators are supported for LDAP mappings.
283 */
284 switch (map->op) {
285 case T_OP_SET:
286 case T_OP_EQ:
287 case T_OP_SUB_EQ:
288 case T_OP_ADD_EQ:
289 break;
290
291 default:
292 cf_log_err(map->ci, "Operator \"%s\" not allowed for LDAP mappings",
293 fr_table_str_by_value(fr_tokens_table, map->op, "<INVALID>"));
294 return -1;
295 }
296
297 return 0;
298}
299
300/** Expand values in an attribute map where needed
301 *
302 * @param[in] ctx o allocate any dynamic expansions in.
303 * @param[out] expanded array of attributes. Need not be initialised (we'll initialise).
304 * @param[in] request The current request.
305 * @param[in] maps to expand.
306 * @param[in] generic_attr name to append to the attribute list.
307 * @param[in] check_attr name to append to the attribute list.
308 * @param[in] fallthrough_attr name to append to the attribute list.
309 * @return
310 * - 0 on success.
311 * - -1 on failure.
312 */
313int fr_ldap_map_expand(TALLOC_CTX *ctx, fr_ldap_map_exp_t *expanded, request_t *request, map_list_t const *maps,
314 char const *generic_attr, char const *check_attr, char const *fallthrough_attr)
315{
316 map_t const *map = NULL;
317 unsigned int total = 0;
318
319 TALLOC_CTX *our_ctx = NULL;
320 char const *attr;
321 char attr_buff[1024 + 1]; /* X.501 says we need to support at least 1024 chars for attr names */
322
323 while ((map = map_list_next(maps, map))) {
324 if (tmpl_expand(&attr, attr_buff, sizeof(attr_buff), request, map->rhs) < 0) {
325 REDEBUG("Expansion of LDAP attribute \"%s\" failed", map->rhs->name);
326 TALLOC_FREE(our_ctx);
327 return -1;
328 }
329
330 /*
331 * Dynamic value
332 */
333 if (attr == attr_buff) {
334 if (!our_ctx) our_ctx = talloc_new(ctx);
335 expanded->attrs[total++] = talloc_strdup(our_ctx, attr_buff);
336 continue;
337 }
338 expanded->attrs[total++] = attr;
339 }
340
341 if (generic_attr) expanded->attrs[total++] = generic_attr;
342 if (check_attr) expanded->attrs[total++] = check_attr;
343 if (fallthrough_attr) expanded->attrs[total++] = fallthrough_attr;
344
345 expanded->attrs[total] = NULL;
346 expanded->count = total;
347 expanded->maps = maps;
348
349 return 0;
350}
351
352
353/** Convert attribute map into valuepairs
354 *
355 * Use the attribute map built earlier to convert LDAP values into valuepairs and insert them into whichever
356 * list they need to go into.
357 *
358 * This is *NOT* atomic, but there's no condition for which we should error out...
359 *
360 * @param[in] request Current request.
361 * @param[in] check_attr Treat attribute with this name as a condition to process the map.
362 * @param[in] valuepair_attr Treat attribute with this name as holding complete AVP definitions.
363 * @param[in] expanded attributes (rhs of map).
364 * @param[in] entry to retrieve attributes from.
365 * @return
366 * - Number of maps successfully applied.
367 * - -1 on failure.
368 */
369int fr_ldap_map_do(request_t *request, char const *check_attr,
370 char const *valuepair_attr, fr_ldap_map_exp_t const *expanded, LDAPMessage *entry)
371{
372 map_t const *map = NULL;
373 unsigned int total = 0;
374 int applied = 0; /* How many maps have been applied to the current request */
375
376 fr_ldap_result_t result;
377 char const *name;
378 LDAP *handle = fr_ldap_handle_thread_local();
379
380 if (check_attr) {
381 struct berval **values;
382 int count, i;
383 tmpl_rules_t const parse_rules = {
384 .attr = {
385 .dict_def = request->local_dict,
386 .list_def = request_attr_request,
387 },
388 .xlat = {
389 .runtime_el = unlang_interpret_event_list(request),
390 },
391 .at_runtime = true,
392 };
393
394 values = ldap_get_values_len(handle, entry, check_attr);
395 count = ldap_count_values_len(values);
396
397 for (i = 0; i < count; i++) {
398 char *value = fr_ldap_berval_to_string(request, values[i]);
399 xlat_exp_head_t *cond_expr = NULL;
400 fr_value_box_list_t res;
401
402 RDEBUG3("Parsing condition %s", value);
403
404 if (xlat_tokenize_expression(request, &cond_expr,
406 NULL, &parse_rules) < 0) {
407 RPEDEBUG("Failed parsing '%s' value \"%s\"", check_attr, value);
408 fail:
409 applied = -1;
410 free:
411 talloc_free(cond_expr);
413 ldap_value_free_len(values);
414 return applied;
415 }
416
417 if (xlat_impure_func(cond_expr)) {
418 fr_strerror_const("Condition expression cannot depend on functions which call external databases");
419 goto fail;
420 }
421
422 RDEBUG2("Checking condition %s", value);
423 fr_value_box_list_init(&res);
424 if (unlang_xlat_eval(request, &res, request, cond_expr) < 0) {
425 RPEDEBUG("Failed evaluating condition");
426 goto fail;
427 }
428 if (!fr_value_box_list_head(&res) || !fr_value_box_is_truthy(fr_value_box_list_head(&res))) {
429 RDEBUG2("Failed match: skipping this profile");
430 fr_value_box_list_talloc_free(&res);
431 goto free;
432 }
434 talloc_free(cond_expr);
435 fr_value_box_list_talloc_free(&res);
436 }
437 ldap_value_free_len(values);
438 }
439
440 while ((map = map_list_next(expanded->maps, map))) {
441 int ret;
442
443 name = expanded->attrs[total++];
444
445 /*
446 * Binary safe
447 */
448 result.values = ldap_get_values_len(handle, entry, name);
449 if (!result.values) {
450 /*
451 * dn is different - it's not (normally) an LDAP attribute
452 * so requires special handling.
453 */
454 if (strcmp(name, "dn") == 0) {
455 char *dn = ldap_get_dn(handle, entry);
457 ret = map_to_request(request, map, fr_ldap_map_getdn, dn);
458 ldap_memfree(dn);
459 if (ret == -1) return -1;
460 applied++;
461 continue;
462 }
463
464 RDEBUG3("Attribute \"%s\" not found in LDAP object", name);
465
466 goto next;
467 }
468
469 /*
470 * Find out how many values there are for the
471 * attribute and extract all of them.
472 */
473 result.count = ldap_count_values_len(result.values);
474
475 /*
476 * If something bad happened, just skip, this is probably
477 * a case of the dst being incorrect for the current
478 * request context
479 */
480 ret = map_to_request(request, map, fr_ldap_map_getvalue, &result);
481 if (ret == -1) return -1; /* Fail */
482
483 /*
484 * How many maps we've processed
485 */
486 applied++;
487
488 next:
489 ldap_value_free_len(result.values);
490 }
491
492
493 /*
494 * Retrieve any valuepair attributes from the result, these are generic values specifying
495 * a radius list, operator and value.
496 */
497 if (valuepair_attr) {
498 struct berval **values;
499 int count, i;
500
501 values = ldap_get_values_len(handle, entry, valuepair_attr);
502 count = ldap_count_values_len(values);
503
504 for (i = 0; i < count; i++) {
505 map_t *attr;
506 char *value;
507
508 tmpl_rules_t const parse_rules = {
509 .attr = {
510 .dict_def = request->local_dict,
511 .list_def = request_attr_request,
512 },
513 .xlat = {
514 .runtime_el = unlang_interpret_event_list(request),
515 },
516 .at_runtime = true,
517 };
518
519 value = fr_ldap_berval_to_string(request, values[i]);
520 RDEBUG3("Parsing attribute string '%s'", value);
521 if (map_afrom_attr_str(request, &attr, value,
522 &parse_rules, &parse_rules) < 0) {
523 RPWDEBUG("Failed parsing '%s' value \"%s\" as valuepair, skipping...",
524 valuepair_attr, value);
526 continue;
527 }
528 if (map_to_request(request, attr, map_to_vp, NULL) < 0) {
529 RWDEBUG("Failed adding \"%s\" to request, skipping...", value);
530 } else {
531 applied++;
532 }
533 talloc_free(attr);
535 }
536 ldap_value_free_len(values);
537 }
538
539 return applied;
540}
#define USES_APPLE_DEPRECATED_API
Definition build.h:474
#define RCSID(id)
Definition build.h:487
#define UNUSED
Definition build.h:317
#define cf_log_err(_cf, _fmt,...)
Definition cf_util.h:288
#define MEM(x)
Definition debug.h:36
Test enumeration values.
Definition dict_test.h:92
free(array)
talloc_free(hp)
fr_event_list_t * unlang_interpret_event_list(request_t *request)
Get the event list for the current interpreter.
Definition interpret.c:2052
size_t fr_ldap_util_normalise_dn(char *out, char const *in)
Normalise escape sequences in a DN.
Definition util.c:492
struct berval ** values
libldap struct containing bv_val (char *) and length bv_len.
Definition base.h:361
int count
Index on next free element.
Definition base.h:375
map_list_t const * maps
Head of list of maps we expanded the RHS of.
Definition base.h:371
char * fr_ldap_berval_to_string(TALLOC_CTX *ctx, struct berval const *in)
Convert a berval to a talloced string.
Definition util.c:443
int count
Number of values.
Definition base.h:363
char const * attrs[LDAP_MAX_ATTRMAP+LDAP_MAP_RESERVED+1]
Reserve some space for access attributes.
Definition base.h:372
Result of expanding the RHS of a set of maps.
Definition base.h:370
Contains a collection of values.
Definition base.h:360
LDAP * fr_ldap_handle_thread_local(void)
Get a thread local dummy LDAP handle.
Definition base.c:1132
int fr_ldap_map_do(request_t *request, char const *check_attr, char const *valuepair_attr, fr_ldap_map_exp_t const *expanded, LDAPMessage *entry)
Convert attribute map into valuepairs.
Definition map.c:369
static int fr_ldap_map_getdn(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t const *map, void *uctx)
Callback for map_to_request.
Definition map.c:203
USES_APPLE_DEPRECATED_API int fr_ldap_map_getvalue(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t const *map, void *uctx)
Callback for map_to_request.
Definition map.c:39
int fr_ldap_map_verify(map_t *map, UNUSED void *instance)
Definition map.c:233
int fr_ldap_map_expand(TALLOC_CTX *ctx, fr_ldap_map_exp_t *expanded, request_t *request, map_list_t const *maps, char const *generic_attr, char const *check_attr, char const *fallthrough_attr)
Expand values in an attribute map where needed.
Definition map.c:313
#define RWDEBUG(fmt,...)
Definition log.h:373
#define RDEBUG3(fmt,...)
Definition log.h:355
#define RERROR(fmt,...)
Definition log.h:310
#define RPEDEBUG(fmt,...)
Definition log.h:388
#define RPWDEBUG(fmt,...)
Definition log.h:378
int map_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t const *map, UNUSED void *uctx)
Convert a map to a fr_pair_t.
Definition map.c:1601
int map_to_request(request_t *request, map_t const *map, radius_map_getvalue_t func, void *ctx)
Convert map_t to fr_pair_t (s) and add them to a request_t.
Definition map.c:1881
int map_afrom_attr_str(TALLOC_CTX *ctx, map_t **out, char const *vp_str, tmpl_rules_t const *lhs_rules, tmpl_rules_t const *rhs_rules)
Convert a value pair string to valuepair map.
Definition map.c:1436
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_OCTETS
Raw octets.
int fr_pair_value_from_str(fr_pair_t *vp, char const *value, size_t inlen, fr_sbuff_unescape_rules_t const *uerules, UNUSED bool tainted)
Convert string value to native attribute value.
Definition pair.c:2602
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
Definition pair.c:1351
fr_pair_t * fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Dynamically allocate a new attribute and assign a fr_dict_attr_t.
Definition pair.c:290
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
Definition pair.c:46
#define fr_assert(_expr)
Definition rad_assert.h:38
#define REDEBUG(fmt,...)
#define RDEBUG2(fmt,...)
fr_dict_attr_t const * request_attr_request
Definition request.c:43
static char const * name
#define FR_SBUFF_IN(_start, _len_or_end)
int8_t tmpl_request_ref_list_cmp(FR_DLIST_HEAD(tmpl_request_list) const *a, FR_DLIST_HEAD(tmpl_request_list) const *b)
Compare a list of request qualifiers.
static char const * tmpl_type_to_str(tmpl_type_t type)
Return a static string containing the type name.
Definition tmpl.h:638
int tmpl_resolve(tmpl_t *vpt, tmpl_res_rules_t const *tr_rules))
Attempt to resolve functions and attributes in xlats and attribute references.
static fr_dict_attr_t const * tmpl_list(tmpl_t const *vpt)
Definition tmpl.h:904
static fr_slen_t tmpl_request_ref_list_aprint(TALLOC_CTX *ctx, char **out, FR_DLIST_HEAD(tmpl_request_list) const *rql) 1(tmpl_request_ref_list_print
@ TMPL_TYPE_ATTR_UNRESOLVED
An attribute reference that we couldn't resolve but looked valid.
Definition tmpl.h:185
@ TMPL_TYPE_ATTR
Reference to one or more attributes.
Definition tmpl.h:142
@ TMPL_TYPE_EXEC
Callout to an external script or program.
Definition tmpl.h:150
@ TMPL_TYPE_DATA
Value in native boxed format.
Definition tmpl.h:138
@ TMPL_TYPE_DATA_UNRESOLVED
Unparsed literal string.
Definition tmpl.h:179
@ TMPL_TYPE_XLAT_UNRESOLVED
A xlat expansion with unresolved xlat functions or attribute references.
Definition tmpl.h:193
tmpl_xlat_rules_t xlat
Rules/data for parsing xlats.
Definition tmpl.h:340
static char const * tmpl_attr_tail_unresolved(tmpl_t const *vpt)
Return the last attribute reference unresolved da.
Definition tmpl.h:869
static bool tmpl_is_list(tmpl_t const *vpt)
Definition tmpl.h:920
#define tmpl_expand(_out, _buff, _buff_len, _request, _vpt)
Expand a tmpl to a C type, using existing storage to hold variably sized types.
Definition tmpl.h:1054
#define tmpl_is_data_unresolved(vpt)
Definition tmpl.h:217
tmpl_attr_rules_t attr
Rules/data for parsing attribute references.
Definition tmpl.h:339
static fr_dict_attr_t const * tmpl_attr_tail_da(tmpl_t const *vpt)
Return the last attribute reference da.
Definition tmpl.h:801
static char const * tmpl_list_name(fr_dict_attr_t const *list, char const *def)
Return the name of a tmpl list or def if list not provided.
Definition tmpl.h:915
fr_event_list_t * runtime_el
The eventlist to use for runtime instantiation of xlats.
Definition tmpl.h:328
Optional arguments passed to vp_tmpl functions.
Definition tmpl.h:336
return count
Definition module.c:155
fr_pair_t * vp
Value pair map.
Definition map.h:77
fr_token_t op
The operator that controls insertion of the dst attribute.
Definition map.h:82
tmpl_t * lhs
Typically describes the attribute to add, modify or compare.
Definition map.h:78
tmpl_t * rhs
Typically describes a literal value or a src attribute to copy or compare.
Definition map.h:79
CONF_ITEM * ci
Config item that the map was created from.
Definition map.h:85
fr_dict_t const * dict_def
Default dictionary to use with unqualified attribute references.
Definition tmpl.h:273
Stores an attribute, a value and various bits of other data.
Definition pair.h:68
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
Definition table.h:772
char * talloc_bstrndup(TALLOC_CTX *ctx, char const *in, size_t inlen)
Binary safe strndup function.
Definition talloc.c:617
#define talloc_strdup(_ctx, _str)
Definition talloc.h:145
static size_t talloc_strlen(char const *s)
Returns the length of a talloc array containing a string.
Definition talloc.h:139
fr_table_num_ordered_t const fr_tokens_table[]
Definition token.c:34
@ T_OP_SUB_EQ
Definition token.h:70
@ T_OP_EQ
Definition token.h:83
@ T_OP_SET
Definition token.h:84
@ T_OP_ADD_EQ
Definition token.h:69
int unlang_xlat_eval(TALLOC_CTX *ctx, fr_value_box_list_t *out, request_t *request, xlat_exp_head_t const *xlat)
Evaluate a "pure" (or not impure) xlat.
Definition xlat.c:712
bool xlat_impure_func(xlat_exp_head_t const *head)
static fr_slen_t head
Definition xlat.h:420
fr_slen_t xlat_tokenize_expression(TALLOC_CTX *ctx, xlat_exp_head_t **head, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules))
Definition xlat_expr.c:3165
void fr_pair_list_append(fr_pair_list_t *dst, fr_pair_list_t *src)
Appends a list of fr_pair_t from a temporary list to a destination list.
#define fr_strerror_const(_msg)
Definition strerror.h:223
fr_table_num_ordered_t const fr_type_table[]
Map data types to names representing those types.
Definition types.c:31
bool fr_value_box_is_truthy(fr_value_box_t const *in)
Check truthiness of values.
Definition value.c:7287
#define fr_box_strvalue_len(_val, _len)
Definition value.h:309
static size_t char ** out
Definition value.h:1024