![]() |
The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Convert internal format configuration values into native C types. More...
#include <string.h>#include <sys/errno.h>#include <sys/fcntl.h>#include <freeradius-devel/server/cf_file.h>#include <freeradius-devel/server/cf_parse.h>#include <freeradius-devel/server/cf_priv.h>#include <freeradius-devel/server/log.h>#include <freeradius-devel/server/tmpl.h>#include <freeradius-devel/server/virtual_servers.h>#include <freeradius-devel/server/main_config.h>#include <freeradius-devel/util/debug.h>#include <freeradius-devel/util/inet.h>#include <freeradius-devel/util/misc.h>#include <freeradius-devel/util/perm.h>#include <freeradius-devel/util/syserror.h>
Include dependency graph for cf_parse.c:Go to the source code of this file.
Macros | |
| #define | PAIR_SPACE(_cs) ((_cs->depth + 1) * 2) |
| #define | SECTION_SPACE(_cs) (_cs->depth * 2) |
Functions | |
| int | _cf_section_rule_push (CONF_SECTION *cs, conf_parser_t const *rule, char const *filename, int lineno) |
| Add a single rule to a CONF_SECTION. | |
| int | _cf_section_rules_push (CONF_SECTION *cs, conf_parser_t const *rules, char const *filename, int lineno) |
| Add an array of parse rules to a CONF_SECTION. | |
| int | cf_null_on_read (UNUSED TALLOC_CTX *ctx, UNUSED void *out, UNUSED void *parent, UNUSED CONF_ITEM *ci, UNUSED conf_parser_t const *rule) |
| NULL callback for sections. | |
| void | cf_pair_debug_log (CONF_SECTION const *cs, CONF_PAIR *cp, conf_parser_t const *rule) |
| static int | cf_pair_default (CONF_PAIR **out, void *parent, CONF_SECTION *cs, conf_parser_t const *rule) |
| Allocate a pair using the dflt value and quotation. | |
| int | cf_pair_parse (TALLOC_CTX *ctx, CONF_SECTION *cs, char const *name, unsigned int type, void *data, char const *dflt, fr_token_t dflt_quote) |
| Parses a CONF_PAIR into a C data type, with a default value. | |
| static int | cf_pair_parse_internal (TALLOC_CTX *ctx, void *out, void *base, CONF_SECTION *cs, conf_parser_t const *rule) |
| Parses a CONF_PAIR into a C data type, with a default value. | |
| int | cf_pair_parse_value (TALLOC_CTX *ctx, void *out, UNUSED void *base, CONF_ITEM *ci, conf_parser_t const *rule) |
| Parses a CONF_PAIR into a C data type. | |
| int | cf_pair_to_value_box (TALLOC_CTX *ctx, fr_value_box_t *out, CONF_PAIR *cp, conf_parser_t const *rule) |
| Parses a CONF_PAIR into a boxed value. | |
| static int | cf_pair_unescape (CONF_PAIR *cp, conf_parser_t const *rule) |
| int | cf_parse_gid (TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule) |
| Generic function for resolving GID strings to uid_t values. | |
| int | cf_parse_permissions (UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule) |
| Generic function for resolving permissions to a mode-t. | |
| static int | cf_parse_tmpl_pass2 (UNUSED CONF_SECTION *cs, tmpl_t **out, CONF_PAIR *cp, fr_type_t type, bool attribute, fr_dict_t const *dict_def) |
| int | cf_parse_uid (TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule) |
| Generic function for resolving UID strings to uid_t values. | |
| int | cf_section_parse (TALLOC_CTX *ctx, void *base, CONF_SECTION *cs) |
| Parse a configuration section into user-supplied variables. | |
| static int | cf_section_parse_init (CONF_SECTION *cs, void *base, conf_parser_t const *rule) |
| Pre-allocate a config section structure to allow defaults to be set. | |
| int | cf_section_parse_pass2 (void *base, CONF_SECTION *cs) |
| Fixup xlat expansions and attributes. | |
| static int | cf_section_parse_rule (TALLOC_CTX *ctx, void *base, CONF_SECTION *cs, conf_parser_t const *rule) |
| static void | cf_section_parse_warn (CONF_SECTION *cs) |
| static int | cf_subsection_parse (TALLOC_CTX *ctx, void *out, void *base, CONF_SECTION *cs, conf_parser_t const *rule) |
| Parse a subsection. | |
| int | cf_table_parse_int (UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule) |
| Generic function for parsing conf pair values as int. | |
| int | cf_table_parse_int32 (UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule) |
| Generic function for parsing conf pair values as int32_t (FR_TYPE_INT32) | |
| int | cf_table_parse_uint32 (UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule) |
| Generic function for parsing conf pair values as int32_t (FR_TYPE_UINT32) | |
Variables | |
| static conf_parser_t | conf_term = CONF_PARSER_TERMINATOR |
| static char const | parse_spaces [] = " " |
Convert internal format configuration values into native C types.
Definition in file cf_parse.c.
Definition at line 49 of file cf_parse.c.
Definition at line 50 of file cf_parse.c.
| int _cf_section_rule_push | ( | CONF_SECTION * | cs, |
| conf_parser_t const * | rule, | ||
| char const * | filename, | ||
| int | lineno | ||
| ) |
Add a single rule to a CONF_SECTION.
| [in] | cs | to add rules to. |
| [in] | rule | to add. |
| [in] | filename | where the rule was pushed. |
| [in] | lineno | where the rule was pushed. |
Definition at line 1503 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int _cf_section_rules_push | ( | CONF_SECTION * | cs, |
| conf_parser_t const * | rules, | ||
| char const * | filename, | ||
| int | lineno | ||
| ) |
Add an array of parse rules to a CONF_SECTION.
| [in] | cs | to add rules to. |
| [in] | rules | to add. Last element should have NULL name field. |
| [in] | filename | where the rule was pushed. |
| [in] | lineno | where the rule was pushed. |
Definition at line 1607 of file cf_parse.c.
Here is the call graph for this function:| int cf_null_on_read | ( | UNUSED TALLOC_CTX * | ctx, |
| UNUSED void * | out, | ||
| UNUSED void * | parent, | ||
| UNUSED CONF_ITEM * | ci, | ||
| UNUSED conf_parser_t const * | rule | ||
| ) |
NULL callback for sections.
This callback exists only as a place-holder to ensure that the nested on_read functions are called. The conf file routines won't recurse into every conf_parser_t section to check if there's an "on_read" callback. So this place-holder is a signal to do that.
| [in] | ctx | to allocate data in. |
| [out] | out | Unused |
| [in] | parent | Base structure address. |
| [in] | ci | CONF_SECTION containing the current section. |
| [in] | rule | unused. |
Definition at line 1747 of file cf_parse.c.
| void cf_pair_debug_log | ( | CONF_SECTION const * | cs, |
| CONF_PAIR * | cp, | ||
| conf_parser_t const * | rule | ||
| ) |
Definition at line 52 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Allocate a pair using the dflt value and quotation.
The pair created by this function should fed to cf_pair_parse for parsing.
| [out] | out | Where to write the CONF_PAIR we created with the default value. |
| [in] | parent | being populated. |
| [in] | cs | to parent the CONF_PAIR from. |
| [in] | rule | to use to create the default. |
Definition at line 367 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int cf_pair_parse | ( | TALLOC_CTX * | ctx, |
| CONF_SECTION * | cs, | ||
| char const * | name, | ||
| unsigned int | type, | ||
| void * | data, | ||
| char const * | dflt, | ||
| fr_token_t | dflt_quote | ||
| ) |
Parses a CONF_PAIR into a C data type, with a default value.
Takes fields from a conf_parser_t struct and uses them to parse the string value of a CONF_PAIR into a C data type matching the type argument.
The format of the types are the same as fr_value_box_t types.
fr_type_t to data type mappings
| fr_type_t | Data type | Dynamically allocated |
|---|---|---|
| FR_TYPE_BOOL | bool | No |
| FR_TYPE_UINT32 | uint32_t | No |
| FR_TYPE_UINT16 | uint16_t | No |
| FR_TYPE_UINT64 | uint64_t | No |
| FR_TYPE_INT32 | int32_t | No |
| FR_TYPE_STRING | char const * | Yes |
| FR_TYPE_IPV4_ADDR | fr_ipaddr_t | No |
| FR_TYPE_IPV4_PREFIX | fr_ipaddr_t | No |
| FR_TYPE_IPV6_ADDR | fr_ipaddr_t | No |
| FR_TYPE_IPV6_PREFIX | fr_ipaddr_t | No |
| FR_TYPE_COMBO_IP_ADDR | fr_ipaddr_t | No |
| FR_TYPE_COMBO_IP_PREFIX | fr_ipaddr_t | No |
| FR_TYPE_TIME_DELTA | fr_time_delta_t | No |
| [in] | ctx | To allocate arrays and values in. |
| [in] | cs | to search for matching CONF_PAIR in. |
| [in] | name | of CONF_PAIR to search for. |
| [in] | type | Data type to parse CONF_PAIR value as. Should be one of the following data types, and one or more of the following flag types or'd together: |
data FR_TYPE_BOOL - A truth value. data FR_TYPE_UINT32 - 32 Bit unsigned integer. data FR_TYPE_UINT16 - 16 Bit unsigned integer. data FR_TYPE_UINT64 - 64 Bit unsigned integer. data FR_TYPE_INT32 - 32 Bit signed integer. data FR_TYPE_STRING - String of printable characters. data FR_TYPE_IPV4_ADDR - 32 Bit IPv4 Address. (IPv4 address with prefix 32).data FR_TYPE_IPV4_PREFIX - IPv4 Prefix. (IPv4 address with variable prefix).data FR_TYPE_IPV6_ADDR - 128 Bit IPv6 Address. (IPv6 address with prefix 128).data FR_TYPE_IPV6_PREFIX - IPv6 Prefix. (IPv6 address with variable prefix).data FR_TYPE_COMBO_IP_ADDR - IPv4 or IPv6 address depending on length. (IPv4/IPv6 address with prefix 32/128).data FR_TYPE_COMBO_IP_PREFIX - IPv4 or IPv6 address prefix depending on length. (IPv4/IPv6 address with variable prefix).data FR_TYPE_TIME_DELTA - A period of time measured in nanoseconds. flag CONF_FLAG_TMPL - CONF_PAIR should be parsed as a template. Feeds the value into tmpl_afrom_substr. Value can be obtained when processing requests, with tmpl_expand or tmpl_aexpand.flag #FR_TYPE_DEPRECATED -flag CONF_FLAG_REQUIRED - Error out if no matching CONF_PAIR is found, and no dflt value is set. flag CONF_FLAG_ATTRIBUTE - Value must resolve to attribute in dict (deprecated, use CONF_FLAG_TMPL). flag CONF_FLAG_SECRET - Only print value if debug level >= 3. flag CONF_FLAG_FILE_READABLE - File matching value must exist, and must be readable. flag CONF_FLAG_FILE_WRITABLE - File matching value must exist, and must be writable. flag CONF_FLAG_NOT_EMPTY - CONF_PAIR is required to have a non zero length value. flag CONF_FLAG_MULTI - CONF_PAIR can have multiple copies. flag CONF_FLAG_IS_SET - Write whether this config item was left as the default to is_set_offset or is_set_ptr. | [out] | data | Pointer to a global variable, or pointer to a field in the struct being populated with values. |
| [in] | dflt | value to use, if no CONF_PAIR is found. |
| [in] | dflt_quote | around the dflt value. |
Definition at line 771 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Parses a CONF_PAIR into a C data type, with a default value.
| [in] | ctx | To allocate arrays and values in. |
| [out] | out | Where to write the result. Must not be NULL unless rule->runc is provided. |
| [in] | base | address of the structure out points into. May be NULL in the case of manual parsing. |
| [in] | cs | to search for matching CONF_PAIR in. |
| [in] | rule | to parse CONF_PAIR with. |
Definition at line 511 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int cf_pair_parse_value | ( | TALLOC_CTX * | ctx, |
| void * | out, | ||
| UNUSED void * | base, | ||
| CONF_ITEM * | ci, | ||
| conf_parser_t const * | rule | ||
| ) |
Parses a CONF_PAIR into a C data type.
Return the value of a CONF_PAIR.
| [in] | ctx | to allocate any dynamic buffers in. |
| [out] | out | Where to write the parsed value. |
| [in] | base | address of the structure out points into. May be NULL in the case of manual parsing. |
| [in] | ci | to parse. |
| [in] | rule | to parse to. May contain flags. |
Definition at line 214 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int cf_pair_to_value_box | ( | TALLOC_CTX * | ctx, |
| fr_value_box_t * | out, | ||
| CONF_PAIR * | cp, | ||
| conf_parser_t const * | rule | ||
| ) |
Parses a CONF_PAIR into a boxed value.
Return the value of a CONF_PAIR.
| [in] | ctx | to allocate any dynamic buffers in. |
| [out] | out | Where to write the parsed value. |
| [in] | cp | to parse. |
| [in] | rule | to parse to. May contain flags. |
Definition at line 129 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 423 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int cf_parse_gid | ( | TALLOC_CTX * | ctx, |
| void * | out, | ||
| UNUSED void * | parent, | ||
| CONF_ITEM * | ci, | ||
| UNUSED conf_parser_t const * | rule | ||
| ) |
Generic function for resolving GID strings to uid_t values.
Type should be FR_TYPE_VOID, struct field should be a gid_t.
Definition at line 1700 of file cf_parse.c.
Here is the call graph for this function:| int cf_parse_permissions | ( | UNUSED TALLOC_CTX * | ctx, |
| void * | out, | ||
| UNUSED void * | parent, | ||
| CONF_ITEM * | ci, | ||
| UNUSED conf_parser_t const * | rule | ||
| ) |
Generic function for resolving permissions to a mode-t.
Type should be FR_TYPE_VOID, struct field should be a gid_t.
Definition at line 1715 of file cf_parse.c.
Here is the call graph for this function:
|
static |
Definition at line 1237 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int cf_parse_uid | ( | TALLOC_CTX * | ctx, |
| void * | out, | ||
| UNUSED void * | parent, | ||
| CONF_ITEM * | ci, | ||
| UNUSED conf_parser_t const * | rule | ||
| ) |
Generic function for resolving UID strings to uid_t values.
Type should be FR_TYPE_VOID, struct field should be a uid_t.
Definition at line 1685 of file cf_parse.c.
Here is the call graph for this function:| int cf_section_parse | ( | TALLOC_CTX * | ctx, |
| void * | base, | ||
| CONF_SECTION * | cs | ||
| ) |
Parse a configuration section into user-supplied variables.
| [in] | ctx | to allocate any strings, or additional structures in. Usually the same as base, unless base is a nested struct. |
| [out] | base | pointer to a struct to fill with data. |
| [in] | cs | to parse. |
Definition at line 1195 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Pre-allocate a config section structure to allow defaults to be set.
| cs | The parent subsection. |
| base | pointer or variable. |
| rule | that may have defaults in this config section. |
Definition at line 793 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int cf_section_parse_pass2 | ( | void * | base, |
| CONF_SECTION * | cs | ||
| ) |
Fixup xlat expansions and attributes.
| [out] | base | start of structure to write tmpl_t s to. |
| [in] | cs | CONF_SECTION to fixup. |
Definition at line 1315 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 1074 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 911 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Parse a subsection.
| [in] | ctx | to allocate any additional structures under. |
| [out] | out | pointer to a struct/pointer to fill with data. |
| [in] | base | address of the structure out points into. May be NULL in the case of manual parsing. |
| [in] | cs | to parse. |
| [in] | rule | to parse the subcs with. |
Definition at line 955 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int cf_table_parse_int | ( | UNUSED TALLOC_CTX * | ctx, |
| void * | out, | ||
| UNUSED void * | parent, | ||
| CONF_ITEM * | ci, | ||
| conf_parser_t const * | rule | ||
| ) |
Generic function for parsing conf pair values as int.
Definition at line 1633 of file cf_parse.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int cf_table_parse_int32 | ( | UNUSED TALLOC_CTX * | ctx, |
| void * | out, | ||
| UNUSED void * | parent, | ||
| CONF_ITEM * | ci, | ||
| conf_parser_t const * | rule | ||
| ) |
Generic function for parsing conf pair values as int32_t (FR_TYPE_INT32)
Definition at line 1649 of file cf_parse.c.
Here is the call graph for this function:| int cf_table_parse_uint32 | ( | UNUSED TALLOC_CTX * | ctx, |
| void * | out, | ||
| UNUSED void * | parent, | ||
| CONF_ITEM * | ci, | ||
| conf_parser_t const * | rule | ||
| ) |
Generic function for parsing conf pair values as int32_t (FR_TYPE_UINT32)
Definition at line 1665 of file cf_parse.c.
Here is the call graph for this function:
|
static |
Definition at line 46 of file cf_parse.c.
|
static |
Definition at line 47 of file cf_parse.c.
1.9.8