25 RCSID(
"$Id: 514e1194c6fa3d69f5715d0b6b8ca502392be767 $")
27 #include <freeradius-devel/server/log.h>
28 #include <freeradius-devel/util/debug.h>
29 #include <freeradius-devel/server/users_file.h>
31 #include <freeradius-devel/util/misc.h>
32 #include <freeradius-devel/util/pair_legacy.h>
33 #include <freeradius-devel/util/syserror.h>
41 bool complain,
int *order);
44 char const *user_file,
int user_line,
50 fr_sbuff_marker(&start, sbuff);
54 fr_sbuff_marker_release(&start);
58 fr_sbuff_used(sbuff), error,
"%s[%d]: ", user_file, user_line);
65 #define ERROR_MARKER(_sbuff, _error) line_error_marker(__FILE__, __LINE__, file, lineno, _sbuff, _error)
68 char const *user_file,
int user_line,
74 fr_sbuff_marker(&start, sbuff);
78 fr_sbuff_marker_release(&start);
82 marker_idx, error,
"%s[%d]: ", user_file, user_line);
90 #define ERROR_MARKER_ADJ(_sbuff, _idx, _error) line_error_marker_adj(__FILE__, __LINE__, file, lineno, _sbuff, _idx, _error)
144 char const *
file,
int lineno,
int *order)
147 char *newfile, *p, c;
164 fr_sbuff_marker(&
name, sbuff);
168 fr_sbuff_marker_release(&
name);
185 p = strrchr(
file,
'/');
187 if (!p)
goto copy_name;
189 newfile = talloc_asprintf(NULL,
"%.*s/%.*s",
196 fr_sbuff_marker_release(&
name);
225 ERROR(
"%s[%d]: Could not read included file %s: %s",
249 map_t *new_map, *relative_map;
254 char *filename = talloc_strdup(ctx,
file);
263 if ((fp = fopen(
file,
"r")) == NULL) {
268 fr_sbuff_init_file(&sbuff, &fctx,
buffer,
sizeof(
buffer), fp, SIZE_MAX);
312 if (leading_spaces) {
313 ERROR_MARKER(&sbuff,
"Entry does not begin with a key value");
323 if (fr_sbuff_is_str(&sbuff,
"$INCLUDE", 8)) {
344 map_list_init(&t->
check);
345 map_list_init(&t->
reply);
348 t->
order = (*order)++;
353 len = fr_sbuff_out_abstrncpy_until(t, &q, &sbuff, SIZE_MAX, &
name_terms, NULL);
401 (tmpl_regex_compile(new_map->
rhs,
false) < 0)) {
402 ERROR(
"%s[%d]: Failed compiling regular expression /%s/ - %s",
412 map_list_insert_tail(&t->
check, new_map);
447 ERROR_MARKER(&sbuff,
"Invalid comma ending the check item list");
460 ERROR_MARKER(&sbuff,
"Unexpected text after check item");
496 ERROR(
"%s[%d]: Unexpected trailing comma in previous line",
file, lineno);
512 }
else if (lineno == (t->
lineno + 1)) {
516 ERROR(
"%s[%d]: Missing comma in previous line",
file, lineno);
549 ERROR(
"%s[%d]: Unknown attribute '%s'",
550 file, lineno, new_map->
lhs->name);
559 if (!new_map->
parent) map_list_insert_tail(&t->
reply, new_map);
593 if (comma)
goto next_reply_item;
static int const char char buffer[256]
#define L(_str)
Helper for initialising arrays of string literals.
static int fr_dlist_insert_tail(fr_dlist_head_t *list_head, void *ptr)
Insert an item into the tail of a list.
fr_table_num_sorted_t const map_assignment_op_table[]
ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, map_t **parent_p, fr_sbuff_t *in, fr_table_num_sorted_t const *op_table, size_t op_table_len, tmpl_rules_t const *lhs_rules, tmpl_rules_t const *rhs_rules, fr_sbuff_parse_rules_t const *p_rules)
Parse sbuff into (which may contain refs) to map_t.
size_t map_assignment_op_table_len
void fr_log_marker(fr_log_t const *log, fr_log_type_t type, char const *file, int line, char const *str, size_t str_len, ssize_t marker_idx, char const *marker, char const *line_prefix_fmt,...)
Print out an error marker.
@ TMPL_ATTR_REF_PREFIX_AUTO
Attribute refs may have a '&' prefix.
@ TMPL_ATTR_REF_PREFIX_YES
Attribute refs must have '&' prefix.
fr_dict_attr_t const * request_attr_request
fr_dict_attr_t const * request_attr_control
fr_dict_attr_t const * request_attr_reply
char * fr_sbuff_adv_to_chr(fr_sbuff_t *sbuff, size_t len, char c)
Wind position to first instance of specified char.
size_t fr_sbuff_adv_until(fr_sbuff_t *sbuff, size_t len, fr_sbuff_term_t const *tt, char escape_chr)
Wind position until we hit a character in the terminal set.
bool fr_sbuff_next_if_char(fr_sbuff_t *sbuff, char c)
Return true if the current char matches, and if it does, advance.
#define fr_sbuff_start(_sbuff_or_marker)
#define fr_sbuff_set(_dst, _src)
#define fr_sbuff_current(_sbuff_or_marker)
#define fr_sbuff_char(_sbuff_or_marker, _eob)
#define FR_SBUFF_TERMS(...)
Initialise a terminal structure with a list of sorted strings.
#define fr_sbuff_is_char(_sbuff_or_marker, _c)
#define fr_sbuff_end(_sbuff_or_marker)
#define fr_sbuff_adv_past_blank(_sbuff, _len, _tt)
#define fr_sbuff_advance(_sbuff_or_marker, _len)
#define fr_sbuff_used(_sbuff_or_marker)
Set of terminal elements.
File sbuff extension structure.
Set of parsing rules for *unescape_until functions.
void tmpl_attr_set_list(tmpl_t *vpt, fr_dict_attr_t const *list)
#define tmpl_contains_regex(vpt)
static fr_dict_attr_t const * tmpl_attr_tail_da(tmpl_t const *vpt)
Return the last attribute reference da.
#define tmpl_is_attr(vpt)
tmpl_attr_rules_t attr
Rules/data for parsing attribute references.
@ TMPL_ATTR_LIST_ALLOW
Attribute refs are allowed to have a list.
struct tmpl_rules_s tmpl_rules_t
#define tmpl_is_regex_uncompiled(vpt)
Optional arguments passed to vp_tmpl functions.
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
tmpl_t * lhs
Typically describes the attribute to add, modify or compare.
tmpl_t * rhs
Typically describes a literal value or a src attribute to copy or compare.
fr_dict_attr_t const * list_def
Default list to use with unqualified attribute reference.
fr_dict_t const * dict_def
Default dictionary to use with unqualified attribute references.
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
An element in a lexicographically sorted array of name to num mappings.
static size_t check_cmp_op_table_len
#define ERROR_MARKER_ADJ(_sbuff, _idx, _error)
Print out a line oriented error marker relative to the current position of the sbuff.
static void line_error_marker_adj(char const *src_file, int src_line, char const *user_file, int user_line, fr_sbuff_t *sbuff, ssize_t marker_idx, char const *error)
#define ERROR_MARKER(_sbuff, _error)
Print out a line oriented error marker at the current position of the sbuff.
int pairlist_read(TALLOC_CTX *ctx, fr_dict_t const *dict, char const *file, PAIR_LIST_LIST *list)
static fr_table_num_sorted_t const check_cmp_op_table[]
static int users_include(TALLOC_CTX *ctx, fr_dict_t const *dict, fr_sbuff_t *sbuff, PAIR_LIST_LIST *list, char const *file, int lineno, int *order)
static int pairlist_read_internal(TALLOC_CTX *ctx, fr_dict_t const *dict, char const *file, PAIR_LIST_LIST *list, bool complain, int *order)
static fr_sbuff_parse_rules_t const rhs_term
static const fr_sbuff_term_t name_terms
static void line_error_marker(char const *src_file, int src_line, char const *user_file, int user_line, fr_sbuff_t *sbuff, char const *error)
char const * name
Key for matching entry.
fr_dlist_head_t head
Head of the list of PAIR_LISTs.
char const * filename
Filename entry read from.
int lineno
Line number entry read from.
int order
Sequence of entry in source file.
map_list_t check
List of maps for comparison / modifying control list.
map_list_t reply
List of maps for modifying reply list.
char const * fr_strerror(void)
Get the last library error.