The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Functions | Variables
main_config.c File Reference

Handle the the main server's (radiusd) configuration. More...

#include <freeradius-devel/server/cf_file.h>
#include <freeradius-devel/server/client.h>
#include <freeradius-devel/server/dependency.h>
#include <freeradius-devel/server/main_config.h>
#include <freeradius-devel/server/map_proc.h>
#include <freeradius-devel/server/modpriv.h>
#include <freeradius-devel/server/util.h>
#include <freeradius-devel/server/virtual_servers.h>
#include <freeradius-devel/util/conf.h>
#include <freeradius-devel/util/file.h>
#include <freeradius-devel/util/hw.h>
#include <freeradius-devel/util/perm.h>
#include <freeradius-devel/util/sem.h>
#include <freeradius-devel/util/pair_legacy.h>
#include <freeradius-devel/unlang/xlat_func.h>
+ Include dependency graph for main_config.c:

Go to the source code of this file.

Functions

static int _dlhandle_free (void **dl_handle)
 
static int hostname_lookups_parse (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 
void hup_logfile (main_config_t *config)
 
static int lib_dir_on_read (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 
static int lib_dir_on_read (UNUSED TALLOC_CTX *ctx, UNUSED void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
 
main_config_tmain_config_alloc (TALLOC_CTX *ctx)
 Allocate a main_config_t struct, setting defaults.
 
void main_config_dict_dir_set (main_config_t *config, char const *name)
 Set the global dictionary directory.
 
int main_config_exclusive_proc (main_config_t *config)
 Check to see if we're the only process using this configuration file (or PID file if specified)
 
int main_config_exclusive_proc_child (UNUSED main_config_t const *config)
 Increment the semaphore in the child process so that it's not released when the parent exits.
 
void main_config_exclusive_proc_done (UNUSED main_config_t const *config)
 Clean up the semaphore when the main config is freed.
 
int main_config_free (main_config_t **config)
 
void main_config_hup (main_config_t *config)
 
int main_config_init (main_config_t *config)
 
bool main_config_migrate_option_get (char const *name)
 
void main_config_name_set_default (main_config_t *config, char const *name, bool overwrite_config)
 Set the server name.
 
int main_config_parse_option (char const *value)
 
void main_config_raddb_dir_set (main_config_t *config, char const *name)
 Set the global radius config directory.
 
static int max_request_time_parse (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 
static int name_parse (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 Configured server name takes precedence over default values.
 
static int num_networks_parse (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 
static uint32_t num_workers_auto (main_config_t *conf, CONF_ITEM *parent)
 
static int num_workers_dflt (CONF_PAIR **out, void *parent, CONF_SECTION *cs, fr_token_t quote, conf_parser_t const *rule)
 
static int num_workers_parse (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 
static int reverse_lookups_parse (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 
static int talloc_pool_size_parse (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 
static xlat_action_t xlat_config (TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in)
 xlat to get config values
 
static int xlat_config_escape (UNUSED request_t *request, fr_value_box_t *vb, UNUSED void *uctx)
 

Variables

static fr_table_num_ordered_t config_arg_table []
 
static size_t config_arg_table_len = NUM_ELEMENTS(config_arg_table)
 
fr_log_t debug_log = { .fd = -1, .dst = L_DST_NULL }
 
static const conf_parser_t initial_log_config []
 
static const conf_parser_t initial_server_config []
 
static const conf_parser_t interpret_config []
 
static const conf_parser_t lib_dir_on_read_config []
 
static const conf_parser_t log_config []
 
main_config_t const * main_config
 Main server configuration.
 
static const conf_parser_t migrate_config []
 
static const conf_parser_t request_config []
 
static const conf_parser_t request_reuse_config []
 
static const conf_parser_t resources []
 
static const conf_parser_t security_config []
 
static const conf_parser_t server_config []
 
static const conf_parser_t switch_users_config []
 
static const conf_parser_t thread_config []
 
static xlat_arg_parser_t const xlat_config_args []
 

Detailed Description

Handle the the main server's (radiusd) configuration.

Id
62becaa5f0ec0cc740d3a21fd455609fe1068b93

Definition in file main_config.c.

Function Documentation

◆ _dlhandle_free()

static int _dlhandle_free ( void **  dl_handle)
static

Definition at line 996 of file main_config.c.

+ Here is the caller graph for this function:

◆ hostname_lookups_parse()

static int hostname_lookups_parse ( TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM ci,
conf_parser_t const *  rule 
)
static

Definition at line 317 of file main_config.c.

+ Here is the call graph for this function:

◆ hup_logfile()

void hup_logfile ( main_config_t config)

Definition at line 1396 of file main_config.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lib_dir_on_read() [1/2]

static int lib_dir_on_read ( TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM ci,
conf_parser_t const *  rule 
)
static

◆ lib_dir_on_read() [2/2]

static int lib_dir_on_read ( UNUSED TALLOC_CTX *  ctx,
UNUSED void *  out,
UNUSED void *  parent,
CONF_ITEM ci,
UNUSED conf_parser_t const *  rule 
)
static

Definition at line 365 of file main_config.c.

+ Here is the call graph for this function:

◆ main_config_alloc()

main_config_t * main_config_alloc ( TALLOC_CTX *  ctx)

Allocate a main_config_t struct, setting defaults.

Definition at line 974 of file main_config.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main_config_dict_dir_set()

void main_config_dict_dir_set ( main_config_t config,
char const *  name 
)

Set the global dictionary directory.

Parameters
[in]configto alter.
[in]nameto set as dict dir root e.g. /usr/local/share/freeradius.

Definition at line 962 of file main_config.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main_config_exclusive_proc()

int main_config_exclusive_proc ( main_config_t config)

Check to see if we're the only process using this configuration file (or PID file if specified)

Parameters
[in]configspecifying the path to the main config file.
Returns
  • 1 if another process is running with this config file
  • 0 if no other process is running with this config file.
  • -1 on error.

Definition at line 887 of file main_config.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main_config_exclusive_proc_child()

int main_config_exclusive_proc_child ( UNUSED main_config_t const *  config)

Increment the semaphore in the child process so that it's not released when the parent exits.

Parameters
[in]configspecifying the path to the main config file.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 866 of file main_config.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main_config_exclusive_proc_done()

void main_config_exclusive_proc_done ( UNUSED main_config_t const *  config)

Clean up the semaphore when the main config is freed.

This helps with permissions issues if the user is switching between running the process under something like systemd and running it under debug mode.

Definition at line 848 of file main_config.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main_config_free()

int main_config_free ( main_config_t **  config)

Definition at line 1372 of file main_config.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main_config_hup()

void main_config_hup ( main_config_t config)

Definition at line 1418 of file main_config.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main_config_init()

int main_config_init ( main_config_t config)

Definition at line 1007 of file main_config.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main_config_migrate_option_get()

bool main_config_migrate_option_get ( char const *  name)

Definition at line 1494 of file main_config.c.

+ Here is the caller graph for this function:

◆ main_config_name_set_default()

void main_config_name_set_default ( main_config_t config,
char const *  name,
bool  overwrite_config 
)

Set the server name.

Note
Will only add pair if one does not already exist
Parameters
[in]configto alter.
[in]nameto set e.g. "radiusd".
[in]overwrite_configreplace any CONF_PAIRs with this value.

Definition at line 814 of file main_config.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main_config_parse_option()

int main_config_parse_option ( char const *  value)

Definition at line 1459 of file main_config.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main_config_raddb_dir_set()

void main_config_raddb_dir_set ( main_config_t config,
char const *  name 
)

Set the global radius config directory.

Parameters
[in]configto alter.
[in]nameto set as dir root e.g. /usr/local/etc/raddb.

Definition at line 833 of file main_config.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ max_request_time_parse()

static int max_request_time_parse ( TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM ci,
conf_parser_t const *  rule 
)
static

Definition at line 347 of file main_config.c.

+ Here is the call graph for this function:

◆ name_parse()

static int name_parse ( TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM ci,
conf_parser_t const *  rule 
)
static

Configured server name takes precedence over default values.

Definition at line 396 of file main_config.c.

+ Here is the call graph for this function:

◆ num_networks_parse()

static int num_networks_parse ( TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM ci,
conf_parser_t const *  rule 
)
static

Definition at line 410 of file main_config.c.

+ Here is the call graph for this function:

◆ num_workers_auto()

static uint32_t num_workers_auto ( main_config_t conf,
CONF_ITEM parent 
)
inlinestatic

Definition at line 428 of file main_config.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ num_workers_dflt()

static int num_workers_dflt ( CONF_PAIR **  out,
void *  parent,
CONF_SECTION cs,
fr_token_t  quote,
conf_parser_t const *  rule 
)
static

Definition at line 480 of file main_config.c.

+ Here is the call graph for this function:

◆ num_workers_parse()

static int num_workers_parse ( TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM ci,
conf_parser_t const *  rule 
)
static

Definition at line 456 of file main_config.c.

+ Here is the call graph for this function:

◆ reverse_lookups_parse()

static int reverse_lookups_parse ( TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM ci,
conf_parser_t const *  rule 
)
static

Definition at line 305 of file main_config.c.

+ Here is the call graph for this function:

◆ talloc_pool_size_parse()

static int talloc_pool_size_parse ( TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM ci,
conf_parser_t const *  rule 
)
static

Definition at line 329 of file main_config.c.

+ Here is the call graph for this function:

◆ xlat_config_escape()

static int xlat_config_escape ( UNUSED request_t request,
fr_value_box_t vb,
UNUSED void *  uctx 
)
static

Definition at line 500 of file main_config.c.

+ Here is the call graph for this function:

Variable Documentation

◆ config_arg_table

fr_table_num_ordered_t config_arg_table[]
static
Initial value:
= {
{ L("rewrite_update"), offsetof(main_config_t, rewrite_update) },
{ L("forbid_update"), offsetof(main_config_t, forbid_update) },
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition build.h:209
Main server configuration.
Definition main_config.h:51

Definition at line 1446 of file main_config.c.

◆ config_arg_table_len

size_t config_arg_table_len = NUM_ELEMENTS(config_arg_table)
static

Definition at line 1450 of file main_config.c.

◆ debug_log

fr_log_t debug_log = { .fd = -1, .dst = L_DST_NULL }

Definition at line 62 of file main_config.c.

◆ initial_log_config

const conf_parser_t initial_log_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("destination", main_config_t, log_dest), .dflt = "file" },
{ FR_CONF_OFFSET("syslog_facility", main_config_t, syslog_facility), .dflt = "daemon",
}
},
{ FR_CONF_OFFSET("local_state_dir", main_config_t, local_state_dir), .dflt = "${prefix}/var"},
{ FR_CONF_OFFSET("logdir", main_config_t, log_dir), .dflt = "${local_state_dir}/log"},
{ FR_CONF_OFFSET("file", main_config_t, log_file), .dflt = "${logdir}/radius.log" },
{ FR_CONF_OFFSET("suppress_secrets", main_config_t, suppress_secrets), .dflt = "no" },
}
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 cf_parse.c:1592
#define CONF_PARSER_TERMINATOR
Definition cf_parse.h:658
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition cf_parse.h:284
size_t syslog_facility_table_len
Definition log.c:143
fr_table_num_sorted_t const syslog_facility_table[]
Syslog facility table.
Definition log.c:66

Definition at line 94 of file main_config.c.

◆ initial_server_config

const conf_parser_t initial_server_config[]
static
Initial value:
= {
{ FR_CONF_POINTER("log", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) initial_log_config },
}
#define FR_CONF_POINTER(_name, _type, _flags, _res_p)
conf_parser_t which parses a single CONF_PAIR producing a single global result
Definition cf_parse.h:339
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition cf_parse.h:428
static const conf_parser_t initial_log_config[]
Definition main_config.c:94

Definition at line 113 of file main_config.c.

◆ interpret_config

const conf_parser_t interpret_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET_FLAGS("countup_instructions", CONF_FLAG_HIDDEN, main_config_t, ins_countup) },
{ FR_CONF_OFFSET_FLAGS("max_instructions", CONF_FLAG_HIDDEN, main_config_t, ins_max) },
}
#define FR_CONF_OFFSET_FLAGS(_name, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition cf_parse.h:272
@ CONF_FLAG_HIDDEN
Used by scripts to omit items from the generated documentation.
Definition cf_parse.h:457

Definition at line 189 of file main_config.c.

◆ lib_dir_on_read_config

const conf_parser_t lib_dir_on_read_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("prefix", main_config_t, prefix), .dflt = "/usr/local" },
{ FR_CONF_OFFSET("libdir", main_config_t, lib_dir), .dflt = "${prefix}/lib",
.on_read = lib_dir_on_read },
}
#define FR_CONF_OFFSET_IS_SET(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct,...
Definition cf_parse.h:298
static bool log_timestamp
Definition log.c:1092
bool log_dates_utc
Definition log.c:290
static int lib_dir_on_read(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
@ FR_TYPE_BOOL
A truth value.

Definition at line 122 of file main_config.c.

◆ log_config

const conf_parser_t log_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("colourise", main_config_t, do_colourise) },
{ FR_CONF_OFFSET("line_number", main_config_t, log_line_number) },
}

Definition at line 140 of file main_config.c.

◆ main_config

main_config_t const* main_config

Main server configuration.

Global configuration singleton.

Definition at line 58 of file main_config.c.

◆ migrate_config

const conf_parser_t migrate_config[]
static
Initial value:
= {
{ 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) },
}

Definition at line 178 of file main_config.c.

◆ request_config

const conf_parser_t request_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("max", main_config_t, worker.max_requests), .dflt = "0" },
{ FR_CONF_OFFSET("timeout", main_config_t, worker.max_request_time), .dflt = STRINGIFY(MAX_REQUEST_TIME), .func = max_request_time_parse },
{ FR_CONF_OFFSET_TYPE_FLAGS("talloc_pool_size", FR_TYPE_SIZE, CONF_FLAG_HIDDEN, main_config_t, worker.reuse.child_pool_size), .func = talloc_pool_size_parse },
}
#define STRINGIFY(x)
Definition build.h:197
#define FR_CONF_OFFSET_SUBSECTION(_name, _flags, _struct, _field, _subcs)
conf_parser_t which populates a sub-struct using a CONF_SECTION
Definition cf_parse.h:313
#define FR_CONF_OFFSET_TYPE_FLAGS(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition cf_parse.h:241
static int max_request_time_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
static const conf_parser_t request_reuse_config[]
static int talloc_pool_size_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
#define MAX_REQUEST_TIME
Default maximum request time.
Definition main_config.h:35
@ FR_TYPE_SIZE
Unsigned integer capable of representing any memory address on the local system.

Definition at line 201 of file main_config.c.

◆ request_reuse_config

const conf_parser_t request_reuse_config[]
static
Initial value:
= {
}
#define FR_SLAB_CONFIG_CONF_PARSER
conf_parser_t entries to populate user configurable slab values
Definition slab.h:35

Definition at line 196 of file main_config.c.

◆ resources

const conf_parser_t resources[]
static
Initial value:
= {
{ FR_CONF_OFFSET_FLAGS("talloc_memory_report", CONF_FLAG_HIDDEN, main_config_t, talloc_memory_report) },
}

Definition at line 149 of file main_config.c.

◆ security_config

const conf_parser_t security_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("allow_core_dumps", main_config_t, allow_core_dumps), .dflt = "no" },
}

Definition at line 265 of file main_config.c.

◆ server_config

const conf_parser_t server_config[]
static

Definition at line 209 of file main_config.c.

◆ switch_users_config

const conf_parser_t switch_users_config[]
static
Initial value:
= {
{ FR_CONF_POINTER("security", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) security_config },
{ FR_CONF_OFFSET("prefix", main_config_t, prefix), .dflt = "/usr/local" },
{ FR_CONF_OFFSET("local_state_dir", main_config_t, local_state_dir), .dflt = "${prefix}/var"},
{ FR_CONF_OFFSET("run_dir", main_config_t, run_dir), .dflt = "${local_state_dir}/run/${name}"},
{ FR_CONF_DEPRECATED("chroot", main_config_t, NULL) },
{ FR_CONF_DEPRECATED("allow_core_dumps", main_config_t, NULL) },
}
cf_parse_t func
Override default parsing behaviour for the specified type with a custom parsing function.
Definition cf_parse.h:612
#define FR_CONF_DEPRECATED(_name, _struct, _field)
conf_parser_t entry which raises an error if a matching CONF_PAIR is found
Definition cf_parse.h:414
static const conf_parser_t security_config[]
static int name_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Configured server name takes precedence over default values.
static char const * name

Definition at line 283 of file main_config.c.

◆ thread_config

const conf_parser_t thread_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("num_networks", main_config_t, max_networks), .dflt = STRINGIFY(1),
.func = num_networks_parse },
{ FR_CONF_OFFSET("num_workers", main_config_t, max_workers), .dflt = STRINGIFY(0),
.func = num_workers_parse, .dflt_func = num_workers_dflt },
}
static int num_workers_dflt(CONF_PAIR **out, void *parent, CONF_SECTION *cs, fr_token_t quote, conf_parser_t const *rule)
static int num_networks_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
static int num_workers_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
@ FR_TYPE_TIME_DELTA
A period of time measured in nanoseconds.

Definition at line 159 of file main_config.c.

◆ xlat_config_args

xlat_arg_parser_t const xlat_config_args[]
static
Initial value:
= {
{ .required = true, .concat = true, .type = FR_TYPE_STRING, .always_escape = true, .func = xlat_config_escape },
}
static int xlat_config_escape(UNUSED request_t *request, fr_value_box_t *vb, UNUSED void *uctx)
@ FR_TYPE_STRING
String of printable characters.
#define XLAT_ARG_PARSER_TERMINATOR
Definition xlat.h:169

Definition at line 554 of file main_config.c.