Whoops.. old-style realms tried to create pools sized by the
authoraland <aland>
Mon, 3 Sep 2007 09:32:52 +0000 (09:32 +0000)
committeraland <aland>
Mon, 3 Sep 2007 09:32:52 +0000 (09:32 +0000)
sub-sections named "realm" of the current realm, which didn't
exist.

Add a new API to get the next matching section from the parent
of the section we have.  It now works.

src/include/conffile.h
src/main/conffile.c
src/main/realms.c

index 6ab926d..646e077 100644 (file)
@@ -76,6 +76,9 @@ int dump_config(void);
 CONF_SECTION *cf_subsection_find_next(CONF_SECTION *section,
                                      CONF_SECTION *subsection,
                                      const char *name1);
+CONF_SECTION *cf_section_find_next(CONF_SECTION *section,
+                                  CONF_SECTION *subsection,
+                                  const char *name1);
 int cf_section_lineno(CONF_SECTION *section);
 int cf_pair_lineno(CONF_PAIR *pair);
 const char *cf_pair_filename(CONF_PAIR *pair);
index 5eb9f44..fdb0a8b 100644 (file)
@@ -1336,7 +1336,7 @@ static int cf_section_read(const char *filename, int *lineno, FILE *fp,
                                        server = server->item.parent;
                                }
                                
-                               if (!server) {
+                               if (0 && !server) {
                                        radlog(L_ERR, "%s[%d]: Processing directives such as \"%s\" cannot be used here.",
                                               filename, *lineno, buf1);
                                        return -1;
@@ -1792,6 +1792,22 @@ CONF_SECTION *cf_subsection_find_next(CONF_SECTION *section,
        return cf_itemtosection(ci);
 }
 
+
+/*
+ * Return the next section after a CONF_SECTION
+ * with a certain name1 (char *name1). If the requested
+ * name1 is NULL, any name1 matches.
+ */
+
+CONF_SECTION *cf_section_find_next(CONF_SECTION *section,
+                                  CONF_SECTION *subsection,
+                                  const char *name1)
+{
+       if (!section->item.parent) return NULL;
+
+       return cf_subsection_find_next(section->item.parent, subsection, name1);
+}
+
 /*
  * Return the next item after a CONF_ITEM.
  */
index 2d8e5de..5c553a3 100644 (file)
@@ -806,15 +806,21 @@ static int old_server_add(CONF_SECTION *cs, const char *realm,
         *      Count the old-style realms of this name.
         */
        num_home_servers = 0;
-       for (subcs = cf_subsection_find_next(cs, NULL, "realm");
+       for (subcs = cf_section_find_next(cs, NULL, "realm");
             subcs != NULL;
-            subcs = cf_subsection_find_next(cs, subcs, "realm")) {
+            subcs = cf_section_find_next(cs, subcs, "realm")) {
                const char *this = cf_section_name2(subcs);
 
                if (!this || (strcmp(this, realm) != 0)) continue;
                num_home_servers++;
        }
 
+       if (num_home_servers == 0) {
+               cf_log_err(cf_sectiontoitem(cs), "Internal error counting pools for home server %s.", name);
+               free(home);
+               return 0;
+       }
+
        pool = rad_malloc(sizeof(*pool) + num_home_servers * sizeof(pool->servers[0]));
        memset(pool, 0, sizeof(*pool) + num_home_servers * sizeof(pool->servers[0]));