Pass CONF_SECTION to listen_init(), for better error messages
authoraland <aland>
Fri, 29 Jun 2007 09:42:10 +0000 (09:42 +0000)
committeraland <aland>
Fri, 29 Jun 2007 09:42:10 +0000 (09:42 +0000)
src/include/radiusd.h
src/main/listen.c
src/main/mainconfig.c

index 6800699..eb0b4b5 100644 (file)
@@ -470,7 +470,7 @@ int free_mainconfig(void);
 
 /* listen.c */
 void listen_free(rad_listen_t **head);
-int listen_init(const char *filename, rad_listen_t **head);
+int listen_init(CONF_SECTION *cs, rad_listen_t **head);
 rad_listen_t *proxy_new_listener(void);
 
 /* event.c */
index a8d8c11..2d56c04 100644 (file)
@@ -1787,7 +1787,7 @@ static rad_listen_t *listen_parse(CONF_SECTION *cs, const char *server)
  *     Generate a list of listeners.  Takes an input list of
  *     listeners, too, so we don't close sockets with waiting packets.
  */
-int listen_init(const char *filename, rad_listen_t **head)
+int listen_init(CONF_SECTION *config, rad_listen_t **head)
 {
        int             rcode;
        CONF_SECTION    *cs;
@@ -1826,7 +1826,7 @@ int listen_init(const char *filename, rad_listen_t **head)
         *      Else look for bind_address and/or listen sections.
         */
        server_ipaddr.ipaddr.ip4addr.s_addr = htonl(INADDR_NONE);
-       rcode = cf_item_parse(mainconfig.config, "bind_address",
+       rcode = cf_item_parse(config, "bind_address",
                              PW_TYPE_IPADDR,
                              &server_ipaddr.ipaddr.ip4addr, NULL);
        if (rcode < 0) return -1; /* error parsing it */
@@ -1911,9 +1911,9 @@ int listen_init(const char *filename, rad_listen_t **head)
        /*
         *      Walk through the "listen" sections, if they exist.
         */
-       for (cs = cf_subsection_find_next(mainconfig.config, NULL, "listen");
+       for (cs = cf_subsection_find_next(config, NULL, "listen");
             cs != NULL;
-            cs = cf_subsection_find_next(mainconfig.config, cs, "listen")) {
+            cs = cf_subsection_find_next(config, cs, "listen")) {
                this = listen_parse(cs, NULL);
                if (!this) {
                        listen_free(head);
@@ -1929,9 +1929,9 @@ int listen_init(const char *filename, rad_listen_t **head)
         *
         *      FIXME: Move to virtual server init?
         */
-       for (cs = cf_subsection_find_next(mainconfig.config, NULL, "server");
+       for (cs = cf_subsection_find_next(config, NULL, "server");
             cs != NULL;
-            cs = cf_subsection_find_next(mainconfig.config, cs, "server")) {
+            cs = cf_subsection_find_next(config, cs, "server")) {
                CONF_SECTION *subcs;
                const char *name2 = cf_section_name2(cs);
                
index 9f7d900..f7c9e17 100644 (file)
@@ -905,9 +905,7 @@ int read_mainconfig(int reload)
        /*
         *      Read the list of listeners.
         */
-       snprintf(buffer, sizeof(buffer), "%.200s/%.50s",
-                radius_dir, mainconfig.radiusd_conf);
-       if (listen_init(buffer, &listener) < 0) {
+       if (listen_init(cs, &listener) < 0) {
                exit(1);
        }