]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Track include files at the top level, instead of each section
authorAlan T. DeKok <aland@freeradius.org>
Fri, 5 Jun 2015 14:37:09 +0000 (10:37 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 5 Jun 2015 18:41:20 +0000 (14:41 -0400)
So that when we're asked to include the same file twice, but
from different sub-sections, we can track that.

src/main/conffile.c

index c29b7a2c3d176e639baa5be55bac2f12bf9524f3..bde9cb601e75d0e82e280c92ea23e5426ebd40ed 100644 (file)
@@ -2693,8 +2693,8 @@ int cf_file_include(CONF_SECTION *cs, char const *filename_in)
        int             lineno = 0;
        struct stat     statbuf;
        time_t          *mtime;
-       CONF_DATA       *cd;
        char const      *filename;
+       CONF_SECTION    *top;
 
        /*
         *      So we only need to do this once.
@@ -2721,7 +2721,9 @@ int cf_file_include(CONF_SECTION *cs, char const *filename_in)
 #endif
        }
 
-       if (cf_data_find_internal(cs, filename, PW_TYPE_FILE_INPUT)) {
+       top = cf_top_section(cs);
+
+       if (cf_data_find_internal(top, filename, PW_TYPE_FILE_INPUT | PW_TYPE_REQUIRED)) {
                fclose(fp);
                ERROR("Cannot include the same file twice: \"%s\"", filename);
 
@@ -2731,21 +2733,13 @@ int cf_file_include(CONF_SECTION *cs, char const *filename_in)
        /*
         *      Add the filename to the section
         */
-       mtime = talloc(cs, time_t);
+       mtime = talloc(top, time_t);
        *mtime = statbuf.st_mtime;
 
-       if (cf_data_add_internal(cs, filename, mtime, NULL, PW_TYPE_FILE_INPUT) < 0) {
-               fclose(fp);
-               ERROR("Internal error opening file \"%s\"",
-                      filename);
-               return -1;
-       }
-
-       cd = cf_data_find_internal(cs, filename, PW_TYPE_FILE_INPUT);
-       if (!cd) {
+       if (cf_data_add_internal(top, filename, mtime, NULL, PW_TYPE_FILE_INPUT | PW_TYPE_REQUIRED) < 0) {
                fclose(fp);
                ERROR("Internal error opening file \"%s\"",
-                      filename);
+                     filename);
                return -1;
        }
 
@@ -2755,7 +2749,7 @@ int cf_file_include(CONF_SECTION *cs, char const *filename_in)
         *      Read the section.  It's OK to have EOF without a
         *      matching close brace.
         */
-       if (cf_section_read(cd->name, &lineno, fp, cs) < 0) {
+       if (cf_section_read(filename, &lineno, fp, cs) < 0) {
                fclose(fp);
                return -1;
        }