{ "valuepair_attribute", FR_CONF_OFFSET(PW_TYPE_STRING, ldap_instance_t, valuepair_attr), NULL }, #ifdef WITH_EDIR /* support for eDirectory Universal Password */ { "edir", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, ldap_instance_t, edir), NULL }, /* NULL defaults to "no" */ /* * Attempt to bind with the cleartext password we got from eDirectory * Universal password for additional authorization checks. */ { "edir_autz", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, ldap_instance_t, edir_autz), NULL }, /* NULL defaults to "no" */ #endif { "read_clients", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, ldap_instance_t, do_clients), NULL }, /* NULL defaults to "no" */ { "user", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) user_config }, { "group", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) group_config }, { "client", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) client_config }, { "profile", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) profile_config }, { "options", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) option_config }, { "tls", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) tls_config }, {NULL, -1, 0, NULL, NULL} }; /** Expand an LDAP URL into a query, and return a string result from that query.
static const CONF_PARSER bootstrap_security_config[] = { #ifdef HAVE_SETUID { FR_CONF_POINTER("user", PW_TYPE_STRING, &uid_name) }, { FR_CONF_POINTER("group", PW_TYPE_STRING, &gid_name) }, #endif { FR_CONF_POINTER("chroot", PW_TYPE_STRING, &chroot_dir) }, { FR_CONF_POINTER("allow_core_dumps", PW_TYPE_BOOLEAN, &allow_core_dumps), .dflt = "no" }, CONF_PARSER_TERMINATOR };
CONF_PARSER_TERMINATOR }; static CONF_PARSER module_config[] = { { "redis-instance-name", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_DEPRECATED, rlm_rediswho_t, redis_instance_name), NULL }, { "redis_module_instance", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_rediswho_t, redis_instance_name), "redis" }, { "trim-count", FR_CONF_OFFSET(PW_TYPE_SIGNED | PW_TYPE_DEPRECATED, rlm_rediswho_t, trim_count), NULL }, { "trim_count", FR_CONF_OFFSET(PW_TYPE_SIGNED, rlm_rediswho_t, trim_count), "-1" }, /* * These all smash the same variables, because we don't care about them right now. * In 3.1, we should have a way of saying "parse a set of sub-sections according to a template" */ { "Start", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), section_config }, { "Interim-Update", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), section_config }, { "Stop", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), section_config }, CONF_PARSER_TERMINATOR }; /* * Query the database executing a command with no result rows */ static int rediswho_command(char const *fmt, REDISSOCK **dissocket_p, rlm_rediswho_t *inst, REQUEST *request) { REDISSOCK *dissocket; int result = 0;
return fork(); } #ifdef HAVE_PTHREAD_H pid_t rad_waitpid(pid_t pid, int *status) { return waitpid(pid, status, 0); } #endif struct radutmp_config_t { char const *radutmp_fn; } radutmpconfig; static const CONF_PARSER module_config[] = { { "filename", FR_CONF_POINTER(PW_TYPE_FILE_INPUT, &radutmpconfig.radutmp_fn), RADUTMP }, { NULL, -1, 0, NULL, NULL } }; /* * Get fullname of a user. */ static char *fullname(char *username) { #ifdef HAVE_PWD_Hx struct passwd *pwd; char *s; if ((pwd = getpwnam(username)) != NULL) { if ((s = strchr(pwd->pw_gecos, ',')) != NULL) *s = 0; return pwd->pw_gecos;
#endif #ifdef WITH_TCP static CONF_PARSER limit_config[] = { { "max_connections", FR_CONF_OFFSET(PW_TYPE_INTEGER, RADCLIENT, limit.max_connections), "16" }, { "lifetime", FR_CONF_OFFSET(PW_TYPE_INTEGER, RADCLIENT, limit.lifetime), "0" }, { "idle_timeout", FR_CONF_OFFSET(PW_TYPE_INTEGER, RADCLIENT, limit.idle_timeout), "30" }, { NULL, -1, 0, NULL, NULL } /* end the list */ }; #endif static const CONF_PARSER client_config[] = { { "ipaddr", FR_CONF_POINTER(PW_TYPE_COMBO_IP_PREFIX, &cl_ipaddr), NULL }, { "ipv4addr", FR_CONF_POINTER(PW_TYPE_IPV4_PREFIX, &cl_ipaddr), NULL }, { "ipv6addr", FR_CONF_POINTER(PW_TYPE_IPV6_PREFIX, &cl_ipaddr), NULL }, { "src_ipaddr", FR_CONF_POINTER(PW_TYPE_STRING, &cl_srcipaddr), NULL }, { "require_message_authenticator", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, RADCLIENT, message_authenticator), "no" }, { "secret", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_SECRET, RADCLIENT, secret), NULL }, { "shortname", FR_CONF_OFFSET(PW_TYPE_STRING, RADCLIENT, shortname), NULL }, { "nas_type", FR_CONF_OFFSET(PW_TYPE_STRING, RADCLIENT, nas_type), NULL }, { "login", FR_CONF_OFFSET(PW_TYPE_STRING, RADCLIENT, login), NULL }, { "password", FR_CONF_OFFSET(PW_TYPE_STRING, RADCLIENT, password), NULL }, { "virtual_server", FR_CONF_OFFSET(PW_TYPE_STRING, RADCLIENT, server), NULL },
{ "body", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_rest_section_t, body_str), "none" }, { "data", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_rest_section_t, data), NULL }, { "force_to", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_rest_section_t, force_to_str), NULL }, /* User authentication */ { "auth", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_rest_section_t, auth_str), "none" }, { "username", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_rest_section_t, username), NULL }, { "password", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_rest_section_t, password), NULL }, { "require_auth", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, rlm_rest_section_t, require_auth), "no" }, /* Transfer configuration */ { "timeout", FR_CONF_OFFSET(PW_TYPE_INTEGER, rlm_rest_section_t, timeout), "4" }, { "chunk", FR_CONF_OFFSET(PW_TYPE_INTEGER, rlm_rest_section_t, chunk), "0" }, /* TLS Parameters */ { "tls", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) tls_config }, { NULL, -1, 0, NULL, NULL } }; static const CONF_PARSER module_config[] = { { "connect_uri", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_rest_t, connect_uri), NULL }, { NULL, -1, 0, NULL, NULL } }; static int rlm_rest_perform(rlm_rest_t *instance, rlm_rest_section_t *section, void *handle, REQUEST *request, char const *username, char const *password) { ssize_t uri_len; char *uri = NULL;
static char const *localstatedir = NULL; static char const *prefix = NULL; static char const *my_name = NULL; static char const *sbindir = NULL; static char const *run_dir = NULL; static char const *syslog_facility = NULL; static bool do_colourise = false; static char const *radius_dir = NULL; //!< Path to raddb directory /* * Security configuration for the server. */ static const CONF_PARSER security_config[] = { { "max_attributes", FR_CONF_POINTER(PW_TYPE_INTEGER, &fr_max_attributes), STRINGIFY(0) }, { "reject_delay", FR_CONF_POINTER(PW_TYPE_INTEGER, &main_config.reject_delay), STRINGIFY(0) }, { "status_server", FR_CONF_POINTER(PW_TYPE_BOOLEAN, &main_config.status_server), "no"}, { "allow_vulnerable_openssl", FR_CONF_POINTER(PW_TYPE_STRING, &main_config.allow_vulnerable_openssl), "no"}, { NULL, -1, 0, NULL, NULL } }; /* * Logging configuration for the server. */ static const CONF_PARSER logdest_config[] = { { "destination", FR_CONF_POINTER(PW_TYPE_STRING, &radlog_dest), "files" }, { "syslog_facility", FR_CONF_POINTER(PW_TYPE_STRING, &syslog_facility), STRINGIFY(0) }, { "file", FR_CONF_POINTER(PW_TYPE_STRING, &main_config.log_file), "${logdir}/radius.log" },
{ "on_clear", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT , rlm_sqlippool_t, on_clear), "" }, { "on-commit", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT | PW_TYPE_DEPRECATED, rlm_sqlippool_t, on_commit), NULL }, { "on_commit", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT, rlm_sqlippool_t, on_commit), "COMMIT" }, { "off-begin", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT | PW_TYPE_DEPRECATED, rlm_sqlippool_t, off_begin), NULL }, { "off_begin", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT, rlm_sqlippool_t, off_begin), "START TRANSACTION" }, { "off-clear", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT | PW_TYPE_DEPRECATED, rlm_sqlippool_t, off_clear), NULL }, { "off_clear", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT , rlm_sqlippool_t, off_clear), "" }, { "off-commit", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT | PW_TYPE_DEPRECATED, rlm_sqlippool_t, off_commit), NULL }, { "off_commit", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT, rlm_sqlippool_t, off_commit), "COMMIT" }, { "messages", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) message_config }, CONF_PARSER_TERMINATOR }; /* * Replace %<whatever> in a string. * * %P pool_name * %I param * %J lease_duration * */ static int sqlippool_expand(char * out, int outlen, char const * fmt, rlm_sqlippool_t *data, char * param, int param_len) { char *q;
* be freed. When the configuration file parse re-reads the string, * it free's the old one, and strdup's the new one, placing the pointer * to the strdup'd string into 'config.string'. This gets around * buffer over-flows. */ static const CONF_PARSER module_config[] = { { "destination", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_REQUIRED, linelog_instance_t, log_dst_str), NULL }, { "delimiter", FR_CONF_OFFSET(PW_TYPE_STRING, linelog_instance_t, delimiter), "\n" }, { "format", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_TMPL, linelog_instance_t, log_src), NULL }, { "reference", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_TMPL, linelog_instance_t, log_ref), NULL }, /* * Log destinations */ { "file", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) file_config }, { "syslog", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) syslog_config }, { "unix", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) unix_config }, { "tcp", FR_CONF_OFFSET(PW_TYPE_SUBSECTION, linelog_instance_t, tcp), (void const *) tcp_config }, { "udp", FR_CONF_OFFSET(PW_TYPE_SUBSECTION, linelog_instance_t, udp), (void const *) udp_config }, /* * Deprecated config items */ { "filename", FR_CONF_OFFSET(PW_TYPE_FILE_OUTPUT | PW_TYPE_DEPRECATED, linelog_instance_t, file.name), NULL }, { "permissions", FR_CONF_OFFSET(PW_TYPE_INTEGER | PW_TYPE_DEPRECATED, linelog_instance_t, file.permissions), NULL }, { "group", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_DEPRECATED, linelog_instance_t, file.group_str), NULL }, { "syslog_facility", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_DEPRECATED, linelog_instance_t, syslog.facility), NULL }, { "syslog_severity", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_DEPRECATED, linelog_instance_t, syslog.severity), NULL },
{NULL, -1, 0, NULL, NULL} /* end the list */ }; /** * Module Configuration */ static const CONF_PARSER module_config[] = { { "acct_key", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT, rlm_couchbase_t, acct_key), "radacct_%{%{Acct-Unique-Session-Id}:-%{Acct-Session-Id}}" }, { "doctype", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_couchbase_t, doctype), "radacct" }, { "server", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_REQUIRED, rlm_couchbase_t, server_raw), NULL }, { "bucket", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_REQUIRED, rlm_couchbase_t, bucket), NULL }, { "password", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_couchbase_t, password), NULL }, { "expire", FR_CONF_OFFSET(PW_TYPE_INTEGER, rlm_couchbase_t, expire), 0 }, { "user_key", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT, rlm_couchbase_t, user_key), "raduser_%{md5:%{tolower:%{%{Stripped-User-Name}:-%{User-Name}}}}" }, { "read_clients", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, rlm_couchbase_t, read_clients), NULL }, /* NULL defaults to "no" */ { "client", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) client_config }, {NULL, -1, 0, NULL, NULL} /* end the list */ }; /** Initialize the rlm_couchbase module * * Intialize the module and create the initial Couchbase connection pool. * * @param conf The module configuration. * @param instance The module instance. * @return Returns 0 on success, -1 on error. */ static int mod_instantiate(CONF_SECTION *conf, void *instance) { static bool version_done; rlm_couchbase_t *inst = instance; /* our module instance */
* So we can do pass2 xlat checks on the queries. */ static const CONF_PARSER query_config[] = { { "query", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT | PW_TYPE_MULTI, rlm_sql_config_t, accounting.query), NULL }, {NULL, -1, 0, NULL, NULL} }; /* * For now hard-code the subsections. This isn't perfect, but it * helps the average case. */ static const CONF_PARSER type_config[] = { { "accounting-on", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) query_config }, { "accounting-off", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) query_config }, { "start", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) query_config }, { "interim-update", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) query_config }, { "stop", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) query_config }, {NULL, -1, 0, NULL, NULL} }; static const CONF_PARSER acct_config[] = { { "reference", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT, rlm_sql_config_t, accounting.reference), ".query" }, { "logfile", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_sql_config_t, accounting.logfile), NULL }, { "type", FR_CONF_POINTER(PW_TYPE_SUBSECTION, NULL), (void const *) type_config },
{ FR_CONF_OFFSET("ipaddr", FR_TYPE_COMBO_IP_ADDR, proto_dhcpv4_udp_t, ipaddr) }, { FR_CONF_OFFSET("ipv4addr", FR_TYPE_IPV4_ADDR, proto_dhcpv4_udp_t, ipaddr) }, { FR_CONF_OFFSET("ipv6addr", FR_TYPE_IPV6_ADDR, proto_dhcpv4_udp_t, ipaddr) }, { FR_CONF_OFFSET("src_ipaddr", FR_TYPE_COMBO_IP_ADDR, proto_dhcpv4_udp_t, src_ipaddr) }, { FR_CONF_OFFSET("interface", FR_TYPE_STRING, proto_dhcpv4_udp_t, interface) }, { FR_CONF_OFFSET("port_name", FR_TYPE_STRING, proto_dhcpv4_udp_t, port_name) }, { FR_CONF_OFFSET("port", FR_TYPE_UINT16, proto_dhcpv4_udp_t, port) }, { FR_CONF_OFFSET_IS_SET("recv_buff", FR_TYPE_UINT32, proto_dhcpv4_udp_t, recv_buff) }, { FR_CONF_OFFSET("broadcast", FR_TYPE_BOOL, proto_dhcpv4_udp_t, broadcast) } , { FR_CONF_OFFSET("dynamic_clients", FR_TYPE_BOOL, proto_dhcpv4_udp_t, dynamic_clients) } , { FR_CONF_POINTER("networks", FR_TYPE_SUBSECTION, NULL), .subcs = (void const *) networks_config }, { FR_CONF_OFFSET("max_packet_size", FR_TYPE_UINT32, proto_dhcpv4_udp_t, max_packet_size), .dflt = "4096" } , { FR_CONF_OFFSET("max_attributes", FR_TYPE_UINT32, proto_dhcpv4_udp_t, max_attributes), .dflt = STRINGIFY(DHCPV4_MAX_ATTRIBUTES) } , CONF_PARSER_TERMINATOR }; static fr_dict_t *dict_dhcpv4; extern fr_dict_autoload_t proto_dhcpv4_udp_dict[]; fr_dict_autoload_t proto_dhcpv4_udp_dict[] = { { .out = &dict_dhcpv4, .proto = "dhcpv4" }, { NULL } };
static char const *hs_proto = NULL; #endif #ifdef WITH_TCP static CONF_PARSER limit_config[] = { { FR_CONF_OFFSET("max_connections", PW_TYPE_INTEGER, RADCLIENT, limit.max_connections), .dflt = "16" }, { FR_CONF_OFFSET("lifetime", PW_TYPE_INTEGER, RADCLIENT, limit.lifetime), .dflt = "0" }, { FR_CONF_OFFSET("idle_timeout", PW_TYPE_INTEGER, RADCLIENT, limit.idle_timeout), .dflt = "30" }, CONF_PARSER_TERMINATOR }; #endif static const CONF_PARSER client_config[] = { { FR_CONF_POINTER("ipaddr", PW_TYPE_COMBO_IP_PREFIX, &cl_ipaddr) }, { FR_CONF_POINTER("ipv4addr", PW_TYPE_IPV4_PREFIX, &cl_ipaddr) }, { FR_CONF_POINTER("ipv6addr", PW_TYPE_IPV6_PREFIX, &cl_ipaddr) }, { FR_CONF_POINTER("src_ipaddr", PW_TYPE_STRING, &cl_srcipaddr) }, { FR_CONF_OFFSET("require_message_authenticator", PW_TYPE_BOOLEAN, RADCLIENT, message_authenticator), .dflt = "no" }, { FR_CONF_OFFSET("secret", PW_TYPE_STRING | PW_TYPE_SECRET, RADCLIENT, secret) }, { FR_CONF_OFFSET("shortname", PW_TYPE_STRING, RADCLIENT, shortname) }, { FR_CONF_OFFSET("nas_type", PW_TYPE_STRING, RADCLIENT, nas_type) }, { FR_CONF_OFFSET("login", PW_TYPE_STRING, RADCLIENT, login) }, { FR_CONF_OFFSET("password", PW_TYPE_STRING, RADCLIENT, password) }, { FR_CONF_OFFSET("virtual_server", PW_TYPE_STRING, RADCLIENT, server) },
#include "rlm_sql.h" /* * So we can do pass2 xlat checks on the queries. */ static const CONF_PARSER query_config[] = { { FR_CONF_OFFSET("query", PW_TYPE_STRING | PW_TYPE_XLAT | PW_TYPE_MULTI, rlm_sql_config_t, accounting.query) }, CONF_PARSER_TERMINATOR }; /* * For now hard-code the subsections. This isn't perfect, but it * helps the average case. */ static const CONF_PARSER type_config[] = { { FR_CONF_POINTER("accounting-on", PW_TYPE_SUBSECTION, NULL), .dflt = (void const *) query_config }, { FR_CONF_POINTER("accounting-off", PW_TYPE_SUBSECTION, NULL), .dflt = (void const *) query_config }, { FR_CONF_POINTER("start", PW_TYPE_SUBSECTION, NULL), .dflt = (void const *) query_config }, { FR_CONF_POINTER("interim-update", PW_TYPE_SUBSECTION, NULL), .dflt = (void const *) query_config }, { FR_CONF_POINTER("stop", PW_TYPE_SUBSECTION, NULL), .dflt = (void const *) query_config }, CONF_PARSER_TERMINATOR }; static const CONF_PARSER acct_config[] = { { FR_CONF_OFFSET("reference", PW_TYPE_STRING | PW_TYPE_XLAT, rlm_sql_config_t, accounting.reference), .dflt = ".query" }, { FR_CONF_OFFSET("logfile", PW_TYPE_STRING | PW_TYPE_XLAT, rlm_sql_config_t, accounting.logfile) }, { FR_CONF_POINTER("type", PW_TYPE_SUBSECTION, NULL), .dflt = (void const *) type_config }, CONF_PARSER_TERMINATOR };
static THREAD_POOL thread_pool; static bool pool_initialized = false; #ifndef WITH_GCD static time_t last_cleaned = 0; static void thread_pool_manage(time_t now); #endif #ifndef WITH_GCD /* * A mapping of configuration file names to internal integers */ static const CONF_PARSER thread_config[] = { { "start_servers", FR_CONF_POINTER(PW_TYPE_INTEGER, &thread_pool.start_threads), "5" }, { "max_servers", FR_CONF_POINTER(PW_TYPE_INTEGER, &thread_pool.max_threads), "32" }, { "min_spare_servers", FR_CONF_POINTER(PW_TYPE_INTEGER, &thread_pool.min_spare_threads), "3" }, { "max_spare_servers", FR_CONF_POINTER(PW_TYPE_INTEGER, &thread_pool.max_spare_threads), "10" }, { "max_requests_per_server", FR_CONF_POINTER(PW_TYPE_INTEGER, &thread_pool.max_requests_per_thread), "0" }, { "cleanup_delay", FR_CONF_POINTER(PW_TYPE_INTEGER, &thread_pool.cleanup_delay), "5" }, { "max_queue_size", FR_CONF_POINTER(PW_TYPE_INTEGER, &thread_pool.max_queue_size), "65536" }, #ifdef WITH_STATS #ifdef WITH_ACCOUNTING { "auto_limit_acct", FR_CONF_POINTER(PW_TYPE_BOOLEAN, &thread_pool.auto_limit_acct), NULL }, #endif #endif { NULL, -1, 0, NULL, NULL } }; #endif