The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
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/cf_util.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/module.h>
#include <freeradius-devel/server/util.h>
#include <freeradius-devel/server/virtual_servers.h>
#include <freeradius-devel/unlang/xlat.h>
#include <freeradius-devel/util/conf.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/dict.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/token.h>
#include <freeradius-devel/util/pair_legacy.h>
#include <freeradius-devel/unlang/xlat_func.h>
#include <sys/stat.h>
#include <pwd.h>
#include <grp.h>
#include <unistd.h>
#include <sys/types.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. More...
 
void main_config_dict_dir_set (main_config_t *config, char const *name)
 Set the global dictionary directory. More...
 
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) More...
 
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. More...
 
void main_config_exclusive_proc_done (UNUSED main_config_t const *config)
 Clean up the semaphore when the main config is freed. More...
 
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. More...
 
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. More...
 
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. More...
 
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 More...
 
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. More...
 
static const conf_parser_t migrate_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 []
 
bool tmpl_require_enum_prefix
 
static xlat_arg_parser_t const xlat_config_args []
 

Detailed Description

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

Id
6521203ba7d8d5e9f4676e9d6aa41f769d670704

Definition in file main_config.c.

Function Documentation

◆ _dlhandle_free()

static int _dlhandle_free ( void **  dl_handle)
static

Definition at line 1025 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 1447 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 1003 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 991 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 916 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 895 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 877 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 1423 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 1469 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 1036 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 1546 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 843 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 1511 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 862 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) },
{ L("require_enum_prefix"), offsetof(main_config_t, require_enum_prefix) },
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition: build.h:207
Main server configuration.
Definition: main_config.h:51

Definition at line 1497 of file main_config.c.

◆ config_arg_table_len

size_t config_arg_table_len = NUM_ELEMENTS(config_arg_table)
static

Definition at line 1502 of file main_config.c.

◆ debug_log

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

Definition at line 73 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:1474
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:627
#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:268
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 105 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:310
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition: cf_parse.h:399
static const conf_parser_t initial_log_config[]
Definition: main_config.c:105

Definition at line 124 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:256
@ CONF_FLAG_HIDDEN
Used by scripts to omit items from the generated documentation.
Definition: cf_parse.h:428

Definition at line 204 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:282
static bool log_timestamp
Definition: log.c:1094
bool log_dates_utc
Definition: log.c:289
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: merged_model.c:95

Definition at line 133 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 151 of file main_config.c.

◆ main_config

main_config_t const* main_config

Main server configuration.

Global configuration singleton.

Definition at line 69 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) },
{ FR_CONF_OFFSET_FLAGS("require_enum_prefix", CONF_FLAG_HIDDEN, main_config_t, require_enum_prefix) },
}

Definition at line 192 of file main_config.c.

◆ resources

const conf_parser_t resources[]
static
Initial value:
= {
{ FR_CONF_OFFSET_TYPE_FLAGS("talloc_pool_size", FR_TYPE_SIZE, CONF_FLAG_HIDDEN, main_config_t, talloc_pool_size), .func = talloc_pool_size_parse },
{ FR_CONF_OFFSET_FLAGS("talloc_memory_report", CONF_FLAG_HIDDEN, main_config_t, talloc_memory_report) },
}
#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 talloc_pool_size_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Definition: main_config.c:329
@ FR_TYPE_SIZE
Unsigned integer capable of representing any memory address on the local system.
Definition: merged_model.c:115

Definition at line 160 of file main_config.c.

◆ security_config

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

Definition at line 264 of file main_config.c.

◆ server_config

const conf_parser_t server_config[]
static

Definition at line 211 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("name", main_config_t, name), .func = name_parse },
{ 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) },
}
#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:385
static const conf_parser_t security_config[]
Definition: main_config.c:264
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.
Definition: main_config.c:396
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 },
}
#define STRINGIFY(x)
Definition: build.h:195
static int num_workers_dflt(CONF_PAIR **out, void *parent, CONF_SECTION *cs, fr_token_t quote, conf_parser_t const *rule)
Definition: main_config.c:480
static int num_networks_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Definition: main_config.c:410
static int num_workers_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Definition: main_config.c:456
@ FR_TYPE_TIME_DELTA
A period of time measured in nanoseconds.
Definition: merged_model.c:113

Definition at line 171 of file main_config.c.

◆ tmpl_require_enum_prefix

bool tmpl_require_enum_prefix
extern

Definition at line 49 of file tmpl_tokenize.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)
Definition: main_config.c:500
@ FR_TYPE_STRING
String of printable characters.
Definition: merged_model.c:83
#define XLAT_ARG_PARSER_TERMINATOR
Definition: xlat.h:166

Definition at line 554 of file main_config.c.