const char *name;
int type; /* PW_TYPE_STRING, etc. */
void *data; /* pointer to where to put it */
+ const char *dflt; /* default as it would appear in radiusd.conf */
} CONF_PARSER;
+/* This preprocessor trick will be useful in initializing CONF_PARSER struct */
+#define XStringify(x) #x
+#define Stringify(x) XStringify(x)
+
CONF_SECTION *conf_read(const char *conffile);
CONF_PAIR *cf_pair_alloc(const char *attr, const char *value, int operator);
void cf_pair_add(CONF_SECTION *cs, CONF_PAIR *cp_new);
}
/*
- * Clear out any possible subsections aswell
+ * Clear out any possible subsections as well
*/
for (sub = cs->sub; sub; sub = next_sub) {
next_sub = sub->next;
CONF_PAIR *cp;
uint32_t ipaddr;
char buffer[1024];
+ const char *value;
/*
* Handle the user-supplied variables.
*/
for (i = 0; variables[i].name != NULL; i++) {
+ value = variables[i].dflt;
+
cp = cf_pair_find(cs, variables[i].name);
- if (!cp) {
- continue;
+ if (cp) {
+ value = cp->value;
}
switch (variables[i].type)
/*
* Allow yes/no and on/off
*/
- if ((strcasecmp(cp->value, "yes") == 0) ||
- (strcasecmp(cp->value, "on") == 0)) {
+ if ((strcasecmp(value, "yes") == 0) ||
+ (strcasecmp(value, "on") == 0)) {
*(int *)variables[i].data = 1;
- } else if ((strcasecmp(cp->value, "no") == 0) ||
- (strcasecmp(cp->value, "off") == 0)) {
+ } else if ((strcasecmp(value, "no") == 0) ||
+ (strcasecmp(value, "off") == 0)) {
*(int *)variables[i].data = 0;
} else {
*(int *)variables[i].data = 0;
- log(L_ERR, "Bad value \"%s\" for boolean variable %s", cp->value, cp->attr);
+ log(L_ERR, "Bad value \"%s\" for boolean variable %s", value, variables[i].name);
return -1;
}
DEBUG2("Config: %s.%s = %s",
cs->name1,
variables[i].name,
- cp->value);
+ value);
break;
case PW_TYPE_INTEGER:
- *(int *)variables[i].data = atoi(cp->value);
+ *(int *)variables[i].data = strtol(value, 0, 0);
DEBUG2("Config: %s.%s = %d",
cs->name1,
variables[i].name,
DEBUG2("Config: %s.%s = \"%s\"",
cs->name1,
variables[i].name,
- cp->value);
- *q = strdup(cp->value);
+ value ? value : "(null)");
+ *q = value ? strdup(value) : NULL;
break;
case PW_TYPE_IPADDR:
/*
* Allow '*' as any address
*/
- if (strcmp(cp->value, "*") == 0) {
+ if (strcmp(value, "*") == 0) {
*(uint32_t *) variables[i].data = 0;
break;
}
- ipaddr = ip_getaddr(cp->value);
+ ipaddr = ip_getaddr(value);
if (ipaddr == 0) {
- log(L_ERR, "Can't find IP address for host %s", cp->value);
+ log(L_ERR, "Can't find IP address for host %s", value);
return -1;
}
DEBUG2("Config: %s.%s = %s IP address [%s]",
cs->name1,
variables[i].name,
- cp->value, ip_ntoa(buffer, ipaddr));
+ value, ip_ntoa(buffer, ipaddr));
*(uint32_t *) variables[i].data = ipaddr;
break;
return new_value->value;
}
+/* Why is this both here and in radiusd.c:server_config? --Pac. */
static CONF_PARSER module_config[] = {
- { "lib_dir", PW_TYPE_STRING_PTR, &radlib_dir },
+ { "lib_dir", PW_TYPE_STRING_PTR, &radlib_dir, LIBDIR },
- { NULL, -1, NULL}
+ { NULL, -1, NULL, NULL }
};
/*
* A mapping of configuration file names to internal variables
*/
static CONF_PARSER server_config[] = {
- { "max_request_time", PW_TYPE_INTEGER, &max_request_time },
- { "cleanup_delay", PW_TYPE_INTEGER, &cleanup_delay },
- { "max_requests", PW_TYPE_INTEGER, &max_requests },
- { "port", PW_TYPE_INTEGER, &auth_port },
- { "allow_core_dumps", PW_TYPE_BOOLEAN, &allow_core_dumps },
- { "log_stripped_names", PW_TYPE_BOOLEAN, &log_stripped_names },
- { "log_auth", PW_TYPE_BOOLEAN, &log_auth },
- { "log_auth_pass", PW_TYPE_BOOLEAN, &log_auth_pass },
- { "pidfile", PW_TYPE_STRING_PTR, &pid_file },
- { "log_dir", PW_TYPE_STRING_PTR, &radlog_dir },
- { "lib_dir", PW_TYPE_STRING_PTR, &radlib_dir },
- { "acct_dir", PW_TYPE_STRING_PTR, &radacct_dir },
- { "bind_address", PW_TYPE_IPADDR, &myip },
- { "proxy_requests", PW_TYPE_BOOLEAN, &proxy_requests },
+ { "max_request_time", PW_TYPE_INTEGER,
+ &max_request_time, Stringify(MAX_REQUEST_TIME) },
+ { "cleanup_delay", PW_TYPE_INTEGER,
+ &cleanup_delay, Stringify(CLEANUP_DELAY) },
+ { "max_requests", PW_TYPE_INTEGER,
+ &max_requests, Stringify(MAX_REQUESTS) },
+ { "port", PW_TYPE_INTEGER,
+ &auth_port, Stringify(PW_AUTH_UDP_PORT) },
+ { "allow_core_dumps", PW_TYPE_BOOLEAN, &allow_core_dumps, "no" },
+ { "log_stripped_names", PW_TYPE_BOOLEAN, &log_stripped_names,"no" },
+ { "log_auth", PW_TYPE_BOOLEAN, &log_auth, "no" },
+ { "log_auth_pass", PW_TYPE_BOOLEAN, &log_auth_pass, "no" },
+ { "pidfile", PW_TYPE_STRING_PTR, &pid_file, RADIUS_PID },
+ { "log_dir", PW_TYPE_STRING_PTR, &radlog_dir, RADLOG_DIR },
+ { "lib_dir", PW_TYPE_STRING_PTR, &radlib_dir, LIBDIR },
+ { "acct_dir", PW_TYPE_STRING_PTR, &radacct_dir, RADACCT_DIR },
+ { "bind_address", PW_TYPE_IPADDR, &myip, "*" },
+ { "proxy_requests", PW_TYPE_BOOLEAN, &proxy_requests, "yes" },
#if 0
- { "confdir", PW_TYPE_STRING_PTR, &radius_dir },
+ { "confdir", PW_TYPE_STRING_PTR, &radius_dir, RADIUS_DIR },
#endif
- { NULL, -1, NULL}
+ { NULL, -1, NULL, NULL }
};
/*
* Map the proxy server configuration parameters to variables.
*/
static CONF_PARSER proxy_config[] = {
- { "retry_delay", PW_TYPE_INTEGER, &proxy_retry_delay },
- { "retry_count", PW_TYPE_INTEGER, &proxy_retry_count },
- { "synchonous", PW_TYPE_BOOLEAN, &proxy_synchronous },
+ { "retry_delay", PW_TYPE_INTEGER,
+ &proxy_retry_delay, Stringify(RETRY_DELAY) },
+ { "retry_count", PW_TYPE_INTEGER,
+ &proxy_retry_count, Stringify(RETRY_COUNT) },
+ { "synchronous", PW_TYPE_BOOLEAN, &proxy_synchronous, "yes" },
- { NULL, -1, NULL}
+ { NULL, -1, NULL, NULL }
};
/*
/*
* And parse the server's configuration values.
*/
- cs = cf_section_find("main");
+ cs = cf_section_find(NULL);
if (!cs)
return;
debug_flag = 0;
spawn_flag = TRUE;
- radacct_dir = strdup(RADACCT_DIR);
radius_dir = strdup(RADIUS_DIR);
- radlog_dir = strdup(RADLOG_DIR);
- radlib_dir = strdup(LIBDIR);
- pid_file = strdup(RADIUS_PID);
signal(SIGHUP, sig_hup);
signal(SIGINT, sig_fatal);
* A mapping of configuration file names to internal integers
*/
static const CONF_PARSER thread_config[] = {
- { "start_servers", PW_TYPE_INTEGER, &thread_pool.start_threads},
- { "max_servers", PW_TYPE_INTEGER, &thread_pool.max_threads},
- { "min_spare_servers", PW_TYPE_INTEGER, &thread_pool.min_spare_threads},
- { "max_spare_servers", PW_TYPE_INTEGER, &thread_pool.max_spare_threads},
- { "max_requests_per_server", PW_TYPE_INTEGER, &thread_pool.max_requests_per_thread},
+ { "start_servers", PW_TYPE_INTEGER,
+ &thread_pool.start_threads, "5" },
+ { "max_servers", PW_TYPE_INTEGER,
+ &thread_pool.max_threads, "32" },
+ { "min_spare_servers", PW_TYPE_INTEGER,
+ &thread_pool.min_spare_threads, "3" },
+ { "max_spare_servers", PW_TYPE_INTEGER,
+ &thread_pool.max_spare_threads, "10" },
+ { "max_requests_per_server", PW_TYPE_INTEGER,
+ &thread_pool.max_requests_per_thread, "0"},
- { NULL, -1, NULL}
+ { NULL, -1, NULL, NULL }
};
/*
thread_pool.head = NULL;
thread_pool.tail = NULL;
thread_pool.total_threads = 0;
- thread_pool.start_threads = 5;
- thread_pool.max_threads = 32;
- thread_pool.min_spare_threads = 3;
- thread_pool.max_spare_threads = 10;
- thread_pool.max_requests_per_thread = 0; /* infinity */
pool_cf = cf_section_find("thread");
if (pool_cf) {
} example_config_t;
/*
- * Define the local copy of our example configuration,
- * and initialize it so some values.
+ * Define the local copy of our example configuration.
+ * Initialization will be done by the CONF_PARSER.
*/
-static example_config_t config = {
- FALSE, /* boolean */
- 1, /* integer */
- NULL, /* string */
- 0 /* IP address */
-};
+static example_config_t config;
/*
* A mapping of configuration file names to internal variables.
* buffer over-flows.
*/
static CONF_PARSER module_config[] = {
- { "integer", PW_TYPE_INTEGER, &config.value },
- { "boolean", PW_TYPE_BOOLEAN, &config.boolean },
- { "string", PW_TYPE_STRING_PTR, &config.string },
- { "ipaddr", PW_TYPE_IPADDR, &config.ipaddr },
+ { "integer", PW_TYPE_INTEGER, &config.value, "1" },
+ { "boolean", PW_TYPE_BOOLEAN, &config.boolean, "no" },
+ { "string", PW_TYPE_STRING_PTR, &config.string, NULL },
+ { "ipaddr", PW_TYPE_IPADDR, &config.ipaddr, "*" },
- { NULL, -1, NULL} /* end the list */
+ { NULL, -1, NULL, NULL } /* end the list */
};
/*
static int readers; /* number of threads performing LDAP lookups */
static CONF_PARSER ldap_config[] = {
- { "server", PW_TYPE_STRING_PTR, &ldap_server },
- { "port", PW_TYPE_INTEGER, &ldap_port },
- { "net_timeout", PW_TYPE_INTEGER, &ldap_net_timeout.tv_sec},
- { "timeout", PW_TYPE_INTEGER, &ldap_timeout.tv_sec},
-
- { "identity", PW_TYPE_STRING_PTR, &ldap_login },
- { "password", PW_TYPE_STRING_PTR, &ldap_password },
- { "basedn", PW_TYPE_STRING_PTR, &ldap_basedn },
- { "filter", PW_TYPE_STRING_PTR, &ldap_filter },
- { "access_group", PW_TYPE_STRING_PTR, &ldap_radius_group },
-
- { "cache_size", PW_TYPE_INTEGER, &ldap_cache_size },
- { "cache_ttl", PW_TYPE_INTEGER, &ldap_cache_ttl },
+ { "server", PW_TYPE_STRING_PTR, &ldap_server, NULL },
+ { "port", PW_TYPE_INTEGER, &ldap_port, "389" },
+ { "net_timeout", PW_TYPE_INTEGER, &ldap_net_timeout.tv_sec, "-1" },
+ { "timeout", PW_TYPE_INTEGER, &ldap_timeout.tv_sec, "-1" },
+
+ { "identity", PW_TYPE_STRING_PTR, &ldap_login, NULL },
+ { "password", PW_TYPE_STRING_PTR, &ldap_password, NULL },
+ { "basedn", PW_TYPE_STRING_PTR, &ldap_basedn, NULL },
+ { "filter", PW_TYPE_STRING_PTR, &ldap_filter, NULL },
+ { "access_group", PW_TYPE_STRING_PTR, &ldap_radius_group, NULL },
+
+ { "cache_size", PW_TYPE_INTEGER, &ldap_cache_size, "0" },
+ { "cache_ttl", PW_TYPE_INTEGER, &ldap_cache_ttl, "30" },
- { NULL, -1, NULL}
+ { NULL, -1, NULL, NULL }
};
/* LDAP attribute name that controls remote access */
};
static CONF_PARSER module_config[] = {
- { "sensitiveusername", PW_TYPE_BOOLEAN , &config.sensitiveusername},
- { "deletestalesessions", PW_TYPE_BOOLEAN , &config.deletestalesessions },
- { "sqltrace", PW_TYPE_BOOLEAN , &config.sqltrace },
- { "max_sql_socks", PW_TYPE_INTEGER , &config.max_sql_socks },
- { "server", PW_TYPE_STRING_PTR , &config.sql_server },
- { "login", PW_TYPE_STRING_PTR , &config.sql_login },
- { "password", PW_TYPE_STRING_PTR , &config.sql_password },
- { "db", PW_TYPE_STRING_PTR , &config.sql_db },
- { "authcheck_table", PW_TYPE_STRING_PTR , &config.sql_authcheck_table },
- { "authreply_table", PW_TYPE_STRING_PTR , &config.sql_authreply_table },
- { "groupcheck_table", PW_TYPE_STRING_PTR , &config.sql_groupcheck_table },
- { "groupreply_table", PW_TYPE_STRING_PTR , &config.sql_groupreply_table },
- { "usergroup_table", PW_TYPE_STRING_PTR , &config.sql_usergroup_table },
- { "realmgroup_table", PW_TYPE_STRING_PTR , &config.sql_realmgroup_table },
- { "acct_table", PW_TYPE_STRING_PTR , &config.sql_acct_table },
- { "nas_table", PW_TYPE_STRING_PTR , &config.sql_nas_table },
- { "realm_table", PW_TYPE_STRING_PTR , &config.sql_realm_table },
- { "dict_table", PW_TYPE_STRING_PTR , &config.sql_dict_table },
- { NULL, -1, NULL}
+ { "sensitiveusername", PW_TYPE_BOOLEAN,
+ &config.sensitiveusername, "1" },
+ { "deletestalesessions", PW_TYPE_BOOLEAN,
+ &config.deletestalesessions, "0" },
+ { "sqltrace", PW_TYPE_BOOLEAN,
+ &config.sqltrace, "0" },
+ { "max_sql_socks", PW_TYPE_INTEGER,
+ &config.max_sql_socks, Stringify(MAX_SQL_SOCKS) },
+ { "server", PW_TYPE_STRING_PTR,
+ &config.sql_server, "localhost" },
+ { "login", PW_TYPE_STRING_PTR,
+ &config.sql_login, "" },
+ { "password", PW_TYPE_STRING_PTR,
+ &config.sql_password, "" },
+ { "db", PW_TYPE_STRING_PTR,
+ &config.sql_db, "radius" },
+ { "authcheck_table", PW_TYPE_STRING_PTR,
+ &config.sql_authcheck_table, "radcheck" },
+ { "authreply_table", PW_TYPE_STRING_PTR,
+ &config.sql_authreply_table, "radreply" },
+ { "groupcheck_table", PW_TYPE_STRING_PTR,
+ &config.sql_groupcheck_table, "radgroupcheck" },
+ { "groupreply_table", PW_TYPE_STRING_PTR,
+ &config.sql_groupreply_table, "radgroupreply" },
+ { "usergroup_table", PW_TYPE_STRING_PTR,
+ &config.sql_usergroup_table, "usergroup" },
+ { "realmgroup_table", PW_TYPE_STRING_PTR,
+ &config.sql_realmgroup_table, "realmgroup" },
+ { "acct_table", PW_TYPE_STRING_PTR,
+ &config.sql_acct_table, "radacct" },
+ { "nas_table", PW_TYPE_STRING_PTR,
+ &config.sql_nas_table, "nas" },
+ { "realm_table", PW_TYPE_STRING_PTR,
+ &config.sql_realm_table, "realms" },
+ { "dict_table", PW_TYPE_STRING_PTR,
+ &config.sql_dict_table, "dictionary" },
+ { NULL, -1, NULL, NULL }
};
static char *group_file = NULL;
static CONF_PARSER module_config[] = {
- { "cache", PW_TYPE_BOOLEAN, &cache_passwd },
- { "passwd", PW_TYPE_STRING_PTR, &passwd_file },
- { "shadow", PW_TYPE_STRING_PTR, &shadow_file },
- { "group", PW_TYPE_STRING_PTR, &group_file },
+ { "cache", PW_TYPE_BOOLEAN, &cache_passwd, "yes" },
+ { "passwd", PW_TYPE_STRING_PTR, &passwd_file, NULL },
+ { "shadow", PW_TYPE_STRING_PTR, &shadow_file, NULL },
+ { "group", PW_TYPE_STRING_PTR, &group_file, NULL },
- { NULL, -1, NULL} /* end the list */
+ { NULL, -1, NULL, NULL } /* end the list */
};
/*