Previously, the realms were added, then pools, then home servers.
This works, but it is awkward for dynamically adding home servers.
Instead, we should add home servers, then pools, and then realms.
-static int home_server_add(realm_config_t *rc, CONF_SECTION *cs, int pool_type)
+static int home_server_add(realm_config_t *rc, CONF_SECTION *cs)
{
const char *name2;
home_server *home;
{
const char *name2;
home_server *home;
free(hs_virtual_server); /* used only for printing during parsing */
hs_virtual_server = NULL;
free(hs_virtual_server); /* used only for printing during parsing */
hs_virtual_server = NULL;
- name2 = cf_section_name1(cs);
- if (!name2 || (strcasecmp(name2, "home_server") != 0)) {
- cf_log_err(cf_sectiontoitem(cs),
- "Section is not a home_server.");
- return 0;
- }
-
name2 = cf_section_name2(cs);
if (!name2) {
cf_log_err(cf_sectiontoitem(cs),
name2 = cf_section_name2(cs);
if (!name2) {
cf_log_err(cf_sectiontoitem(cs),
if (strcasecmp(hs_type, "auth") == 0) {
home->type = HOME_TYPE_AUTH;
if (home->no_response_fail == 2) home->no_response_fail = 0;
if (strcasecmp(hs_type, "auth") == 0) {
home->type = HOME_TYPE_AUTH;
if (home->no_response_fail == 2) home->no_response_fail = 0;
- if (pool_type != home->type) {
- mismatch:
- cf_log_err(cf_sectiontoitem(cs),
- "Home server %s of unexpected type \"%s\"",
- name2, hs_type);
- goto error;
- }
} else if (strcasecmp(hs_type, "acct") == 0) {
home->type = HOME_TYPE_ACCT;
if (home->no_response_fail == 2) home->no_response_fail = 1;
} else if (strcasecmp(hs_type, "acct") == 0) {
home->type = HOME_TYPE_ACCT;
if (home->no_response_fail == 2) home->no_response_fail = 1;
- if (pool_type != home->type) goto mismatch;
} else if (strcasecmp(hs_type, "auth+acct") == 0) {
home->type = HOME_TYPE_AUTH;
} else if (strcasecmp(hs_type, "auth+acct") == 0) {
home->type = HOME_TYPE_AUTH;
home->type = HOME_TYPE_COA;
dual = FALSE;
home->type = HOME_TYPE_COA;
dual = FALSE;
- if (pool_type != home->type) goto mismatch;
-
if (home->server != NULL) {
cf_log_err(cf_sectiontoitem(cs),
"Home servers of type \"coa\" cannot point to a virtual server");
if (home->server != NULL) {
cf_log_err(cf_sectiontoitem(cs),
"Home servers of type \"coa\" cannot point to a virtual server");
- if (!home_server_add(rc, server_cs, server_type)) {
- return 0;
- }
-
home = rbtree_finddata(home_servers_byname, &myhome);
if (!home) {
cf_log_err(cf_pairtoitem(cp),
home = rbtree_finddata(home_servers_byname, &myhome);
if (!home) {
cf_log_err(cf_pairtoitem(cp),
+ for (cs = cf_subsection_find_next(config, NULL, "home_server");
+ cs != NULL;
+ cs = cf_subsection_find_next(config, cs, "home_server")) {
+ if (!home_server_add(rc, cs)) {
+ free(rc);
+ realms_free();
+ return 0;
+ }
+ }
+
for (cs = cf_subsection_find_next(config, NULL, "realm");
cs != NULL;
cs = cf_subsection_find_next(config, cs, "realm")) {
for (cs = cf_subsection_find_next(config, NULL, "realm");
cs != NULL;
cs = cf_subsection_find_next(config, cs, "realm")) {
-
- /*
- * CoA home servers aren't tied to realms.
- */
- for (cs = cf_subsection_find_next(config, NULL, "home_server");
- cs != NULL;
- cs = cf_subsection_find_next(config, cs, "home_server")) {
- /*
- * Server was already loaded.
- */
- if (cf_data_find(cs, "home_server")) continue;
-
- if (!home_server_add(rc, cs, HOME_TYPE_COA)) {
- return 0;
- }
- }